Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 14, 2026

The _LatestAnalysisLevel and _PreviewAnalysisLevel properties were not incremented for the .NET 11 SDK release (main branch), causing projects with AnalysisLevel=latest to incorrectly use .NET 9.0 analyzer rules instead of 11.0 rules.

Changes

  • Microsoft.NET.Sdk.Analyzers.targets: Incremented _LatestAnalysisLevel from 9.0 to 11.0 and _PreviewAnalysisLevel from 10.0 to 12.0
  • GivenThatWeWantToFloatWarningLevels.cs: Unskipped preview analysis level test and added test coverage for version 11.0

Impact

Projects targeting the main branch with <AnalysisLevel>latest</AnalysisLevel> will now correctly use analysislevel_11_default.globalconfig instead of analysislevel_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:

  • Use _LatestAnalysisLevel = 10.0 and _PreviewAnalysisLevel = 11.0
  • Include only the test cases for version 10.0
Original 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 AnalysisLevel to latest in a project, the 9.0 rules are being chosen instead of the 10.0 rules.

I believe the cause for this is that the _LatestAnalysisLevel property in Microsoft.NET.Sdk.Analyzers.targets was not incremented for the .NET 10 SDK.

_PreviewAnalysisLevel also 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

  1. Create a new console app targeting net10.0
  2. Add <AnalysisLevel>latest</AnalysisLevel> to the project file
  3. Build the project and create a binlog (dotnet build -bl)
  4. In the binlog, you can see that the _GlobalAnalyzerConfigFileName_MicrosoftCodeAnalysisNetAnalyzers property value is analysislevel_9_default.globalconfig instead of analysislevel_10_default.globalconfig

Exceptions (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

- The IDE (VS / VS Code/ VS4Mac) you're running on, and its version: Microsoft Visual Studio Professional January 2026 Feature Update 18.2.0

</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.

- Update _LatestAnalysisLevel from 9.0 to 10.0
- Update _PreviewAnalysisLevel from 10.0 to 11.0
- Unskip the preview analysis level test
- Add test cases for version 10.0

Co-authored-by: baronfel <[email protected]>
Copilot AI changed the title [WIP] Fix AnalysisLevel latest to use correct rules Increment AnalysisLevel properties for .NET 10 SDK Jan 14, 2026
Copilot AI requested a review from baronfel January 14, 2026 21:33
@baronfel
Copy link
Member

@copilot since this is targeting main the values will need to be 11.0 for current and 12.0 for preview - make sure to add new tests for those.

When we backport we'll need to take just the 10 tests and set the values to 10.0 for current, 11.0 for preview.

- Changed _LatestAnalysisLevel from 10.0 to 11.0
- Changed _PreviewAnalysisLevel from 11.0 to 12.0
- Added test cases for version 11.0

Note: The 11.0 tests will fail until the roslyn-analyzers package is updated with 11.0 globalconfig files, as documented in the test comments.

Co-authored-by: baronfel <[email protected]>
Copy link
Contributor Author

Copilot AI commented Jan 14, 2026

@copilot since this is targeting main the values will need to be 11.0 for current and 12.0 for preview - make sure to add new tests for those.

When we backport we'll need to take just the 10 test...

Updated in commit 88cd1a1:

  • _LatestAnalysisLevel changed to 11.0
  • _PreviewAnalysisLevel changed to 12.0
  • Added test cases for version 11.0

The 11.0 tests currently fail as expected (analysislevel_11_*.globalconfig files don't exist yet), which serves as a reminder to update the roslyn-analyzers package as documented in the test comments.

Copilot AI changed the title Increment AnalysisLevel properties for .NET 10 SDK Increment AnalysisLevel properties for .NET 11 SDK Jan 14, 2026
@baronfel
Copy link
Member

Tests are failing here now because the analyzer config generation pipeline is creating .NET 10/.NET 11-versioned analyzer rulesets and config file. This is because we never migrated the .Unshipped.md contents to the .Shipped.md files that are used by the generation config program as part of the repo build. In #52487 I'm trying to get this all fixed up for the 10.x servicing releases, but once that foundation comes in we should be able to easily update this PR to be green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AnalysisLevel latest not using the correct set of rules

2 participants