ISyntaxReceiver Interface

Definition

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

Applies to