✅ Source Generator, dynamic assembly not added.
I have the following code:
When trying to compile a project that references the source generator, I get a
CS0103
, saying "The name 'MyType' does not exist in the current context".
Any ideas on how to fix?8 Replies
Actually, let me try to explain what I'm trying to do with that code:
I want to directly add IL to a project using source-generators.
This can allow me to get around some restrictions using C# strings with
AddSource
gives me.You can't directly add IL, you can only add strings or parse trees.
If there are restrictions then those restrictions are likely purposeful.
Well, what I'm trying to do in the IL code is access a field I normally don't have access to, as a sort of alternative to reflection but faster
Firstly I don't think the runtime would allow you to do that
fun fact: it does
huh, neat
Secondly go ask in #roslyn
I have it working as just calling a method that builds it at runtime, but I'd prefer to use a source-generator so that the method building is done at compile time (for performance reasons)
Well, the code source generators generate have all the same restrictions as regular C# code