Open sandboxFocus

Enum InitializerKind

Specifies the kind of initializer that should be added by an advice operation.

Namespace: Metalama.Framework.Advising
Assembly: Metalama.Framework.dll
Syntax
[CompileTime]
public enum InitializerKind
Remarks

This enumeration is used with methods like AddInitializer(IAdviser<INamedType>, IStatement, InitializerKind) to determine when and where initialization code should be injected into a type's constructors or initialization sequence.

Fields

Name Description
AfterLastInstanceConstructor

Indicates that the advice should run at the end of every instance constructor body, after all user constructor code. In an inheritance chain it runs only once, in the most-derived layer: base constructors skip the call so that derived state is fully assigned by the time the template executes. Constructors chained via : this(...) are skipped just like with BeforeInstanceConstructor.

AfterObjectInitializer

Indicates that the advice should inject statements into the Initialize(InitializationContext) method of IInitializable on the target type. If the type does not already implement IInitializable, the interface and a virtual Initialize(InitializationContext) method are introduced automatically. Metalama rewrites every instrumented new T(...), new T { ... }, and with { ... } call site to invoke Initialize(InitializationContext) after construction, so the template runs only once properties and fields have been assigned by the object initializer.

BeforeInstanceConstructor

Indicates that the advice should be executed before any user code in all instance constructors except those that are chained to a constructor of the current class (using the this chaining keyword). The initialization logic executes after the call to the base constructor.

BeforeTypeConstructor

Indicates that the advice should be executed before the type constructor (aka static constructor) of the target type. If there is no type constructor, this advice adds one.

See Also