Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 30, 2025

Fixes #27744

Summary

This PR adds documentation on how to configure code analyzers when using the Microsoft.CodeAnalysis.NetAnalyzers NuGet package in legacy (non-SDK-style) .NET Framework projects.

Problem

The existing documentation mentions that MSBuild properties like AnalysisMode and AnalysisLevel only work with SDK-style projects starting with .NET 5, and suggests using the Microsoft.CodeAnalysis.NetAnalyzers NuGet package for legacy projects. However, it doesn't explain how to configure the analyzers when using the NuGet package, leaving users without guidance on how to enable additional analyzers or adjust rule severity.

Solution

Added a new section "Configure analyzers in legacy projects" to docs/fundamentals/code-analysis/overview.md that documents three configuration methods available for legacy projects:

  1. EditorConfig files: The primary method for configuring rule severity and options. Includes examples showing how to:

    • Configure individual rule severity
    • Enable all rules in a specific category (e.g., Security)
  2. Predefined configurations: Explains how to use the pre-packaged EditorConfig and ruleset files included in the NuGet package, which are located in the editorconfig and rulesets subdirectories after installation.

  3. Ruleset files: Documents this deprecated-but-still-supported method with appropriate deprecation notice, showing how to create and reference ruleset files in the project file.

The new section clearly explains that MSBuild properties like AnalysisMode and AnalysisLevel don't work for projects that don't reference a project SDK, and provides actionable alternatives with concrete examples.

Related Links

Original prompt

This section details on the original issue you should resolve

<issue_title>Document how to configure code analyzers in legacy projects</issue_title>
<issue_description>### Type of issue

Missing information

Description

This article often mentions that configuration settings only work with SDK projects starting with .NET 5. It also mentions that you have to use the Microsoft.CodeAnalysis.NetAnalyzers NuGet package for legacy (non-SDK) .NET Framework projects. But there is no documentation on how to configure the analyzers when you use the NuGet package. For example how to enable additional analyzers.

See also dotnet/roslyn-analyzers#4776 (comment)

Page URL

https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/overview?tabs=net-9

Content source URL

https://github.com/dotnet/docs/blob/main/docs/fundamentals/code-analysis/overview.md

Document Version Independent Id

128f9903-971d-6a66-a2cb-9b12acbc55e7

Platform Id

6c404312-136c-21aa-d92a-1cb8ea7ecdcf

Article author

@gewarren

Metadata

  • ID: f8906b2c-b984-0427-d064-829e7ea2fc55
  • PlatformId: 6c404312-136c-21aa-d92a-1cb8ea7ecdcf
  • Service: dotnet-fundamentals

Related Issues


Associated WorkItem - 486224</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #45182

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] Document how to configure code analyzers in legacy projects Document how to configure code analyzers in legacy projects Sep 30, 2025
@Copilot Copilot AI requested a review from gewarren September 30, 2025 23:48
Copilot finished work on behalf of gewarren September 30, 2025 23:48
@gewarren gewarren closed this Sep 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

2 participants