ISyntaxReceiver Interface
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.
Receives notifications of each SyntaxNode in the compilation before generation runs
public interface ISyntaxReceiver
type ISyntaxReceiver = interface
Public Interface ISyntaxReceiver
Remarks
A ISourceGenerator can provide an instance of ISyntaxReceiver via a SyntaxReceiverCreator.
The compiler will invoke the SyntaxReceiverCreator prior to generation to obtain an instance of ISyntaxReceiver. This instance will have its OnVisitSyntaxNode(SyntaxNode) called for every syntax node in the compilation.
The ISyntaxReceiver can record any information about the nodes visited. During Execute(GeneratorExecutionContext) the generator can obtain the created instance via the SyntaxReceiver property. The information contained can be used to perform final generation.
A new instance of ISyntaxReceiver is created per-generation, meaning the instance is free to store state without worrying about lifetime or reuse.
An ISourceGenerator may provide only a single ISyntaxReceiver or ISyntaxContextReceiver, not both.
Methods
OnVisitSyntaxNode(SyntaxNode) |
Called for each SyntaxNode in the compilation |