Skip to content

Support analyzer property propagation - #31

Merged
andreasohlund merged 3 commits into
mainfrom
analyzer-props
Jun 8, 2026
Merged

Support analyzer property propagation#31
andreasohlund merged 3 commits into
mainfrom
analyzer-props

Conversation

@andreasohlund

Copy link
Copy Markdown
Member

Needed to test changes in Particular/NServiceBus.AzureFunctions#115

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 AnalyzerConfigOptionsFactory and use it to supply AnalyzerConfigOptionsProvider/AnalyzerOptions to analyzers and generator drivers.
  • Update source generator test execution to run analyzers with a configured options provider.
  • Add a new TestFlagAnalyzer + tests validating that build_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.

Comment thread src/Particular.AnalyzerTesting/SourceGeneratorTest.cs
Comment thread src/Particular.AnalyzerTesting/SourceGeneratorTest.cs
@andreasohlund
andreasohlund merged commit 1789fb5 into main Jun 8, 2026
5 checks passed
@andreasohlund
andreasohlund deleted the analyzer-props branch June 8, 2026 11:23
var result = SourceGeneratorTest.ForIncrementalGenerator<SimpleSourceGenerator>()
.WithAnalyzer<TestFlagAnalyzer>()
.WithProperty("build_property.TestFlag", "enabled")
.SuppressCompilationErrors()

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.

Is this suppress needed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes see #31 (review)

I have confirmed that its still needed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants