Skip to content

Feat/component guard and generator throw rule - #42

Merged
kieronlanning merged 4 commits into
mainfrom
feat/component-guard-and-generator-throw-rule
Oct 22, 2026
Merged

kieronlanning merged 4 commits into
mainfrom
feat/component-guard-and-generator-throw-rule

Conversation

@kieronlanning

Copy link
Copy Markdown
Contributor

No description provided.

… diagnostic

An exception escaping a source generator is reported as CS8785 in every consuming build and IDE, and
the generator produces no output at all for that compilation, so the consumer also gets every "type or
namespace not found" error that follows, with a stack trace through code they do not own.

PSGFR44 flags a throw in code that runs during generation. ComponentGuard turns an escaping exception
into a diagnostic for every component kind the framework supports: Run reports where there is a
channel to report on (a generator, an analyzer), TryRun returns whether the body succeeded where there
is not (suppressors, code fixes, refactorings, which should simply do nothing). Cancellation is never
caught.

The reported diagnostic defaults entirely from the component, because it belongs to the consumer: the
id derives from the component namespace, the title from the component kind, the category from the root
namespace. Every part is overridable through GenerationSettings.FailureOptions.

Fixes two blind spots in PSGFR33: it matched banned types by exact display string, so INamedTypeSymbol
never matched ISymbol, and it only walked named model types, so a transform returning a symbol was
invisible. TypeLibraryModelLibrary no longer holds a symbol in a pipeline node, and three throw arms
in AttributeDataModelGenerator are gone.

RunIncremental now builds a fresh Compilation per run, matching what an IDE does; reusing one let a
symbol-holding stage report Cached on reference equality alone and hid the regression these tests
exist to catch.
@kieronlanning
kieronlanning merged commit 09c2699 into main Oct 22, 2026
1 check passed
@kieronlanning
kieronlanning deleted the feat/component-guard-and-generator-throw-rule branch October 22, 2026 11:36
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.

1 participant