Skip to main content

Source generator checkpoint

Challenge on lesson: Checkpoint: source generators

CHALLENGE
Difficulty: advanced+25 XP

Implement static (int trees, bool symbolResolved) RunGenerator(string userSource): build a generator that reads classes marked [Gen] (an attribute the generator itself creates via RegisterPostInitializationOutput) and emits a static class GenCatalog with one method per marked class: public static string Name_X() => "X";. Parse userSource, add the attribute source, run CSharpGeneratorDriver, and return (generated tree count including the init output, whether symbol GenCatalog resolves in the output compilation).

Back to lesson: Checkpoint: source generators