question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using CodeDom in Source Generators

See original GitHub issue

I’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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

5reactions
sharwellcommented, Oct 6, 2020

Words cannot describe how sad I will be if we create Source Generators only to find they are used to resurrect CodeDom. 😭

2reactions
Vake93commented, Oct 7, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Codedom and SourceGenerator
I am trying to build a SourceGenerator which should utilize Sytem.Codedom. My project File looks like this: <Project Sdk="Microsoft.NET.
Read more >
Generating and Compiling Source Code from a CodeDOM ...
Generate and compile source code from a CodeDOM graph in .NET. Use a CodeDOM code provider to generate source code and compile assemblies....
Read more >
Writing Code Generators with the CodeDOM - Part 2
The first part of this article introduced the macro steps involved in creating a code generator with Microsoft's .NET CodeDOM.
Read more >
Powerful Code Generation Techniques
You can use the CodeDOM or you can use some sort of text templating system, depending on how you want to go about...
Read more >
How to generate code using Roslyn source ...
In this blog post I'll outline how I'm using it, in light of my first real-world use case: ... How to use Scriban...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found