✅ Source Generator, dynamic assembly not added.

I have the following code:
            var assemblyName = new AssemblyName("MyAssembly");
            var assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run);
            var moduleBuilder = assemblyBuilder.DefineDynamicModule("MyModule");

            var typeBuilder = moduleBuilder.DefineType("MyNamespace.MyType", TypeAttributes.Public);
            var methodBuilder = typeBuilder.DefineMethod("MyMethod", MethodAttributes.Public | MethodAttributes.Static);
            var ilGenerator = methodBuilder.GetILGenerator();

            // Generate some IL code
            ilGenerator.Emit(OpCodes.Ldstr, "Hello, world!");
            ilGenerator.Emit(OpCodes.Call, typeof(Console).GetMethod("WriteLine", new[] { typeof(string) }));

            var sourceText = "namespace MyNamespace { public static class MyClass { public static void MyMethod() { MyType.MyMethod(); } } }";
            context.AddSource("MyFile.cs", sourceText);

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?
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