Skip to content

Add support for virtual relative AnalyzerConfig properties - #86645

Draft
jjonescz wants to merge 1 commit into
dotnet:mainfrom
jjonescz:86593-AnalyzerConfig-VirtualProjectDir
Draft

jjonescz wants to merge 1 commit into
dotnet:mainfrom
jjonescz:86593-AnalyzerConfig-VirtualProjectDir

Conversation

@jjonescz

@jjonescz jjonescz commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Part of #86593.

Microsoft Reviewers: Open in CodeFlow

@jjonescz
jjonescz requested review from chsienki and a balanced review from Copilot November 27, 2026 20:50
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟑 Changes recommended

The analyzer-config documentation overstates precedence and resolution guarantees by omitting same-section restrictions, cross-file global_level rules, and the requirement to place directives before section headers.

1 open issue
What changed in this PR

This PR adds config-relative build properties to Roslyn’s global analyzer configs, supporting location-independent configuration for build caching as described in #86593.

Changes:

  • Resolve config_relative_build_property.* directives into build_property.* options before merging global configs.
  • Preserve empty values and trailing separators, with explicit same-section values taking precedence.
  • Add compiler, command-line generator, and workspace tests, plus usage documentation.
File Description
src/​Workspaces/​CoreTest/​SolutionTests/​SolutionTests.cs Tests resolution relative to the config location across project and config moves.
src/​Compilers/​CSharp/​Test/​CommandLine/​CommandLineTests.cs Verifies resolved properties reach source generators.
src/​Compilers/​Core/​Portable/​CommandLine/​AnalyzerConfigSet.cs Resolves relative property directives before global merging.
src/​Compilers/​Core/​Portable/​CommandLine/​AnalyzerConfig.cs Defines the config-relative property prefix.
src/​Compilers/​Core/​CodeAnalysisTest/​Analyzers/​AnalyzerConfigTests.cs Tests resolution, precedence, conflicts, and path edge cases.
docs/​compilers/​analyzer-config.md Documents directive syntax and behavior.

Review effort: Balanced

Comment on lines +47 to +48
Explicit `build_property` values override config-relative values.
The `config_relative_build_property` directives themselves are not exposed to analyzers.

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants