Skip to main content

Practice ยท 2 of 2

Verify the pipeline compiles

CHALLENGE
Difficulty: advanced+25 XP

Implement static bool GeneratedCatalogCompiles(string userSource): build a generator pipeline where a Gen2Attribute (emitted by the generator itself via RegisterPostInitializationOutput, AttributeTargets.Class) marks classes, and a generated static class GenCatalog2 exposes one method per marked class. Return true only when the OUTPUT compilation โ€” user code AND generated code โ€” has zero error diagnostics. The test proves the output check matters: a user class named GenCatalog2 collides with the generated type and must yield false.

Back to lesson: Practice: Generator drills