Using CodeDom in Source Generators
See original GitHub issueI’m not sure if this is the correct place to create issues with regards to C# source generators.
I’m using dotnet version: 3.1.402
I’m trying out source generators and if I reference System.CodeDom and use it in the code generator it fails. Normally I can attach a debugger to the code generator by Debugger.Launch(), but if I’m using System.CodeDom the Debugger.Launch() wont be execute either so I really dont know whats happening there.
I’ve create a simple solution with 2 projects, which one is a source generator(Test.SourceGenerator).
In Test.SourceGenerator project if you remove line
var codeCompileUnit = new CodeCompileUnit();
the source generator works fine and the Test.Consumer project builds.
Does source generators have restrictions on using nuget packages?
You can find the solution in the Test.zip file Test.zip
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:13 (8 by maintainers)
Words cannot describe how sad I will be if we create Source Generators only to find they are used to resurrect CodeDom. 😭
That wasn’t my intention, sorry. 😅 Source generators are awesome new tool but I think there has to be a better way to build the generated source other than using string builder and string concatenation.