Serializers, ORMs, DI containers, mappers, and rule engines all do the same trick under the hood: they write IL at runtime instead of calling your methods directly, because a generated, specialised method is far faster than reflection on every call. .NET gives you three main ways to do it — DynamicMethod + ILGenerator , TypeBuilder via Reflection.Emit , and Expression.Compile over LINQ expression trees. All three interact with obfuscation in a way the compiler cannot warn you about, because the breakage happens at runtime, in code that did not exist at build time. Here is the precise model of what is safe and what is not.
The key distinction: the generator ships, the generated code does not
Two different pieces of code are in play, and conflating them is where the confusion starts.
The generated code — the DynamicMethod body, the TypeBuilder type, the compiled expression delegate — is created in memory at runtime and never written to your assembly.…