Skip to content

<AnalysisLevel>latest-all</AnalysisLevel> seems to be not effective when switching to .NET7 #65630

@moses70

Description

@moses70

Version Used:
SDK 7.0.100 with Visual studio 17.4.1

Steps to Reproduce:

  1. Install .NET6 SDK and .NET 7 SDK in parallel (latest versions)
  2. Create a C# project with a global.json selecting .NET6
  3. Use <AnalysisLevel>latest-all</AnalysisLevel> in csproj
  4. Using some example code, targeting .NET48 with <EnableNETAnalyzers>true</EnableNETAnalyzers>
  5. Verify the number of code analysis warnings. E.g. 97 warnings
  6. Switch to .NET7 using global.json, rebuild
  7. The number of code analysis warnings decreases to about the same number as with <AnalysisLevel>latest-recommended</AnalysisLevel>

Diagnostic Id:

For example, CA2007 should be enabled in "latest-all", but is not in .NET7

Expected Behavior:
In .NET7, at least the same number of code style warnings should be visible as in .NET 6.

Actual Behavior:
latest-all has not the same effect in .NET 7

Workaround
With this global.json, I can still use C#11 features (with VS17.4) and all analyzers are working:
{
"sdk": {
"allowPrerelease": false,
"version": "6.0.0",
"rollForward": "latestMinor"
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-AnalyzersuntriagedIssues and PRs which have not yet been triaged by a lead

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions