CompilationUnitSyntax Class

Definition

Represents an entire source file of VB code.

public ref class CompilationUnitSyntax sealed : Microsoft::CodeAnalysis::VisualBasic::VisualBasicSyntaxNode, Microsoft::CodeAnalysis::ICompilationUnitSyntax
public sealed class CompilationUnitSyntax : Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxNode, Microsoft.CodeAnalysis.ICompilationUnitSyntax
type CompilationUnitSyntax = class
    inherit VisualBasicSyntaxNode
    interface ICompilationUnitSyntax
Public NotInheritable Class CompilationUnitSyntax
Inherits VisualBasicSyntaxNode
Implements ICompilationUnitSyntax
Inheritance
CompilationUnitSyntax
Implements

Remarks

This node is associated with the following syntax kinds:

Properties

Attributes

Represents the list of AttributeStatements at the beginning of a source file that contain the Assembly and Module attributes.

ContainsAnnotations

Determines whether this node or any sub node, token or trivia has annotations.

(Inherited from SyntaxNode)
ContainsDiagnostics

Determines whether this node or any of its descendant nodes, tokens or trivia have any diagnostics on them.

(Inherited from SyntaxNode)
ContainsDirectives

Determines whether this node has any descendant preprocessor directives.

(Inherited from SyntaxNode)
ContainsSkippedText

Determines whether this node has any descendant skipped text.

(Inherited from SyntaxNode)
EndOfFileToken

Represents the end of the source file. This token may have trivia (whitespace, comments, ...) attached to it.

FullSpan

The absolute span of this node in characters, including its leading and trailing trivia.

(Inherited from SyntaxNode)
HasLeadingTrivia

Determines whether this node has any leading trivia.

(Inherited from SyntaxNode)
HasStructuredTrivia

Determines whether a descendant trivia of this node is structured.

(Inherited from SyntaxNode)
HasTrailingTrivia

Determines whether this node has any trailing trivia.

(Inherited from SyntaxNode)
Imports

Represents the list of Imports statements at the beginning of a source file.

IsDirective

Returns True if this node represents a directive.

(Inherited from VisualBasicSyntaxNode)
IsMissing

Determines whether the node represents a language construct that was actually parsed from the source code. Missing nodes are generated by the parser in error scenarios to represent constructs that should have been present in the source code in order to compile successfully but were actually missing.

(Inherited from SyntaxNode)
IsStructuredTrivia

Determines whether this node represents a structured trivia.

(Inherited from SyntaxNode)
KindText (Inherited from SyntaxNode)
Language

The language name this node is syntax of.

(Inherited from VisualBasicSyntaxNode)
Members

Represents the members of the default namespace for this source file: all the top-level type and namespace declarations in the file. May also contain Statements that are not valid

Options

Represents the list of Option statements at the beginning of a source file.

Parent

The node that contains this node in its ChildNodes() collection.

(Inherited from SyntaxNode)
ParentTrivia (Inherited from SyntaxNode)
RawKind

An integer representing the language specific kind of this node.

(Inherited from SyntaxNode)
Span

The absolute span of this node in characters, not including its leading and trailing trivia.

(Inherited from SyntaxNode)
SpanStart

Same as accessing Start on Span.

(Inherited from VisualBasicSyntaxNode)
SyntaxTree

Returns SyntaxTree that owns the node.

(Inherited from SyntaxNode)
SyntaxTreeCore (Inherited from VisualBasicSyntaxNode)

Methods

Accept(VisualBasicSyntaxVisitor)
Accept<TResult>(VisualBasicSyntaxVisitor<TResult>)
AddAttributes(AttributesStatementSyntax[])
AddImports(ImportsStatementSyntax[])
AddMembers(StatementSyntax[])
AddOptions(OptionStatementSyntax[])
Ancestors(Boolean)

Gets a list of ancestor nodes

(Inherited from SyntaxNode)
AncestorsAndSelf(Boolean)

Gets a list of ancestor nodes (including this node)

(Inherited from SyntaxNode)
ChildNodes()

Gets a list of the child nodes in prefix document order.

