Support analyzer property propagation - #31
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds support in the Particular.AnalyzerTesting harness for propagating build/analyzer config properties into analyzer execution (including during source-generator runs), enabling tests for upstream changes (Particular/NServiceBus.AzureFunctions#115).
Changes:
- Introduce
AnalyzerConfigOptionsFactoryand use it to supplyAnalyzerConfigOptionsProvider/AnalyzerOptionsto analyzers and generator drivers. - Update source generator test execution to run analyzers with a configured options provider.
- Add a new
TestFlagAnalyzer+ tests validating thatbuild_property.*values are visible to analyzers.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/Tests/SourceGenerators/BasicSourceGeneratorTest.cs | Reuses a shared source string and adds a regression test ensuring analyzers see build properties during generator runs. |
| src/Tests/Analyzers/TestFlagAnalyzerTests.cs | New analyzer test verifying property-driven diagnostics. |
| src/Particular.AnalyzerTesting/SourceGeneratorTest.cs | Switches to shared analyzer-config options provider creation for generator runs. |
| src/Particular.AnalyzerTesting/SourceGeneratorBuild.cs | Passes an options provider into analyzer execution via CompilationWithAnalyzersOptions. |
| src/Particular.AnalyzerTesting/CompilationExtensions.cs | Ensures analyzer runs receive analyzer options created from the test’s properties. |
| src/Particular.AnalyzerTesting/BaseAnalyzerTest.cs | Threads properties through to analyzer diagnostic collection. |
| src/Particular.AnalyzerTesting/AnalyzerConfigOptionsFactory.cs | New helper for building AnalyzerConfigOptionsProvider and AnalyzerOptions from a property dictionary. |
| src/FakeAnalyzers/TestFlagAnalyzer.cs | New analyzer that reads build_property.TestFlag from global analyzer config options. |
| src/FakeAnalyzers/DiagnosticIds.cs | Adds FAKE0004 id. |
| src/FakeAnalyzers/DiagnosticDescriptors.cs | Adds descriptor for the new test analyzer diagnostic. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
DavidBoike
approved these changes
Jun 4, 2026
| var result = SourceGeneratorTest.ForIncrementalGenerator<SimpleSourceGenerator>() | ||
| .WithAnalyzer<TestFlagAnalyzer>() | ||
| .WithProperty("build_property.TestFlag", "enabled") | ||
| .SuppressCompilationErrors() |
Contributor
There was a problem hiding this comment.
Is this suppress needed?
Member
Author
There was a problem hiding this comment.
Yes see #31 (review)
I have confirmed that its still needed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Needed to test changes in Particular/NServiceBus.AzureFunctions#115