Runtime Code Generation in .NET
-
C#: Loading Dynamic Assemblies Into Other AppDomains
Dynamic assemblies cannot simply be shared between AppDomains. What fails when you try, why it fails, and how to get generated code into another AppDomain anyway.
-
In-Memory Code Generation at Run-Time With .NET – Part 5 – Loading
Part 5: finding the generated types and creating instances of them, using Reflection, a dependency injection container, or the Managed Extensibility Framework.
-
Reflection Emit and Type Inheritance: Calling Base Type Constructors
With Reflection.Emit there is no C# compiler to insert the base constructor call for you. How to emit that call so a generated type can inherit a custom base class.
-
Reflection Emit: Creating Properties
Copy-paste Reflection.Emit code that adds a backing field, a getter and a setter to a type generated in memory.
-
Roslyn: Compile C# Expressions Without Using the Scripting API
Compiling small C# expressions with Roslyn without the scripting API, so you keep control over the resulting assembly and the AppDomain it is loaded into.
-
Fast Named Formats In C#
Format strings that reference object properties by name, such as My name is {Name}, with the emphasis on making the substitution fast rather than only correct.
-
Linq Expressions By Sample: Calling Generic Methods With Lambda Parameters For Unknown Types
Calling a generic method whose type arguments and delegate parameter are unknown at compile time, by building and compiling a Linq expression at run time.
-
Loading Assemblies In New AppDomain (And Unloading Them)
Loading assemblies into a separate AppDomain to inspect their types, and the small detail that quietly loads them into the main AppDomain and makes unloading impossible.
-
In-Memory Run-Time Code Generation With .NET – Part 2
Part 2: producing C# source at run time with templating engines. T4, StringTemplate and DotLiquid compared on the same generation task.
-
In-Memory Run-Time Code Generation With .NET – Part 3
Part 3: turning generated source into a usable assembly in memory, first with CodeDom and then with Roslyn, including references and compilation errors.
-
In-Memory Run-Time Code Generation With .NET – Part 4
Part 4: generating types straight from a model with no source code in between, using Reflection Emit to write MSIL and by compiling Linq expression trees.
-
In-Memory Run-Time Code Generation With .NET
Part 1 of a series on generating .NET types at run time: the general approach and the generation model that the templating, compilation and loading parts build on.