GeneratorInitializationContext.RegisterForPostInitialization Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Register a callback that is invoked after initialization.
public void RegisterForPostInitialization (Action<Microsoft.CodeAnalysis.GeneratorPostInitializationContext> callback);
member this.RegisterForPostInitialization : Action<Microsoft.CodeAnalysis.GeneratorPostInitializationContext> -> unit
Public Sub RegisterForPostInitialization (callback As Action(Of GeneratorPostInitializationContext))
Parameters
- callback
- Action<GeneratorPostInitializationContext>
An Action<T> that accepts a GeneratorPostInitializationContext that will be invoked after initialization.
Remarks
This method allows a generator to opt-in to an extra phase in the generator lifecycle called PostInitialization. After being initialized any generators that have opted in will have their provided callback invoked with a GeneratorPostInitializationContext instance that can be used to alter the compilation that is provided to subsequent generator phases.
For example a generator may choose to add sources during PostInitialization. These will be added to the compilation before execution and will be visited by a registered ISyntaxReceiver and available for semantic analysis as part of the Compilation
Note that any sources added during PostInitialization will be visible to the later phases of other generators operating on the compilation.
Applies to
.NET