-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Increment AnalysisLevel properties for .NET 11 SDK #52468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- 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 <573979+baronfel@users.noreply.github.com>
|
@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 <573979+baronfel@users.noreply.github.com>
Updated in commit 88cd1a1:
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. |
|
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 |
|
@baronfel I think this looks good now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR increments the _LatestAnalysisLevel and _PreviewAnalysisLevel properties in the .NET 11 SDK to fix a bug where projects using AnalysisLevel=latest were incorrectly using .NET 9.0 analyzer rules instead of .NET 11.0 rules. The main branch represents .NET 11 SDK, and these properties need to be updated when the target framework version advances.
Changes:
- Incremented
_LatestAnalysisLevelfrom 10.0 to 11.0 and_PreviewAnalysisLevelfrom 11.0 to 12.0 in Microsoft.NET.Sdk.Analyzers.targets - Added test coverage for AnalysisLevel version 11.0 following the established test pattern
- Added informational comments about the relationship between property bumps and test requirements
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.Analyzers.targets | Updated _LatestAnalysisLevel to 11.0 and _PreviewAnalysisLevel to 12.0 to align with .NET 11 SDK |
| test/Microsoft.NET.Build.Tests/GivenThatWeWantToFloatWarningLevels.cs | Added 4 test cases for version 11.0 and clarifying comments about property bump requirements |
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 secure@microsoft.com. 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.