Code Generation
Allows meta-programming-like experience to reduce repetitive code.
app.Layers.AddCodeGeneration();
Configuration Targets
Code generation layer provides IGeneratedAssemblyCollection
as the only
configuration target.
IGeneratedAssemblyCollection
This target is provided in GenerateCode
phase. To configure it in a feature;
configurator.ConfigureGeneratedAssemblyCollection(assemblies =>
{
...
});
Phases
This layer introduces following phases to the application it is added;
GenerateCode
: This phase creates aIGeneratedAssemblyCollection
instance and places it in the application contextCompile
: This phase compiles generated code during above phase, and places all generated assemblies intoGeneratedAssemblyProvider
, which is added to the application context
To access to a generated assembly from a feature use
configurator.Context.GetGeneratedAssembly("MyAssembly")
extension method.