Increment AnalysisLevel properties for .NET 11 SDK #52468
Draft
+11
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
_LatestAnalysisLeveland_PreviewAnalysisLevelproperties were not incremented for the .NET 11 SDK release (main branch), causing projects withAnalysisLevel=latestto incorrectly use .NET 9.0 analyzer rules instead of 11.0 rules.Changes
_LatestAnalysisLevelfrom9.0to11.0and_PreviewAnalysisLevelfrom10.0to12.0Impact
Projects targeting the main branch with
<AnalysisLevel>latest</AnalysisLevel>will now correctly useanalysislevel_11_default.globalconfiginstead ofanalysislevel_9_default.globalconfig.Notes
The 11.0 tests will fail until the roslyn-analyzers package is updated with 11.0 globalconfig files. This is intentional and serves as a regression test to ensure analyzer packages are kept in sync with SDK version bumps.
When backporting to release/10.0.1xx and release/10.0.2xx branches:
_LatestAnalysisLevel=10.0and_PreviewAnalysisLevel=11.0Original prompt
This section details on the original issue you should resolve
<issue_title>AnalysisLevel latest not using the correct set of rules</issue_title>
<issue_description><!--
Please keep in mind that the GitHub issue tracker is not intended as a general support forum, but for reporting non-security bugs and feature requests.
If you believe you have an issue that affects the SECURITY of the platform, please do NOT create an issue and instead email your issue details to [email protected]. Your report may be eligible for our bug bounty but ONLY if it is reported through email.
For other types of questions, consider using StackOverflow.
-->
Describe the bug
When setting
AnalysisLeveltolatestin a project, the 9.0 rules are being chosen instead of the 10.0 rules.I believe the cause for this is that the
_LatestAnalysisLevelproperty inMicrosoft.NET.Sdk.Analyzers.targetswas not incremented for the .NET 10 SDK._PreviewAnalysisLevelalso looks to be incorrect.I can see that there are tests related to checking these properties, but based on the comments I can see on those tests, it looks like they weren't updated either.
To Reproduce
net10.0<AnalysisLevel>latest</AnalysisLevel>to the project filedotnet build -bl)_GlobalAnalyzerConfigFileName_MicrosoftCodeAnalysisNetAnalyzersproperty value isanalysislevel_9_default.globalconfiginstead ofanalysislevel_10_default.globalconfigExceptions (if any)
N/A
Further technical details
details of dotnet --info
.NET SDK: Version: 10.0.102 Commit: 4452502459 Workload version: 10.0.100-manifests.6d969a7e MSBuild version: 18.0.7+445250245
Runtime Environment:
OS Name: Windows
OS Version: 10.0.26200
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\10.0.102\
.NET workloads installed:
There are no installed workloads to display.
Configured to use workload sets when installing new manifests.
No workload sets are installed. Run "dotnet workload restore" to install a workload set.
Host:
Version: 10.0.2
Architecture: x64
Commit: 4452502459
.NET SDKs installed:
9.0.306 [C:\Program Files\dotnet\sdk]
10.0.102 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 10.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.23 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 10.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 8.0.21 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.23 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 10.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
</issue_description>
Comments on the Issue (you are @copilot in this section)
@baronfel Good analysis (heh).Well want to fix it and backport it to 100 and 200 servicing releases. <...
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.