From 54e9030a7c025e1fd5e26c1c71e5745682ad0caa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9rald=20Barr=C3=A9?= Date: Wed, 8 Jan 2025 10:28:24 -0500 Subject: [PATCH] Allow to disable all rules using a property (#781) --- .github/workflows/ci.yml | 4 +- Meziantou.Analyzer.sln | 2 +- README.md | 14 +- src/DocumentationGenerator/Program.cs | 39 +- .../Meziantou.Analyzer.Pack.csproj | 45 ++ .../build/Meziantou.Analyzer.props | 6 + .../Meziantou.Analyzer.props | 3 + .../buildTransitive/Meziantou.Analyzer.props | 3 + .../configuration/default.editorconfig | 495 ++++++++++++++++++ .../configuration/none.editorconfig | 495 ++++++++++++++++++ src/Meziantou.Analyzer.pack.csproj | 38 -- 11 files changed, 1094 insertions(+), 50 deletions(-) create mode 100644 src/Meziantou.Analyzer.Pack/Meziantou.Analyzer.Pack.csproj create mode 100644 src/Meziantou.Analyzer.Pack/build/Meziantou.Analyzer.props create mode 100644 src/Meziantou.Analyzer.Pack/buildMultiTargeting/Meziantou.Analyzer.props create mode 100644 src/Meziantou.Analyzer.Pack/buildTransitive/Meziantou.Analyzer.props create mode 100644 src/Meziantou.Analyzer.Pack/configuration/default.editorconfig create mode 100644 src/Meziantou.Analyzer.Pack/configuration/none.editorconfig delete mode 100644 src/Meziantou.Analyzer.pack.csproj diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c59d963e4..f0573e264 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -74,8 +74,8 @@ jobs: - run: dotnet build src/Meziantou.Analyzer.CodeFixers/Meziantou.Analyzer.CodeFixers.csproj --configuration Release /p:RoslynVersion=roslyn4.6 /p:Version=${{ needs.compute_package_version.outputs.package_version }} - run: dotnet build src/Meziantou.Analyzer.CodeFixers/Meziantou.Analyzer.CodeFixers.csproj --configuration Release /p:RoslynVersion=roslyn4.8 /p:Version=${{ needs.compute_package_version.outputs.package_version }} - - run: dotnet restore src/Meziantou.Analyzer.pack.csproj - - run: dotnet pack src/Meziantou.Analyzer.pack.csproj --configuration Release --no-build /p:Version=${{ needs.compute_package_version.outputs.package_version }} + - run: dotnet restore src/Meziantou.Analyzer.Pack/Meziantou.Analyzer.Pack.csproj + - run: dotnet pack src/Meziantou.Analyzer.Pack/Meziantou.Analyzer.Pack.csproj --configuration Release --no-build /p:Version=${{ needs.compute_package_version.outputs.package_version }} - run: dotnet pack src/Meziantou.Analyzer.Annotations/Meziantou.Analyzer.Annotations.csproj --configuration Release - uses: actions/upload-artifact@v4 diff --git a/Meziantou.Analyzer.sln b/Meziantou.Analyzer.sln index f10f42c05..077a4bba9 100644 --- a/Meziantou.Analyzer.sln +++ b/Meziantou.Analyzer.sln @@ -23,7 +23,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DocumentationGenerator", "s EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ListDotNetTypes", "src\ListDotNetTypes\ListDotNetTypes.csproj", "{B496BD9C-27CA-44BE-95A9-57CBC99314D4}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Meziantou.Analyzer.pack", "src\Meziantou.Analyzer.pack.csproj", "{6AB20B80-DE7F-4EB3-8A8B-E5C902F06438}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Meziantou.Analyzer.Pack", "src\Meziantou.Analyzer.Pack\Meziantou.Analyzer.Pack.csproj", "{6AB20B80-DE7F-4EB3-8A8B-E5C902F06438}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Meziantou.Analyzer.Annotations", "src\Meziantou.Analyzer.Annotations\Meziantou.Analyzer.Annotations.csproj", "{6C3D4314-A2E3-498F-A2C3-AC10E714A498}" EndProject diff --git a/README.md b/README.md index 06ece215f..c5b9ba2aa 100755 --- a/README.md +++ b/README.md @@ -194,4 +194,16 @@ If you are already using other analyzers, you can check [which rules are duplica |`MAS0002`|[CA1822](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1822?WT.mc_id=DT-MVP-5003978)|Suppress CA1822 on methods decorated with a System.Text.Json attribute such as \[JsonPropertyName\] or \[JsonInclude\].| |`MAS0003`|[IDE0058](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0058?WT.mc_id=DT-MVP-5003978)|Suppress IDE0058 on well-known types| - \ No newline at end of file + + +# Configuration + +You can set the `` MSBuild property to configure the default severity of the rules. The default value is `Default`. You can set it to `None` to disable all rules by default. + +```` + + + None + + +```` diff --git a/src/DocumentationGenerator/Program.cs b/src/DocumentationGenerator/Program.cs index 7df26cf70..f93b49836 100644 --- a/src/DocumentationGenerator/Program.cs +++ b/src/DocumentationGenerator/Program.cs @@ -56,7 +56,7 @@ { // The main readme is embedded into the NuGet package and rendered by nuget.org. // nuget.org's markdown support is limited. Raw html in table is not supported. - var readmePath = Path.GetFullPath(Path.Combine(outputFolder, "README.md")); + var readmePath = outputFolder / "README.md"; var readmeContent = await File.ReadAllTextAsync(readmePath); var newContent = Regex.Replace(readmeContent, "(?<=\\r?\\n).*(?=)", "\n" + GenerateRulesTable(diagnosticAnalyzers, codeFixProviders, addTitle: false) + "\n", RegexOptions.Singleline); newContent = Regex.Replace(newContent, "(?<=\\r?\\n).*(?=)", "\n" + GenerateSuppressorsTable(diagnosticSuppressors) + "\n", RegexOptions.Singleline); @@ -65,7 +65,7 @@ // Update doc readme { - var path = Path.GetFullPath(Path.Combine(outputFolder, "docs", "README.md")); + var path = outputFolder / "docs" / "README.md"; Console.WriteLine(path); WriteFileIfChanged(path, sb.ToString()); } @@ -75,7 +75,7 @@ foreach (var diagnostic in diagnosticAnalyzers.SelectMany(diagnosticAnalyzer => diagnosticAnalyzer.SupportedDiagnostics).DistinctBy(diag => diag.Id).OrderBy(diag => diag.Id, StringComparer.Ordinal)) { var title = $"# {diagnostic.Id} - {EscapeMarkdown(diagnostic.Title.ToString(CultureInfo.InvariantCulture))}"; - var detailPath = Path.GetFullPath(Path.Combine(outputFolder, "docs", "Rules", diagnostic.Id + ".md")); + var detailPath = outputFolder / "docs" / "Rules" / (diagnostic.Id + ".md"); if (File.Exists(detailPath)) { var lines = await File.ReadAllLinesAsync(detailPath); @@ -89,14 +89,30 @@ } } +// Update editorconfig files for NuGet package +{ + GenerateFile(outputFolder / "src" / "Meziantou.Analyzer.Pack" / "configuration" / "none.editorconfig", sb => GenerateEditorConfig(sb, diagnosticAnalyzers, overrideSeverity: "none", appendCodeBlock: false)); + GenerateFile(outputFolder / "src" / "Meziantou.Analyzer.Pack" / "configuration" / "default.editorconfig", sb => GenerateEditorConfig(sb, diagnosticAnalyzers, overrideSeverity: null, appendCodeBlock: false)); + void GenerateFile(FullPath outputPath, Action code) + { + var sb = new StringBuilder(); + sb.Append("# This file is generated by the build process. Do not edit it manually.\n"); + sb.Append("is_global = true\n"); + sb.Append("global_level = 0\n"); + sb.Append('\n'); + code(sb); + WriteFileIfChanged(outputPath, sb.ToString()); + } +} + return fileWritten; -void WriteFileIfChanged(string path, string content) +void WriteFileIfChanged(FullPath path, string content) { content = content.ReplaceLineEndings("\n"); - if (!File.Exists(path)) { + path.CreateParentDirectory(); File.WriteAllText(path, content); fileWritten++; return; @@ -200,9 +216,13 @@ static string GenerateSuppressorsTable(List diagnosticSupp return sb.ToString(); } -static void GenerateEditorConfig(StringBuilder sb, List analyzers, string? overrideSeverity = null) +static void GenerateEditorConfig(StringBuilder sb, List analyzers, string? overrideSeverity = null, bool appendCodeBlock = true) { - sb.Append("```editorconfig\n"); + if (appendCodeBlock) + { + sb.Append("```editorconfig\n"); + } + var first = true; foreach (var diagnostic in analyzers.SelectMany(diagnosticAnalyzer => diagnosticAnalyzer.SupportedDiagnostics).DistinctBy(diag => diag.Id).OrderBy(diag => diag.Id, StringComparer.Ordinal)) { @@ -237,7 +257,10 @@ static void GenerateEditorConfig(StringBuilder sb, List anal first = false; } - sb.Append("```\n"); + if (appendCodeBlock) + { + sb.Append("```\n"); + } } static string GetSeverity(DiagnosticSeverity severity) diff --git a/src/Meziantou.Analyzer.Pack/Meziantou.Analyzer.Pack.csproj b/src/Meziantou.Analyzer.Pack/Meziantou.Analyzer.Pack.csproj new file mode 100644 index 000000000..6b23e5e3e --- /dev/null +++ b/src/Meziantou.Analyzer.Pack/Meziantou.Analyzer.Pack.csproj @@ -0,0 +1,45 @@ + + + netstandard2.0 + false + false + false + true + true + + 2.0.0 + + Meziantou.Analyzer + A Roslyn analyzer to enforce some good practices in C# + Meziantou.Analyzer, analyzers + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Meziantou.Analyzer.Pack/build/Meziantou.Analyzer.props b/src/Meziantou.Analyzer.Pack/build/Meziantou.Analyzer.props new file mode 100644 index 000000000..3d104410a --- /dev/null +++ b/src/Meziantou.Analyzer.Pack/build/Meziantou.Analyzer.props @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/Meziantou.Analyzer.Pack/buildMultiTargeting/Meziantou.Analyzer.props b/src/Meziantou.Analyzer.Pack/buildMultiTargeting/Meziantou.Analyzer.props new file mode 100644 index 000000000..fcb0d0e54 --- /dev/null +++ b/src/Meziantou.Analyzer.Pack/buildMultiTargeting/Meziantou.Analyzer.props @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/Meziantou.Analyzer.Pack/buildTransitive/Meziantou.Analyzer.props b/src/Meziantou.Analyzer.Pack/buildTransitive/Meziantou.Analyzer.props new file mode 100644 index 000000000..fcb0d0e54 --- /dev/null +++ b/src/Meziantou.Analyzer.Pack/buildTransitive/Meziantou.Analyzer.props @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/Meziantou.Analyzer.Pack/configuration/default.editorconfig b/src/Meziantou.Analyzer.Pack/configuration/default.editorconfig new file mode 100644 index 000000000..547b04366 --- /dev/null +++ b/src/Meziantou.Analyzer.Pack/configuration/default.editorconfig @@ -0,0 +1,495 @@ +# This file is generated by the build process. Do not edit it manually. +is_global = true +global_level = 0 + +# MA0001: StringComparison is missing +dotnet_diagnostic.MA0001.severity = suggestion + +# MA0002: IEqualityComparer or IComparer is missing +dotnet_diagnostic.MA0002.severity = warning + +# MA0003: Add parameter name to improve readability +dotnet_diagnostic.MA0003.severity = suggestion + +# MA0004: Use Task.ConfigureAwait +dotnet_diagnostic.MA0004.severity = warning + +# MA0005: Use Array.Empty() +dotnet_diagnostic.MA0005.severity = warning + +# MA0006: Use String.Equals instead of equality operator +dotnet_diagnostic.MA0006.severity = warning + +# MA0007: Add a comma after the last value +dotnet_diagnostic.MA0007.severity = suggestion + +# MA0008: Add StructLayoutAttribute +dotnet_diagnostic.MA0008.severity = warning + +# MA0009: Add regex evaluation timeout +dotnet_diagnostic.MA0009.severity = warning + +# MA0010: Mark attributes with AttributeUsageAttribute +dotnet_diagnostic.MA0010.severity = warning + +# MA0011: IFormatProvider is missing +dotnet_diagnostic.MA0011.severity = warning + +# MA0012: Do not raise reserved exception type +dotnet_diagnostic.MA0012.severity = warning + +# MA0013: Types should not extend System.ApplicationException +dotnet_diagnostic.MA0013.severity = warning + +# MA0014: Do not raise System.ApplicationException type +dotnet_diagnostic.MA0014.severity = warning + +# MA0015: Specify the parameter name in ArgumentException +dotnet_diagnostic.MA0015.severity = warning + +# MA0016: Prefer using collection abstraction instead of implementation +dotnet_diagnostic.MA0016.severity = warning + +# MA0017: Abstract types should not have public or internal constructors +dotnet_diagnostic.MA0017.severity = warning + +# MA0018: Do not declare static members on generic types (deprecated; use CA1000 instead) +dotnet_diagnostic.MA0018.severity = suggestion + +# MA0019: Use EventArgs.Empty +dotnet_diagnostic.MA0019.severity = warning + +# MA0020: Use direct methods instead of LINQ methods +dotnet_diagnostic.MA0020.severity = suggestion + +# MA0021: Use StringComparer.GetHashCode instead of string.GetHashCode +dotnet_diagnostic.MA0021.severity = warning + +# MA0022: Return Task.FromResult instead of returning null +dotnet_diagnostic.MA0022.severity = warning + +# MA0023: Add RegexOptions.ExplicitCapture +dotnet_diagnostic.MA0023.severity = warning + +# MA0024: Use an explicit StringComparer when possible +dotnet_diagnostic.MA0024.severity = warning + +# MA0025: Implement the functionality instead of throwing NotImplementedException +dotnet_diagnostic.MA0025.severity = warning + +# MA0026: Fix TODO comment +dotnet_diagnostic.MA0026.severity = warning + +# MA0027: Prefer rethrowing an exception implicitly +dotnet_diagnostic.MA0027.severity = warning + +# MA0028: Optimize StringBuilder usage +dotnet_diagnostic.MA0028.severity = suggestion + +# MA0029: Combine LINQ methods +dotnet_diagnostic.MA0029.severity = suggestion + +# MA0030: Remove useless OrderBy call +dotnet_diagnostic.MA0030.severity = warning + +# MA0031: Optimize Enumerable.Count() usage +dotnet_diagnostic.MA0031.severity = suggestion + +# MA0032: Use an overload with a CancellationToken argument +dotnet_diagnostic.MA0032.severity = none + +# MA0033: Do not tag instance fields with ThreadStaticAttribute +dotnet_diagnostic.MA0033.severity = warning + +# MA0035: Do not use dangerous threading methods +dotnet_diagnostic.MA0035.severity = warning + +# MA0036: Make class static +dotnet_diagnostic.MA0036.severity = suggestion + +# MA0037: Remove empty statement +dotnet_diagnostic.MA0037.severity = error + +# MA0038: Make method static (deprecated, use CA1822 instead) +dotnet_diagnostic.MA0038.severity = suggestion + +# MA0039: Do not write your own certificate validation method +dotnet_diagnostic.MA0039.severity = error + +# MA0040: Forward the CancellationToken parameter to methods that take one +dotnet_diagnostic.MA0040.severity = suggestion + +# MA0041: Make property static (deprecated, use CA1822 instead) +dotnet_diagnostic.MA0041.severity = suggestion + +# MA0042: Do not use blocking calls in an async method +dotnet_diagnostic.MA0042.severity = suggestion + +# MA0043: Use nameof operator in ArgumentException +dotnet_diagnostic.MA0043.severity = suggestion + +# MA0044: Remove useless ToString call +dotnet_diagnostic.MA0044.severity = suggestion + +# MA0045: Do not use blocking calls in a sync method (need to make calling method async) +dotnet_diagnostic.MA0045.severity = none + +# MA0046: Use EventHandler to declare events +dotnet_diagnostic.MA0046.severity = warning + +# MA0047: Declare types in namespaces +dotnet_diagnostic.MA0047.severity = warning + +# MA0048: File name must match type name +dotnet_diagnostic.MA0048.severity = warning + +# MA0049: Type name should not match containing namespace +dotnet_diagnostic.MA0049.severity = error + +# MA0050: Validate arguments correctly in iterator methods +dotnet_diagnostic.MA0050.severity = suggestion + +# MA0051: Method is too long +dotnet_diagnostic.MA0051.severity = warning + +# MA0052: Replace constant Enum.ToString with nameof +dotnet_diagnostic.MA0052.severity = suggestion + +# MA0053: Make class sealed +dotnet_diagnostic.MA0053.severity = suggestion + +# MA0054: Embed the caught exception as innerException +dotnet_diagnostic.MA0054.severity = warning + +# MA0055: Do not use finalizer +dotnet_diagnostic.MA0055.severity = warning + +# MA0056: Do not call overridable members in constructor +dotnet_diagnostic.MA0056.severity = warning + +# MA0057: Class name should end with 'Attribute' +dotnet_diagnostic.MA0057.severity = suggestion + +# MA0058: Class name should end with 'Exception' +dotnet_diagnostic.MA0058.severity = suggestion + +# MA0059: Class name should end with 'EventArgs' +dotnet_diagnostic.MA0059.severity = suggestion + +# MA0060: The value returned by Stream.Read/Stream.ReadAsync is not used +dotnet_diagnostic.MA0060.severity = warning + +# MA0061: Method overrides should not change default values +dotnet_diagnostic.MA0061.severity = warning + +# MA0062: Non-flags enums should not be marked with "FlagsAttribute" +dotnet_diagnostic.MA0062.severity = warning + +# MA0063: Use Where before OrderBy +dotnet_diagnostic.MA0063.severity = suggestion + +# MA0064: Avoid locking on publicly accessible instance +dotnet_diagnostic.MA0064.severity = warning + +# MA0065: Default ValueType.Equals or HashCode is used for struct equality +dotnet_diagnostic.MA0065.severity = warning + +# MA0066: Hash table unfriendly type is used in a hash table +dotnet_diagnostic.MA0066.severity = warning + +# MA0067: Use Guid.Empty +dotnet_diagnostic.MA0067.severity = suggestion + +# MA0068: Invalid parameter name for nullable attribute +dotnet_diagnostic.MA0068.severity = warning + +# MA0069: Non-constant static fields should not be visible +dotnet_diagnostic.MA0069.severity = warning + +# MA0070: Obsolete attributes should include explanations +dotnet_diagnostic.MA0070.severity = warning + +# MA0071: Avoid using redundant else +dotnet_diagnostic.MA0071.severity = suggestion + +# MA0072: Do not throw from a finally block +dotnet_diagnostic.MA0072.severity = warning + +# MA0073: Avoid comparison with bool constant +dotnet_diagnostic.MA0073.severity = suggestion + +# MA0074: Avoid implicit culture-sensitive methods +dotnet_diagnostic.MA0074.severity = warning + +# MA0075: Do not use implicit culture-sensitive ToString +dotnet_diagnostic.MA0075.severity = suggestion + +# MA0076: Do not use implicit culture-sensitive ToString in interpolated strings +dotnet_diagnostic.MA0076.severity = suggestion + +# MA0077: A class that provides Equals(T) should implement IEquatable +dotnet_diagnostic.MA0077.severity = warning + +# MA0078: Use 'Cast' instead of 'Select' to cast +dotnet_diagnostic.MA0078.severity = suggestion + +# MA0079: Forward the CancellationToken using .WithCancellation() +dotnet_diagnostic.MA0079.severity = suggestion + +# MA0080: Use a cancellation token using .WithCancellation() +dotnet_diagnostic.MA0080.severity = none + +# MA0081: Method overrides should not omit params keyword +dotnet_diagnostic.MA0081.severity = warning + +# MA0082: NaN should not be used in comparisons +dotnet_diagnostic.MA0082.severity = warning + +# MA0083: ConstructorArgument parameters should exist in constructors +dotnet_diagnostic.MA0083.severity = warning + +# MA0084: Local variables should not hide other symbols +dotnet_diagnostic.MA0084.severity = warning + +# MA0085: Anonymous delegates should not be used to unsubscribe from Events +dotnet_diagnostic.MA0085.severity = warning + +# MA0086: Do not throw from a finalizer +dotnet_diagnostic.MA0086.severity = warning + +# MA0087: Parameters with [DefaultParameterValue] attributes should also be marked [Optional] +dotnet_diagnostic.MA0087.severity = warning + +# MA0088: Use [DefaultParameterValue] instead of [DefaultValue] +dotnet_diagnostic.MA0088.severity = warning + +# MA0089: Optimize string method usage +dotnet_diagnostic.MA0089.severity = suggestion + +# MA0090: Remove empty else/finally block +dotnet_diagnostic.MA0090.severity = suggestion + +# MA0091: Sender should be 'this' for instance events +dotnet_diagnostic.MA0091.severity = warning + +# MA0092: Sender should be 'null' for static events +dotnet_diagnostic.MA0092.severity = warning + +# MA0093: EventArgs should not be null +dotnet_diagnostic.MA0093.severity = warning + +# MA0094: A class that provides CompareTo(T) should implement IComparable +dotnet_diagnostic.MA0094.severity = warning + +# MA0095: A class that implements IEquatable should override Equals(object) +dotnet_diagnostic.MA0095.severity = warning + +# MA0096: A class that implements IComparable should also implement IEquatable +dotnet_diagnostic.MA0096.severity = warning + +# MA0097: A class that implements IComparable or IComparable should override comparison operators +dotnet_diagnostic.MA0097.severity = warning + +# MA0098: Use indexer instead of LINQ methods +dotnet_diagnostic.MA0098.severity = suggestion + +# MA0099: Use Explicit enum value instead of 0 +dotnet_diagnostic.MA0099.severity = warning + +# MA0100: Await task before disposing of resources +dotnet_diagnostic.MA0100.severity = warning + +# MA0101: String contains an implicit end of line character +dotnet_diagnostic.MA0101.severity = silent + +# MA0102: Make member readonly +dotnet_diagnostic.MA0102.severity = suggestion + +# MA0103: Use SequenceEqual instead of equality operator +dotnet_diagnostic.MA0103.severity = warning + +# MA0104: Do not create a type with a name from the BCL +dotnet_diagnostic.MA0104.severity = none + +# MA0105: Use the lambda parameters instead of using a closure +dotnet_diagnostic.MA0105.severity = suggestion + +# MA0106: Avoid closure by using an overload with the 'factoryArgument' parameter +dotnet_diagnostic.MA0106.severity = suggestion + +# MA0107: Do not use culture-sensitive object.ToString +dotnet_diagnostic.MA0107.severity = none + +# MA0108: Remove redundant argument value +dotnet_diagnostic.MA0108.severity = suggestion + +# MA0109: Consider adding an overload with a Span or Memory +dotnet_diagnostic.MA0109.severity = none + +# MA0110: Use the Regex source generator +dotnet_diagnostic.MA0110.severity = suggestion + +# MA0111: Use string.Create instead of FormattableString +dotnet_diagnostic.MA0111.severity = suggestion + +# MA0112: Use 'Count > 0' instead of 'Any()' +dotnet_diagnostic.MA0112.severity = none + +# MA0113: Use DateTime.UnixEpoch +dotnet_diagnostic.MA0113.severity = suggestion + +# MA0114: Use DateTimeOffset.UnixEpoch +dotnet_diagnostic.MA0114.severity = suggestion + +# MA0115: Unknown component parameter +dotnet_diagnostic.MA0115.severity = warning + +# MA0116: Parameters with [SupplyParameterFromQuery] attributes should also be marked as [Parameter] +dotnet_diagnostic.MA0116.severity = warning + +# MA0117: Parameters with [EditorRequired] attributes should also be marked as [Parameter] +dotnet_diagnostic.MA0117.severity = warning + +# MA0118: [JSInvokable] methods must be public +dotnet_diagnostic.MA0118.severity = warning + +# MA0119: JSRuntime must not be used in OnInitialized or OnInitializedAsync +dotnet_diagnostic.MA0119.severity = warning + +# MA0120: Use InvokeVoidAsync when the returned value is not used +dotnet_diagnostic.MA0120.severity = suggestion + +# MA0121: Do not overwrite parameter value +dotnet_diagnostic.MA0121.severity = none + +# MA0122: Parameters with [SupplyParameterFromQuery] attributes are only valid in routable components (@page) +dotnet_diagnostic.MA0122.severity = suggestion + +# MA0123: Sequence number must be a constant +dotnet_diagnostic.MA0123.severity = warning + +# MA0124: Log parameter type is not valid +dotnet_diagnostic.MA0124.severity = warning + +# MA0125: The list of log parameter types contains an invalid type +dotnet_diagnostic.MA0125.severity = warning + +# MA0126: The list of log parameter types contains a duplicate +dotnet_diagnostic.MA0126.severity = warning + +# MA0127: Use String.Equals instead of is pattern +dotnet_diagnostic.MA0127.severity = none + +# MA0128: Use 'is' operator instead of SequenceEqual +dotnet_diagnostic.MA0128.severity = suggestion + +# MA0129: Await task in using statement +dotnet_diagnostic.MA0129.severity = warning + +# MA0130: GetType() should not be used on System.Type instances +dotnet_diagnostic.MA0130.severity = warning + +# MA0131: ArgumentNullException.ThrowIfNull should not be used with non-nullable types +dotnet_diagnostic.MA0131.severity = warning + +# MA0132: Do not convert implicitly to DateTimeOffset +dotnet_diagnostic.MA0132.severity = warning + +# MA0133: Use DateTimeOffset instead of relying on the implicit conversion +dotnet_diagnostic.MA0133.severity = suggestion + +# MA0134: Observe result of async calls +dotnet_diagnostic.MA0134.severity = warning + +# MA0135: The log parameter has no configured type +dotnet_diagnostic.MA0135.severity = none + +# MA0136: Raw String contains an implicit end of line character +dotnet_diagnostic.MA0136.severity = silent + +# MA0137: Use 'Async' suffix when a method returns an awaitable type +dotnet_diagnostic.MA0137.severity = none + +# MA0138: Do not use 'Async' suffix when a method does not return an awaitable type +dotnet_diagnostic.MA0138.severity = none + +# MA0139: Log parameter type is not valid +dotnet_diagnostic.MA0139.severity = warning + +# MA0140: Both if and else branch have identical code +dotnet_diagnostic.MA0140.severity = warning + +# MA0141: Use pattern matching instead of inequality operators for null check +dotnet_diagnostic.MA0141.severity = none + +# MA0142: Use pattern matching instead of equality operators for null check +dotnet_diagnostic.MA0142.severity = none + +# MA0143: Primary constructor parameters should be readonly +dotnet_diagnostic.MA0143.severity = warning + +# MA0144: Use System.OperatingSystem to check the current OS +dotnet_diagnostic.MA0144.severity = warning + +# MA0145: Signature for [UnsafeAccessorAttribute] method is not valid +dotnet_diagnostic.MA0145.severity = warning + +# MA0146: Name must be set explicitly on local functions +dotnet_diagnostic.MA0146.severity = warning + +# MA0147: Avoid async void method for delegate +dotnet_diagnostic.MA0147.severity = warning + +# MA0148: Use pattern matching instead of equality operators for discrete value +dotnet_diagnostic.MA0148.severity = none + +# MA0149: Use pattern matching instead of inequality operators for discrete value +dotnet_diagnostic.MA0149.severity = none + +# MA0150: Do not call the default object.ToString explicitly +dotnet_diagnostic.MA0150.severity = warning + +# MA0151: DebuggerDisplay must contain valid members +dotnet_diagnostic.MA0151.severity = warning + +# MA0152: Use Unwrap instead of using await twice +dotnet_diagnostic.MA0152.severity = suggestion + +# MA0153: Do not log symbols decorated with DataClassificationAttribute directly +dotnet_diagnostic.MA0153.severity = warning + +# MA0154: Use langword in XML comment +dotnet_diagnostic.MA0154.severity = suggestion + +# MA0155: Do not use async void methods +dotnet_diagnostic.MA0155.severity = none + +# MA0156: Use 'Async' suffix when a method returns IAsyncEnumerable +dotnet_diagnostic.MA0156.severity = none + +# MA0157: Do not use 'Async' suffix when a method does not return IAsyncEnumerable +dotnet_diagnostic.MA0157.severity = none + +# MA0158: Use System.Threading.Lock +dotnet_diagnostic.MA0158.severity = warning + +# MA0159: Use 'Order' instead of 'OrderBy' +dotnet_diagnostic.MA0159.severity = suggestion + +# MA0160: Use ContainsKey instead of TryGetValue +dotnet_diagnostic.MA0160.severity = suggestion + +# MA0161: UseShellExecute must be explicitly set +dotnet_diagnostic.MA0161.severity = none + +# MA0162: Use Process.Start overload with ProcessStartInfo +dotnet_diagnostic.MA0162.severity = none + +# MA0163: UseShellExecute must be false when redirecting standard input or output +dotnet_diagnostic.MA0163.severity = warning + +# MA0164: Use parentheses to make not pattern clearer +dotnet_diagnostic.MA0164.severity = warning + +# MA0165: Make interpolated string +dotnet_diagnostic.MA0165.severity = silent diff --git a/src/Meziantou.Analyzer.Pack/configuration/none.editorconfig b/src/Meziantou.Analyzer.Pack/configuration/none.editorconfig new file mode 100644 index 000000000..c02bf124a --- /dev/null +++ b/src/Meziantou.Analyzer.Pack/configuration/none.editorconfig @@ -0,0 +1,495 @@ +# This file is generated by the build process. Do not edit it manually. +is_global = true +global_level = 0 + +# MA0001: StringComparison is missing +dotnet_diagnostic.MA0001.severity = none + +# MA0002: IEqualityComparer or IComparer is missing +dotnet_diagnostic.MA0002.severity = none + +# MA0003: Add parameter name to improve readability +dotnet_diagnostic.MA0003.severity = none + +# MA0004: Use Task.ConfigureAwait +dotnet_diagnostic.MA0004.severity = none + +# MA0005: Use Array.Empty() +dotnet_diagnostic.MA0005.severity = none + +# MA0006: Use String.Equals instead of equality operator +dotnet_diagnostic.MA0006.severity = none + +# MA0007: Add a comma after the last value +dotnet_diagnostic.MA0007.severity = none + +# MA0008: Add StructLayoutAttribute +dotnet_diagnostic.MA0008.severity = none + +# MA0009: Add regex evaluation timeout +dotnet_diagnostic.MA0009.severity = none + +# MA0010: Mark attributes with AttributeUsageAttribute +dotnet_diagnostic.MA0010.severity = none + +# MA0011: IFormatProvider is missing +dotnet_diagnostic.MA0011.severity = none + +# MA0012: Do not raise reserved exception type +dotnet_diagnostic.MA0012.severity = none + +# MA0013: Types should not extend System.ApplicationException +dotnet_diagnostic.MA0013.severity = none + +# MA0014: Do not raise System.ApplicationException type +dotnet_diagnostic.MA0014.severity = none + +# MA0015: Specify the parameter name in ArgumentException +dotnet_diagnostic.MA0015.severity = none + +# MA0016: Prefer using collection abstraction instead of implementation +dotnet_diagnostic.MA0016.severity = none + +# MA0017: Abstract types should not have public or internal constructors +dotnet_diagnostic.MA0017.severity = none + +# MA0018: Do not declare static members on generic types (deprecated; use CA1000 instead) +dotnet_diagnostic.MA0018.severity = none + +# MA0019: Use EventArgs.Empty +dotnet_diagnostic.MA0019.severity = none + +# MA0020: Use direct methods instead of LINQ methods +dotnet_diagnostic.MA0020.severity = none + +# MA0021: Use StringComparer.GetHashCode instead of string.GetHashCode +dotnet_diagnostic.MA0021.severity = none + +# MA0022: Return Task.FromResult instead of returning null +dotnet_diagnostic.MA0022.severity = none + +# MA0023: Add RegexOptions.ExplicitCapture +dotnet_diagnostic.MA0023.severity = none + +# MA0024: Use an explicit StringComparer when possible +dotnet_diagnostic.MA0024.severity = none + +# MA0025: Implement the functionality instead of throwing NotImplementedException +dotnet_diagnostic.MA0025.severity = none + +# MA0026: Fix TODO comment +dotnet_diagnostic.MA0026.severity = none + +# MA0027: Prefer rethrowing an exception implicitly +dotnet_diagnostic.MA0027.severity = none + +# MA0028: Optimize StringBuilder usage +dotnet_diagnostic.MA0028.severity = none + +# MA0029: Combine LINQ methods +dotnet_diagnostic.MA0029.severity = none + +# MA0030: Remove useless OrderBy call +dotnet_diagnostic.MA0030.severity = none + +# MA0031: Optimize Enumerable.Count() usage +dotnet_diagnostic.MA0031.severity = none + +# MA0032: Use an overload with a CancellationToken argument +dotnet_diagnostic.MA0032.severity = none + +# MA0033: Do not tag instance fields with ThreadStaticAttribute +dotnet_diagnostic.MA0033.severity = none + +# MA0035: Do not use dangerous threading methods +dotnet_diagnostic.MA0035.severity = none + +# MA0036: Make class static +dotnet_diagnostic.MA0036.severity = none + +# MA0037: Remove empty statement +dotnet_diagnostic.MA0037.severity = none + +# MA0038: Make method static (deprecated, use CA1822 instead) +dotnet_diagnostic.MA0038.severity = none + +# MA0039: Do not write your own certificate validation method +dotnet_diagnostic.MA0039.severity = none + +# MA0040: Forward the CancellationToken parameter to methods that take one +dotnet_diagnostic.MA0040.severity = none + +# MA0041: Make property static (deprecated, use CA1822 instead) +dotnet_diagnostic.MA0041.severity = none + +# MA0042: Do not use blocking calls in an async method +dotnet_diagnostic.MA0042.severity = none + +# MA0043: Use nameof operator in ArgumentException +dotnet_diagnostic.MA0043.severity = none + +# MA0044: Remove useless ToString call +dotnet_diagnostic.MA0044.severity = none + +# MA0045: Do not use blocking calls in a sync method (need to make calling method async) +dotnet_diagnostic.MA0045.severity = none + +# MA0046: Use EventHandler to declare events +dotnet_diagnostic.MA0046.severity = none + +# MA0047: Declare types in namespaces +dotnet_diagnostic.MA0047.severity = none + +# MA0048: File name must match type name +dotnet_diagnostic.MA0048.severity = none + +# MA0049: Type name should not match containing namespace +dotnet_diagnostic.MA0049.severity = none + +# MA0050: Validate arguments correctly in iterator methods +dotnet_diagnostic.MA0050.severity = none + +# MA0051: Method is too long +dotnet_diagnostic.MA0051.severity = none + +# MA0052: Replace constant Enum.ToString with nameof +dotnet_diagnostic.MA0052.severity = none + +# MA0053: Make class sealed +dotnet_diagnostic.MA0053.severity = none + +# MA0054: Embed the caught exception as innerException +dotnet_diagnostic.MA0054.severity = none + +# MA0055: Do not use finalizer +dotnet_diagnostic.MA0055.severity = none + +# MA0056: Do not call overridable members in constructor +dotnet_diagnostic.MA0056.severity = none + +# MA0057: Class name should end with 'Attribute' +dotnet_diagnostic.MA0057.severity = none + +# MA0058: Class name should end with 'Exception' +dotnet_diagnostic.MA0058.severity = none + +# MA0059: Class name should end with 'EventArgs' +dotnet_diagnostic.MA0059.severity = none + +# MA0060: The value returned by Stream.Read/Stream.ReadAsync is not used +dotnet_diagnostic.MA0060.severity = none + +# MA0061: Method overrides should not change default values +dotnet_diagnostic.MA0061.severity = none + +# MA0062: Non-flags enums should not be marked with "FlagsAttribute" +dotnet_diagnostic.MA0062.severity = none + +# MA0063: Use Where before OrderBy +dotnet_diagnostic.MA0063.severity = none + +# MA0064: Avoid locking on publicly accessible instance +dotnet_diagnostic.MA0064.severity = none + +# MA0065: Default ValueType.Equals or HashCode is used for struct equality +dotnet_diagnostic.MA0065.severity = none + +# MA0066: Hash table unfriendly type is used in a hash table +dotnet_diagnostic.MA0066.severity = none + +# MA0067: Use Guid.Empty +dotnet_diagnostic.MA0067.severity = none + +# MA0068: Invalid parameter name for nullable attribute +dotnet_diagnostic.MA0068.severity = none + +# MA0069: Non-constant static fields should not be visible +dotnet_diagnostic.MA0069.severity = none + +# MA0070: Obsolete attributes should include explanations +dotnet_diagnostic.MA0070.severity = none + +# MA0071: Avoid using redundant else +dotnet_diagnostic.MA0071.severity = none + +# MA0072: Do not throw from a finally block +dotnet_diagnostic.MA0072.severity = none + +# MA0073: Avoid comparison with bool constant +dotnet_diagnostic.MA0073.severity = none + +# MA0074: Avoid implicit culture-sensitive methods +dotnet_diagnostic.MA0074.severity = none + +# MA0075: Do not use implicit culture-sensitive ToString +dotnet_diagnostic.MA0075.severity = none + +# MA0076: Do not use implicit culture-sensitive ToString in interpolated strings +dotnet_diagnostic.MA0076.severity = none + +# MA0077: A class that provides Equals(T) should implement IEquatable +dotnet_diagnostic.MA0077.severity = none + +# MA0078: Use 'Cast' instead of 'Select' to cast +dotnet_diagnostic.MA0078.severity = none + +# MA0079: Forward the CancellationToken using .WithCancellation() +dotnet_diagnostic.MA0079.severity = none + +# MA0080: Use a cancellation token using .WithCancellation() +dotnet_diagnostic.MA0080.severity = none + +# MA0081: Method overrides should not omit params keyword +dotnet_diagnostic.MA0081.severity = none + +# MA0082: NaN should not be used in comparisons +dotnet_diagnostic.MA0082.severity = none + +# MA0083: ConstructorArgument parameters should exist in constructors +dotnet_diagnostic.MA0083.severity = none + +# MA0084: Local variables should not hide other symbols +dotnet_diagnostic.MA0084.severity = none + +# MA0085: Anonymous delegates should not be used to unsubscribe from Events +dotnet_diagnostic.MA0085.severity = none + +# MA0086: Do not throw from a finalizer +dotnet_diagnostic.MA0086.severity = none + +# MA0087: Parameters with [DefaultParameterValue] attributes should also be marked [Optional] +dotnet_diagnostic.MA0087.severity = none + +# MA0088: Use [DefaultParameterValue] instead of [DefaultValue] +dotnet_diagnostic.MA0088.severity = none + +# MA0089: Optimize string method usage +dotnet_diagnostic.MA0089.severity = none + +# MA0090: Remove empty else/finally block +dotnet_diagnostic.MA0090.severity = none + +# MA0091: Sender should be 'this' for instance events +dotnet_diagnostic.MA0091.severity = none + +# MA0092: Sender should be 'null' for static events +dotnet_diagnostic.MA0092.severity = none + +# MA0093: EventArgs should not be null +dotnet_diagnostic.MA0093.severity = none + +# MA0094: A class that provides CompareTo(T) should implement IComparable +dotnet_diagnostic.MA0094.severity = none + +# MA0095: A class that implements IEquatable should override Equals(object) +dotnet_diagnostic.MA0095.severity = none + +# MA0096: A class that implements IComparable should also implement IEquatable +dotnet_diagnostic.MA0096.severity = none + +# MA0097: A class that implements IComparable or IComparable should override comparison operators +dotnet_diagnostic.MA0097.severity = none + +# MA0098: Use indexer instead of LINQ methods +dotnet_diagnostic.MA0098.severity = none + +# MA0099: Use Explicit enum value instead of 0 +dotnet_diagnostic.MA0099.severity = none + +# MA0100: Await task before disposing of resources +dotnet_diagnostic.MA0100.severity = none + +# MA0101: String contains an implicit end of line character +dotnet_diagnostic.MA0101.severity = none + +# MA0102: Make member readonly +dotnet_diagnostic.MA0102.severity = none + +# MA0103: Use SequenceEqual instead of equality operator +dotnet_diagnostic.MA0103.severity = none + +# MA0104: Do not create a type with a name from the BCL +dotnet_diagnostic.MA0104.severity = none + +# MA0105: Use the lambda parameters instead of using a closure +dotnet_diagnostic.MA0105.severity = none + +# MA0106: Avoid closure by using an overload with the 'factoryArgument' parameter +dotnet_diagnostic.MA0106.severity = none + +# MA0107: Do not use culture-sensitive object.ToString +dotnet_diagnostic.MA0107.severity = none + +# MA0108: Remove redundant argument value +dotnet_diagnostic.MA0108.severity = none + +# MA0109: Consider adding an overload with a Span or Memory +dotnet_diagnostic.MA0109.severity = none + +# MA0110: Use the Regex source generator +dotnet_diagnostic.MA0110.severity = none + +# MA0111: Use string.Create instead of FormattableString +dotnet_diagnostic.MA0111.severity = none + +# MA0112: Use 'Count > 0' instead of 'Any()' +dotnet_diagnostic.MA0112.severity = none + +# MA0113: Use DateTime.UnixEpoch +dotnet_diagnostic.MA0113.severity = none + +# MA0114: Use DateTimeOffset.UnixEpoch +dotnet_diagnostic.MA0114.severity = none + +# MA0115: Unknown component parameter +dotnet_diagnostic.MA0115.severity = none + +# MA0116: Parameters with [SupplyParameterFromQuery] attributes should also be marked as [Parameter] +dotnet_diagnostic.MA0116.severity = none + +# MA0117: Parameters with [EditorRequired] attributes should also be marked as [Parameter] +dotnet_diagnostic.MA0117.severity = none + +# MA0118: [JSInvokable] methods must be public +dotnet_diagnostic.MA0118.severity = none + +# MA0119: JSRuntime must not be used in OnInitialized or OnInitializedAsync +dotnet_diagnostic.MA0119.severity = none + +# MA0120: Use InvokeVoidAsync when the returned value is not used +dotnet_diagnostic.MA0120.severity = none + +# MA0121: Do not overwrite parameter value +dotnet_diagnostic.MA0121.severity = none + +# MA0122: Parameters with [SupplyParameterFromQuery] attributes are only valid in routable components (@page) +dotnet_diagnostic.MA0122.severity = none + +# MA0123: Sequence number must be a constant +dotnet_diagnostic.MA0123.severity = none + +# MA0124: Log parameter type is not valid +dotnet_diagnostic.MA0124.severity = none + +# MA0125: The list of log parameter types contains an invalid type +dotnet_diagnostic.MA0125.severity = none + +# MA0126: The list of log parameter types contains a duplicate +dotnet_diagnostic.MA0126.severity = none + +# MA0127: Use String.Equals instead of is pattern +dotnet_diagnostic.MA0127.severity = none + +# MA0128: Use 'is' operator instead of SequenceEqual +dotnet_diagnostic.MA0128.severity = none + +# MA0129: Await task in using statement +dotnet_diagnostic.MA0129.severity = none + +# MA0130: GetType() should not be used on System.Type instances +dotnet_diagnostic.MA0130.severity = none + +# MA0131: ArgumentNullException.ThrowIfNull should not be used with non-nullable types +dotnet_diagnostic.MA0131.severity = none + +# MA0132: Do not convert implicitly to DateTimeOffset +dotnet_diagnostic.MA0132.severity = none + +# MA0133: Use DateTimeOffset instead of relying on the implicit conversion +dotnet_diagnostic.MA0133.severity = none + +# MA0134: Observe result of async calls +dotnet_diagnostic.MA0134.severity = none + +# MA0135: The log parameter has no configured type +dotnet_diagnostic.MA0135.severity = none + +# MA0136: Raw String contains an implicit end of line character +dotnet_diagnostic.MA0136.severity = none + +# MA0137: Use 'Async' suffix when a method returns an awaitable type +dotnet_diagnostic.MA0137.severity = none + +# MA0138: Do not use 'Async' suffix when a method does not return an awaitable type +dotnet_diagnostic.MA0138.severity = none + +# MA0139: Log parameter type is not valid +dotnet_diagnostic.MA0139.severity = none + +# MA0140: Both if and else branch have identical code +dotnet_diagnostic.MA0140.severity = none + +# MA0141: Use pattern matching instead of inequality operators for null check +dotnet_diagnostic.MA0141.severity = none + +# MA0142: Use pattern matching instead of equality operators for null check +dotnet_diagnostic.MA0142.severity = none + +# MA0143: Primary constructor parameters should be readonly +dotnet_diagnostic.MA0143.severity = none + +# MA0144: Use System.OperatingSystem to check the current OS +dotnet_diagnostic.MA0144.severity = none + +# MA0145: Signature for [UnsafeAccessorAttribute] method is not valid +dotnet_diagnostic.MA0145.severity = none + +# MA0146: Name must be set explicitly on local functions +dotnet_diagnostic.MA0146.severity = none + +# MA0147: Avoid async void method for delegate +dotnet_diagnostic.MA0147.severity = none + +# MA0148: Use pattern matching instead of equality operators for discrete value +dotnet_diagnostic.MA0148.severity = none + +# MA0149: Use pattern matching instead of inequality operators for discrete value +dotnet_diagnostic.MA0149.severity = none + +# MA0150: Do not call the default object.ToString explicitly +dotnet_diagnostic.MA0150.severity = none + +# MA0151: DebuggerDisplay must contain valid members +dotnet_diagnostic.MA0151.severity = none + +# MA0152: Use Unwrap instead of using await twice +dotnet_diagnostic.MA0152.severity = none + +# MA0153: Do not log symbols decorated with DataClassificationAttribute directly +dotnet_diagnostic.MA0153.severity = none + +# MA0154: Use langword in XML comment +dotnet_diagnostic.MA0154.severity = none + +# MA0155: Do not use async void methods +dotnet_diagnostic.MA0155.severity = none + +# MA0156: Use 'Async' suffix when a method returns IAsyncEnumerable +dotnet_diagnostic.MA0156.severity = none + +# MA0157: Do not use 'Async' suffix when a method does not return IAsyncEnumerable +dotnet_diagnostic.MA0157.severity = none + +# MA0158: Use System.Threading.Lock +dotnet_diagnostic.MA0158.severity = none + +# MA0159: Use 'Order' instead of 'OrderBy' +dotnet_diagnostic.MA0159.severity = none + +# MA0160: Use ContainsKey instead of TryGetValue +dotnet_diagnostic.MA0160.severity = none + +# MA0161: UseShellExecute must be explicitly set +dotnet_diagnostic.MA0161.severity = none + +# MA0162: Use Process.Start overload with ProcessStartInfo +dotnet_diagnostic.MA0162.severity = none + +# MA0163: UseShellExecute must be false when redirecting standard input or output +dotnet_diagnostic.MA0163.severity = none + +# MA0164: Use parentheses to make not pattern clearer +dotnet_diagnostic.MA0164.severity = none + +# MA0165: Make interpolated string +dotnet_diagnostic.MA0165.severity = none diff --git a/src/Meziantou.Analyzer.pack.csproj b/src/Meziantou.Analyzer.pack.csproj deleted file mode 100644 index 82290005b..000000000 --- a/src/Meziantou.Analyzer.pack.csproj +++ /dev/null @@ -1,38 +0,0 @@ - - - netstandard2.0 - false - false - false - true - true - - 2.0.0 - - Meziantou.Analyzer - A Roslyn analyzer to enforce some good practices in C# - Meziantou.Analyzer, analyzers - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file