4 ms·
C# source generators are...just macros?
by CharlieDigital 1y ago
C# source generators are...just macros?
- skydhash 1y agoThey are not. They are generators. Macros tends to be local and explicit as the other commenters have said. They are more like templates. Generators can be fairly involved and feels like a mini language, one that is not as observable as macros.
- CharlieDigital 1y agoIsn't this just a string template? https://github.com/CharlieDigital/SKPromptGenerator/blob/main/generator/PromptGenerator.cs#L76-L112 https://github.com/CharlieDigital/SKPromptGenerator/blob/mai... Maybe you're confusing `System.Reflection.Emit` and source generators? Source generators are just a source tree walker + string templates to write source files.
- mexicocitinluez 1y ago> Generators can be fairly involved and feels like a mini language, one that is not as observable as macros. I agree the syntax is awkward, but all it boils down to is concatenating code in strings and adding it as a file to your codebase. And the syntax will 100% get cleaner (it;s already happening with stuff like ForAttributeWithMetadataName