(Inherited from SyntaxNode)
ChildNodesAndTokens()

The list of child nodes and tokens of this node, where each element is a SyntaxNodeOrToken instance.

(Inherited from SyntaxNode)
ChildThatContainsPosition(Int32) (Inherited from SyntaxNode)
ChildTokens()

Gets a list of the direct child tokens of this node.

(Inherited from SyntaxNode)
Contains(SyntaxNode)

Determines if the specified node is a descendant of this node. Returns true for current node.

(Inherited from SyntaxNode)
ContainsDirective(Int32)

Returns true if this node contains any directives (e.g. #if, #nullable, etc.) within it with a matching kind.

(Inherited from SyntaxNode)
CopyAnnotationsTo<T>(T)

Copies all SyntaxAnnotations, if any, from this SyntaxNode instance and attaches them to a new instance based on node.

(Inherited from SyntaxNode)
DescendantNodes(Func<SyntaxNode,Boolean>, Boolean)

Gets a list of descendant nodes in prefix document order.

(Inherited from SyntaxNode)
DescendantNodes(TextSpan, Func<SyntaxNode,Boolean>, Boolean)

Gets a list of descendant nodes in prefix document order.

(Inherited from SyntaxNode)
DescendantNodesAndSelf(Func<SyntaxNode,Boolean>, Boolean)

Gets a list of descendant nodes (including this node) in prefix document order.

(Inherited from SyntaxNode)
DescendantNodesAndSelf(TextSpan, Func<SyntaxNode,Boolean>, Boolean)

Gets a list of descendant nodes (including this node) in prefix document order.

(Inherited from SyntaxNode)
DescendantNodesAndTokens(Func<SyntaxNode,Boolean>, Boolean)

Gets a list of descendant nodes and tokens in prefix document order.

(Inherited from SyntaxNode)
DescendantNodesAndTokens(TextSpan, Func<SyntaxNode,Boolean>, Boolean)

Gets a list of the descendant nodes and tokens in prefix document order.

(Inherited from SyntaxNode)
DescendantNodesAndTokensAndSelf(Func<SyntaxNode,Boolean>, Boolean)

Gets a list of descendant nodes and tokens (including this node) in prefix document order.

(Inherited from SyntaxNode)
DescendantNodesAndTokensAndSelf(TextSpan, Func<SyntaxNode,Boolean>, Boolean)

Gets a list of the descendant nodes and tokens (including this node) in prefix document order.

(Inherited from SyntaxNode)
DescendantTokens(Func<SyntaxNode,Boolean>, Boolean)

Gets a list of all the tokens in the span of this node.

(Inherited from SyntaxNode)
DescendantTokens(TextSpan, Func<SyntaxNode,Boolean>, Boolean)

Gets a list of all the tokens in the full span of this node.

(Inherited from SyntaxNode)
DescendantTrivia(Func<SyntaxNode,Boolean>, Boolean)

Get a list of all the trivia associated with the descendant nodes and tokens.

(Inherited from SyntaxNode)
DescendantTrivia(TextSpan, Func<SyntaxNode,Boolean>, Boolean)

Get a list of all the trivia associated with the descendant nodes and tokens.

(Inherited from SyntaxNode)
EquivalentToCore(SyntaxNode)

Determine if this node is structurally equivalent to another.

(Inherited from SyntaxNode)
FindNode(TextSpan, Boolean, Boolean)

Finds the node with the smallest FullSpan that contains span. getInnermostNodeForTie is used to determine the behavior in case of a tie (i.e. a node having the same span as its parent). If getInnermostNodeForTie is true, then it returns lowest descending node encompassing the given span. Otherwise, it returns the outermost node encompassing the given span.

(Inherited from SyntaxNode)
FindToken(Int32, Boolean)

Finds a token according to the following rules:

  1. If position matches the End of the node's Span, then its last token is returned.

  2. If node.FullSpan.Contains(position) then the token that contains given position is returned.

  3. Otherwise an IndexOutOfRange is thrown

(Inherited from VisualBasicSyntaxNode)
FindTokenCore(Int32, Boolean)

Finds a descendant token of this node whose span includes the supplied position.

(Inherited from SyntaxNode)
FindTokenCore(Int32, Func<SyntaxTrivia,Boolean>)

Finds a descendant token of this node whose span includes the supplied position.

(Inherited from SyntaxNode)
FindTrivia(Int32, Boolean) (Inherited from VisualBasicSyntaxNode)
FindTrivia(Int32, Func<SyntaxTrivia,Boolean>)

Finds a descendant trivia of this node at the specified position, where the position is within the span of the node.

(Inherited from SyntaxNode)
FindTriviaCore(Int32, Boolean)

Finds a descendant trivia of this node whose span includes the supplied position.

(Inherited from SyntaxNode)
FirstAncestorOrSelf<TNode,TArg>(Func<TNode,TArg,Boolean>, TArg, Boolean)

Gets the first node of type TNode that matches the predicate.

(Inherited from SyntaxNode)
FirstAncestorOrSelf<TNode>(Func<TNode,Boolean>, Boolean)

Gets the first node of type TNode that matches the predicate.

(Inherited from SyntaxNode)
GetAnnotatedNodes(String)

Gets all nodes with the specified annotation kind.

(Inherited from SyntaxNode)
GetAnnotatedNodes(SyntaxAnnotation)

Gets all nodes with the specified annotation.

(Inherited from SyntaxNode)
GetAnnotatedNodesAndTokens(String)

Gets all nodes and tokens with an annotation of the specified annotation kind.

(Inherited from SyntaxNode)
GetAnnotatedNodesAndTokens(String[])

Gets all nodes and tokens with an annotation of the specified annotation kinds.

(Inherited from SyntaxNode)
GetAnnotatedNodesAndTokens(SyntaxAnnotation)

Gets all nodes and tokens with the specified annotation.

(Inherited from SyntaxNode)
GetAnnotatedTokens(String)

Gets all tokens with the specified annotation kind.

(Inherited from SyntaxNode)
GetAnnotatedTokens(SyntaxAnnotation)

Gets all tokens with the specified annotation.

(Inherited from SyntaxNode)
GetAnnotatedTrivia(String)

Gets all trivia with an annotation of the specified annotation kind.

(Inherited from SyntaxNode)
GetAnnotatedTrivia(String[])

Gets all trivia with an annotation of the specified annotation kinds.

(Inherited from SyntaxNode)
GetAnnotatedTrivia(SyntaxAnnotation)

Gets all trivia with the specified annotation.

(Inherited from SyntaxNode)
GetAnnotations(IEnumerable<String>)

Gets all the annotations with the specified annotation kinds.

(Inherited from SyntaxNode)
GetAnnotations(String)

Gets all the annotations with the specified annotation kind.

(Inherited from SyntaxNode)
GetDiagnostics()

Gets a list of all the diagnostics in the sub tree that has this node as its root. This method does not filter diagnostics based on compiler options like nowarn, warnaserror etc.

(Inherited from VisualBasicSyntaxNode)
GetDirectives(Func<DirectiveTriviaSyntax,Boolean>) (Inherited from VisualBasicSyntaxNode)
GetFirstDirective(Func<DirectiveTriviaSyntax,Boolean>) (Inherited from VisualBasicSyntaxNode)
GetFirstToken(Boolean, Boolean, Boolean, Boolean) (Inherited from VisualBasicSyntaxNode)
GetLastDirective(Func<DirectiveTriviaSyntax,Boolean>) (Inherited from VisualBasicSyntaxNode)
GetLastToken(Boolean, Boolean, Boolean, Boolean) (Inherited from VisualBasicSyntaxNode)
GetLeadingTrivia()

Get the preceding trivia nodes of this node. If this node is a token, returns the preceding trivia associated with this node. If this is a non-terminal, returns the preceding trivia of the first token of this node.

(Inherited from VisualBasicSyntaxNode)
GetLocation()

Gets the location of this node.

(Inherited from VisualBasicSyntaxNode)
GetRed<T>(T, Int32) (Inherited from SyntaxNode)
GetRedAtZero<T>(T) (Inherited from SyntaxNode)
GetReference()

Gets a SyntaxReference for this syntax node. CommonSyntaxReferences can be used to regain access to a syntax node without keeping the entire tree and source text in memory.

(Inherited from SyntaxNode)
GetReferenceDirectives()

Returns #r directives specified in the compilation.

GetText(Encoding, SourceHashAlgorithm)

Gets the full text of this node as a new SourceText instance.

(Inherited from SyntaxNode)
GetTrailingTrivia()

Get the following trivia nodes of this node. If this node is a token, returns the following trivia associated with this node. If this is a non-terminal, returns the following trivia of the last token of this node.

(Inherited from VisualBasicSyntaxNode)
HasAnnotation(SyntaxAnnotation)

Determines whether this node has the specific annotation.

(Inherited from SyntaxNode)
HasAnnotations(IEnumerable<String>)

Determines whether this node has any annotations with any of the specific annotation kinds.

(Inherited from SyntaxNode)
HasAnnotations(String)

Determines whether this node has any annotations with the specific annotation kind.

(Inherited from SyntaxNode)
InsertNodesInListCore(SyntaxNode, IEnumerable<SyntaxNode>, Boolean) (Inherited from VisualBasicSyntaxNode)
InsertTokensInListCore(SyntaxToken, IEnumerable<SyntaxToken>, Boolean) (Inherited from VisualBasicSyntaxNode)
InsertTriviaInListCore(SyntaxTrivia, IEnumerable<SyntaxTrivia>, Boolean) (Inherited from VisualBasicSyntaxNode)
IsEquivalentTo(SyntaxNode)

Determine whether this node is structurally equivalent to another.

(Inherited from SyntaxNode)
IsEquivalentTo(SyntaxNode, Boolean)

Determines if two nodes are the same, disregarding trivia differences.

(Inherited from SyntaxNode)
IsEquivalentToCore(SyntaxNode, Boolean) (Inherited from VisualBasicSyntaxNode)
IsIncrementallyIdenticalTo(SyntaxNode)

Returns true if these two nodes are considered "incrementally identical". An incrementally identical node occurs when a SyntaxTree is incrementally parsed using WithChangedText(SourceText) and the incremental parser is able to take the node from the original tree and use it in its entirety in the new tree. In this case, the ToFullString() of each node will be the same, though they could have different parents, and may occur at different positions in their respective trees. If two nodes are incrementally identical, all children of each node will be incrementally identical as well.

(Inherited from SyntaxNode)
IsPartOfStructuredTrivia()

Determines whether this node is a descendant of a structured trivia.

(Inherited from SyntaxNode)
Kind()

Returns the SyntaxKind of the node.

(Inherited from VisualBasicSyntaxNode)
NormalizeWhitespaceCore(String, String, Boolean) (Inherited from VisualBasicSyntaxNode)
RemoveNodesCore(IEnumerable<SyntaxNode>, SyntaxRemoveOptions) (Inherited from VisualBasicSyntaxNode)
ReplaceCore<TNode>(IEnumerable<TNode>, Func<TNode,TNode,SyntaxNode>, IEnumerable<SyntaxToken>, Func<SyntaxToken,SyntaxToken,SyntaxToken>, IEnumerable<SyntaxTrivia>, Func<SyntaxTrivia,SyntaxTrivia,SyntaxTrivia>) (Inherited from VisualBasicSyntaxNode)
ReplaceNodeInListCore(SyntaxNode, IEnumerable<SyntaxNode>) (Inherited from VisualBasicSyntaxNode)
ReplaceTokenInListCore(SyntaxToken, IEnumerable<SyntaxToken>) (Inherited from VisualBasicSyntaxNode)
ReplaceTriviaInListCore(SyntaxTrivia, IEnumerable<SyntaxTrivia>) (Inherited from VisualBasicSyntaxNode)
SerializeTo(Stream, CancellationToken)
Obsolete.
Obsolete.

Serializes the node to the given stream. Leaves the stream open for further writes.

(Inherited from SyntaxNode)
ToFullString()

Returns full string representation of this node including its leading and trailing trivia.

(Inherited from SyntaxNode)
ToString()

Returns the string representation of this node, not including its leading and trailing trivia.

(Inherited from SyntaxNode)
Update(SyntaxList<OptionStatementSyntax>, SyntaxList<ImportsStatementSyntax>, SyntaxList<AttributesStatementSyntax>, SyntaxList<StatementSyntax>, SyntaxToken)

Returns a copy of this with the specified changes. Returns this instance if there are no actual changes.

WithAttributes(SyntaxList<AttributesStatementSyntax>)

Returns a copy of this with the Attributes property changed to the specified value. Returns this instance if the specified value is the same as the current value.

WithEndOfFileToken(SyntaxToken)

Returns a copy of this with the EndOfFileToken property changed to the specified value. Returns this instance if the specified value is the same as the current value.

WithImports(SyntaxList<ImportsStatementSyntax>)

Returns a copy of this with the [Imports] property changed to the specified value. Returns this instance if the specified value is the same as the current value.

WithMembers(SyntaxList<StatementSyntax>)

Returns a copy of this with the Members property changed to the specified value. Returns this instance if the specified value is the same as the current value.

WithOptions(SyntaxList<OptionStatementSyntax>)

Returns a copy of this with the Options property changed to the specified value. Returns this instance if the specified value is the same as the current value.

WriteTo(TextWriter)

Writes the full text of this node to the specified TextWriter.

(Inherited from SyntaxNode)

Explicit Interface Implementations

ICompilationUnitSyntax.EndOfFileToken

Extension Methods

GetFirstDirective(SyntaxNode, Func<DirectiveTriviaSyntax,Boolean>)

Gets the first directive of the tree rooted by this node.

GetLastDirective(SyntaxNode, Func<DirectiveTriviaSyntax,Boolean>)

Gets the last directive of the tree rooted by this node.

Kind(SyntaxNode)

Returns SyntaxKind for SyntaxNode from RawKind property.

TryGetInferredMemberName(SyntaxNode)

Given an initializer expression infer the name of anonymous property or tuple element. Returns null if unsuccessful

ContainsDirective(SyntaxNode, SyntaxKind)

Returns true if this node contains any directives (e.g. #if, #nullable, etc.) within it with a matching kind.

IsKind(SyntaxNode, SyntaxKind)

Determines if SyntaxNode is of a specified kind.

GetCurrentNode<TNode>(SyntaxNode, TNode)

Gets the node within the subtree corresponding to the original tracked node. Use TrackNodes to start tracking nodes.

GetCurrentNodes<TNode>(SyntaxNode, TNode)

Gets the nodes within the subtree corresponding to the original tracked node. Use TrackNodes to start tracking nodes.

GetCurrentNodes<TNode>(SyntaxNode, IEnumerable<TNode>)

Gets the nodes within the subtree corresponding to the original tracked nodes. Use TrackNodes to start tracking nodes.

TryGetInferredMemberName(SyntaxNode)

Given an initializer expression infer the name of anonymous property or tuple element. Returns Nothing if unsuccessful

GetDirectives(SyntaxNode, Func<DirectiveTriviaSyntax,Boolean>)

Gets the DirectiveTriviaSyntax items for a specified SyntaxNode with optional filtering.

GetFirstDirective(SyntaxNode, Func<DirectiveTriviaSyntax,Boolean>)

Gets the first DirectiveTriviaSyntax item for a specified SyntaxNode.

GetLastDirective(SyntaxNode, Func<DirectiveTriviaSyntax,Boolean>)

Gets the last DirectiveTriviaSyntax item for a specified SyntaxNode.

Kind(SyntaxNode)

Returns SyntaxKind for SyntaxNode from RawKind property.

ContainsDirective(SyntaxNode, SyntaxKind)

Returns true if this node contains any directives (e.g. #if, #nullable, etc.) within it with a matching kind.

IsKind(SyntaxNode, SyntaxKind)

Determines if SyntaxNode is of a specified kind.

Applies to