feat(pipeline): RegisterCollectedEmitter + IsTypeAccessible + IsToggleEnabled - #91
Conversation
…oggleEnabled
Promotes three patterns observed across consuming generator codebases
(qyl, MAF, LoggerMessageNPlus2) into shared, by-the-book helpers:
- IncrementalValuesProviderExtensions.RegisterCollectedEmitter<T> — the
canonical "collect → gate → exception-safe emit → AddSource" pipeline,
with a FileWithName overload and a (filename, string emitter) overload.
- CompilationExtensions.IsTypeAccessible — projects an
IncrementalValueProvider<Compilation> to a value-equatable bool in one
call. Avoids the textbook anti-pattern of combining the non-equatable
Compilation directly into a downstream stage, which thrashes the
generator cache on every keystroke.
- AnalyzerConfigOptionsProviderExtensions.IsToggleEnabled — same shape
for an MSBuild boolean toggle, with a defaultValue (defaults to true).
Together these collapse the typical per-concern generator boilerplate
("dual gate + collect + emit") to a single declarative line.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
Cache: Disabled due to data retention organization setting Knowledge base: Disabled due to data retention organization setting Summary by CodeRabbit
WalkthroughThree extension methods added to support incremental generator pipelines: ChangesIncremental Generator Helper Extensions
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Review rate limit: 4/5 reviews remaining, refill in 12 minutes. Comment |
There was a problem hiding this comment.
Pull request overview
This PR promotes common incremental-generator pipeline patterns into shared helpers in ANcpLua.Roslyn.Utilities, reducing repeated boilerplate in consuming generators while preserving incremental caching behavior (projecting non-equatable Roslyn inputs into value-equatable boolean “gates”, and standardizing a collect+gate+emit pipeline).
Changes:
- Add
IncrementalValuesProviderExtensions.RegisterCollectedEmitter<T>overloads to standardize “collect → gate → exception-safe emit → AddSource” for single-file generation. - Add
CompilationExtensions.IsTypeAccessibleto projectCompilationProviderinto a value-equatable boolean gate based on accessible type presence. - Add
AnalyzerConfigOptionsProviderExtensions.IsToggleEnabledto project config options into a value-equatable boolean gate based on an MSBuild boolean property with a default.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/ANcpLua.Roslyn.Utilities/IncrementalValuesProviderExtensions.cs | Adds RegisterCollectedEmitter<T> helpers composing existing pipeline primitives (collect/combine/exception reporting/add-source). |
| src/ANcpLua.Roslyn.Utilities/CompilationExtensions.cs | Adds IsTypeAccessible to convert CompilationProvider into a boolean gate using existing accessibility checks. |
| src/ANcpLua.Roslyn.Utilities/AnalyzerConfigOptionsProviderExtensions.cs | Adds IsToggleEnabled to convert AnalyzerConfigOptionsProvider into a boolean gate using existing MSBuild boolean parsing helpers. |
Summary
Promotes three patterns observed across consuming generator codebases (qyl, MAF agent-framework, LoggerMessageNPlus2) into shared by-the-book helpers, collapsing typical per-concern generator boilerplate to a single declarative line.
IncrementalValuesProviderExtensions.RegisterCollectedEmitter<T>— canonical "collect → gate → exception-safe emit → AddSource" pipeline, with aFileWithNameoverload and a(filename, string emitter)overload.CompilationExtensions.IsTypeAccessible— projectsIncrementalValueProvider<Compilation>to a value-equatableboolin one call. Avoids the textbook anti-pattern of combining the non-equatableCompilationdirectly into a downstream stage (which thrashes the generator cache on every keystroke).AnalyzerConfigOptionsProviderExtensions.IsToggleEnabled— same shape for an MSBuild boolean toggle, withdefaultValuedefaulting totrue.Why
Three independent generator codebases reinvented the same dual-gate + collect + emit boilerplate locally. Surfacing it once in
Roslyn.Utilitieslets each per-concern generator become a thin declaration of inputs/gates/outputs:Test plan
dotnet buildclean (zero warnings,TreatWarningsAsErrorsenforces cref regression — noCS0419)Testing.Tests23/23 passCollectAsEquatableArray,Combine,SelectAndReportExceptions,AddSource,HasAccessibleTypeWithMetadataName,GetGlobalBoolOrDefault)🤖 Generated with Claude Code