diff --git a/src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.NetAnalyzers/AnalyzerReleases.Shipped.md b/src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.NetAnalyzers/AnalyzerReleases.Shipped.md index 4e76ada6af3e..d13ae5e93b8e 100644 --- a/src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.NetAnalyzers/AnalyzerReleases.Shipped.md +++ b/src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.NetAnalyzers/AnalyzerReleases.Shipped.md @@ -362,3 +362,16 @@ CA2262 | Usage | Info | ProvideHttpClientHandlerMaxResponseHeaderLengthValueCorr CA2263 | Usage | Info | PreferGenericOverloadsAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2263) CA2264 | Usage | Warning | DoNotPassNonNullableValueToArgumentNullExceptionThrowIfNull, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2264) CA2265 | Usage | Warning | DoNotCompareSpanToNullAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2265) + +## Release 10.0 + +### New Rules + +Rule ID | Category | Severity | Notes +--------|----------|----------|------- +CA1873 | Performance | Info | AvoidPotentiallyExpensiveCallWhenLoggingAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1873) +CA1874 | Performance | Info | UseRegexMembers, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1874) +CA1875 | Performance | Info | UseRegexMembers, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1875) +CA2023 | Reliability | Warning | LoggerMessageDefineAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2023) +CA2024 | Reliability | Warning | DoNotUseEndOfStreamInAsyncMethods, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2024) +CA2025 | Reliability | Disabled | DoNotPassDisposablesIntoUnawaitedTasksAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2025) diff --git a/src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.NetAnalyzers/AnalyzerReleases.Unshipped.md b/src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.NetAnalyzers/AnalyzerReleases.Unshipped.md index 0ecf6597797e..cdf4f1397e0b 100644 --- a/src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.NetAnalyzers/AnalyzerReleases.Unshipped.md +++ b/src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.NetAnalyzers/AnalyzerReleases.Unshipped.md @@ -1,12 +1 @@ ; Please do not edit this file manually, it should only be updated through code fix application. - -### New Rules - -Rule ID | Category | Severity | Notes ---------|----------|----------|------- -CA1873 | Performance | Info | AvoidPotentiallyExpensiveCallWhenLoggingAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1873) -CA1874 | Performance | Info | UseRegexMembers, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1874) -CA1875 | Performance | Info | UseRegexMembers, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1875) -CA2023 | Reliability | Warning | LoggerMessageDefineAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2023) -CA2024 | Reliability | Warning | DoNotUseEndOfStreamInAsyncMethods, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2024) -CA2025 | Reliability | Disabled | DoNotPassDisposablesIntoUnawaitedTasksAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2025) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.Analyzers.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.Analyzers.targets index bfe44a366470..0c206deb1e52 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.Analyzers.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.Analyzers.targets @@ -22,8 +22,8 @@ Copyright (c) .NET Foundation. All rights reserved. <_NoneAnalysisLevel>4.0 - <_LatestAnalysisLevel>9.0 - <_PreviewAnalysisLevel>10.0 + <_LatestAnalysisLevel>10.0 + <_PreviewAnalysisLevel>11.0 Path.GetFileName(file).Equals(expectedGlobalConfig, StringComparison.OrdinalIgnoreCase)); + matchingConfigs.Should().ContainSingle( + $""" + Expected to find globalconfig '{expectedGlobalConfig}' for AnalysisLevel=latest. + + To fix this test failure: + (1) Update the AnalyzerReleases files: + - Edit 'src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.NetAnalyzers/AnalyzerReleases.Shipped.md' + to create a new release section for the prior analysis level version (e.g., '## Release 10.0'). + - Move all entries from 'AnalyzerReleases.Unshipped.md' to the new release section. + - Repeat for C#/VB.NET specific files if they have unshipped entries. + (2) Update _LatestAnalysisLevel and _PreviewAnalysisLevel in + 'src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.Analyzers.targets'. + (3) Rebuild the SDK to regenerate the globalconfig files. + """); + + var globalConfigPath = matchingConfigs.Single(); + File.Exists(globalConfigPath).Should().BeTrue( + $"The globalconfig file '{expectedGlobalConfig}' should exist on disk."); + } + [InlineData("preview")] [InlineData("latest")] [InlineData("none")] @@ -277,23 +357,22 @@ static void Main() [InlineData("9.0", "", "true", "")] [InlineData("9", "default", "false", "Security")] [InlineData("9.0", "", "true", "Usage")] + [InlineData("10", "default", "false", "")] + [InlineData("10.0", "", "true", "")] + [InlineData("10", "default", "false", "Security")] + [InlineData("10.0", "", "true", "Usage")] [RequiresMSBuildVersionTheory("16.8")] public void It_maps_analysis_properties_to_globalconfig(string analysisLevel, string analysisMode, string codeAnalysisTreatWarningsAsErrors, string category) { // Documentation: https://learn.microsoft.com/dotnet/core/project-sdk/msbuild-props#code-analysis-properties - + // // NOTE: This test will fail for "latest" analysisLevel when the "_LatestAnalysisLevel" property - // is bumped in Microsoft.NET.Sdk.Analyzers.targets without a corresponding change in dotnet/roslyn-analyzers - // repo that generates and maps to the globalconfig. This is an important regression test to ensure the + // is bumped in Microsoft.NET.Sdk.Analyzers.targets without a corresponding change in the the analyzers + // source in this repo that generates and maps to the globalconfig. This is an important regression test to ensure the // "latest" analysisLevel setting keeps working as expected when moving to a newer version of the .NET SDK. - // Following changes are needed to ensure the failing test scenario passes again: - // 1. In dotnet/roslyn-analyzers repo: - // a. Update "src/NetAnalyzers/Core/AnalyzerReleases.Shipped.md"to create a new release - // for the prior "_LatestAnalysisLevel" value and move all the entries from - // "src/NetAnalyzers/Core/AnalyzerReleases.Unshipped.md" to the shipped file. - // For example, see https://github.com/dotnet/roslyn-analyzers/pull/6246. - // 2. In dotnet/sdk repo: - // a. Consume the new Microsoft.CodeAnalysis.NetAnalyzers package with the above sha. + // + // See the It_has_globalconfig_for_latest_analysis_level test for more explicit validation and detailed + // instructions on what changes are needed when bumping to a new TFM. var testProject = new TestProject {