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
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應