Click or drag to resize

SemanticModel Class



Allows asking semantic questions about a tree of syntax nodes in a Compilation. Typically, an instance is obtained by a call to GetBinding on a Compilation or Compilation.
Inheritance Hierarchy
SystemObject
  Microsoft.CodeAnalysisSemanticModel

Namespace:  Microsoft.CodeAnalysis
Assembly:  Microsoft.CodeAnalysis (in Microsoft.CodeAnalysis.dll) Version: 2.3.0-dev-56735-00. Commit Hash: <developer build>
Syntax
public abstract class SemanticModel

The SemanticModel type exposes the following members.

Constructors
  NameDescription
Protected methodSemanticModel
Initializes a new instance of the SemanticModel class
Top
Properties
  NameDescription
Public propertyCompilation
The compilation this model was obtained from.
Protected propertyCompilationCore
The compilation this model was obtained from.
Public propertyIgnoresAccessibility
Returns true if this is a SemanticModel that ignores accessibility rules when answering semantic questions.
Public propertyIsSpeculativeSemanticModel
Returns true if this is a speculative semantic model created with any of the TryGetSpeculativeSemanticModel methods.
Public propertyLanguage
Gets the source language ("C#" or "Visual Basic").
Public propertyOriginalPositionForSpeculation
If this is a speculative semantic model, returns the original position at which the speculative model was created. Otherwise, returns 0.
Public propertyParentModel
If this is a speculative semantic model, then returns its parent semantic model. Otherwise, returns null.
Protected propertyParentModelCore
If this is a speculative semantic model, then returns its parent semantic model. Otherwise, returns null.
Public propertySyntaxTree
The syntax tree this model was obtained from.
Protected propertySyntaxTreeCore
The syntax tree this model was obtained from.
Top
Methods
  NameDescription
Protected methodAnalyzeControlFlowCore(SyntaxNode)
Analyze control-flow within a part of a method body.
Protected methodAnalyzeControlFlowCore(SyntaxNode, SyntaxNode)
Analyze control-flow within a part of a method body.
Protected methodAnalyzeDataFlowCore(SyntaxNode)
Analyze data-flow within a part of a method body.
Protected methodAnalyzeDataFlowCore(SyntaxNode, SyntaxNode)
Analyze data-flow within a part of a method body.
Protected methodGetAliasInfoCore
If "nameSyntax" resolves to an alias name, return the IAliasSymbol corresponding to A. Otherwise return null.
Public methodGetConstantValue
If the node provided has a constant value an Optional value will be returned with HasValue set to true and with Value set to the constant. If the node does not have an constant value, an Optional will be returned with HasValue set to false.
Protected methodGetConstantValueCore
If the node provided has a constant value an Optional value will be returned with HasValue set to true and with Value set to the constant. If the node does not have an constant value, an Optional will be returned with HasValue set to false.
Public methodGetDeclarationDiagnostics
Protected methodGetDeclaredSymbolCore
Gets the symbol associated with a declaration syntax node.
Protected methodGetDeclaredSymbolsCore
Gets the symbol associated with a declaration syntax node. Unlike GetDeclaredSymbolForNode(SyntaxNode, CancellationToken), this method returns all symbols declared by a given declaration syntax node. Specifically, in the case of field declaration syntax nodes, which can declare multiple symbols, this method returns all declared symbols.
Public methodGetDiagnostics
Public methodGetEnclosingSymbol
Given a position in the SyntaxTree for this SemanticModel returns the innermost Symbol that the position is considered inside of.
Protected methodGetEnclosingSymbolCore
Given a position in the SyntaxTree for this SemanticModel returns the innermost Symbol that the position is considered inside of.
Protected methodGetMemberGroupCore
When getting information for a symbol that resolves to a method group or property group, from which a method is then chosen; the chosen method or property is present in Symbol; all methods in the group that was consulted are placed in this property.
Public methodGetMethodBodyDiagnostics
Public methodGetOperation
Gets the operation corresponding to the expression or statement syntax node.
Protected methodGetOperationCore
Public methodGetPreprocessingSymbolInfo
If nameSyntax is an identifier name syntax node, return the PreprocessingSymbolInfo corresponding to it.
Protected methodGetPreprocessingSymbolInfoCore
If nameSyntax is an identifier name syntax node, return the PreprocessingSymbolInfo corresponding to it.
Protected methodGetSpeculativeAliasInfoCore
Binds the name in the context of the specified location and sees if it resolves to an alias name. If it does, return the AliasSymbol corresponding to it. Otherwise, return null.
Protected methodGetSpeculativeSymbolInfoCore
Binds the node in the context of the specified location and get semantic information such as type, symbols and diagnostics. This method is used to get semantic information about an expression that did not actually appear in the source code.
Protected methodGetSpeculativeTypeInfoCore
Binds the node in the context of the specified location and get semantic information such as type, symbols and diagnostics. This method is used to get semantic information about an expression that did not actually appear in the source code.
Protected methodGetSymbolInfoCore
Gets symbol information about a syntax node.
Public methodGetSyntaxDiagnostics
Protected methodGetTopmostNodeForDiagnosticAnalysis
Takes a Symbol and syntax for one of its declaring syntax reference and returns the topmost syntax node to be used by syntax analyzer.
Protected methodGetTypeInfoCore
Gets type information about a syntax node.
Public methodIsAccessible
Determines if the symbol is accessible from the specified location.
Protected methodIsAccessibleCore
Determines if the symbol is accessible from the specified location.
Public methodIsEventUsableAsField
Field-like events can be used as fields in types that can access private members of the declaring type of the event.
Protected methodIsEventUsableAsFieldCore
Field-like events can be used as fields in types that can access private members of the declaring type of the event.
Public methodLookupBaseMembers
Gets the available base type members in the context of the specified location. Akin to calling LookupSymbols(Int32, INamespaceOrTypeSymbol, String, Boolean) with the container set to the immediate base type of the type in which position occurs. However, the accessibility rules are different: protected members of the base type will be visible. Consider the following example: public class Base { protected void M() { } } public class Derived : Base { void Test(Base b) { b.M(); // Error - cannot access protected member. base.M(); } } Protected members of an instance of another type are only accessible if the instance is known to be "this" instance (as indicated by the "base" keyword).
Protected methodLookupBaseMembersCore
Backing implementation of LookupBaseMembers(Int32, String).
Public methodLookupLabels
Gets the available named label symbols in the context of the specified location and optional container. Only members that are accessible and visible from the given location are returned.
Protected methodLookupLabelsCore
Backing implementation of LookupLabels(Int32, String).
Public methodLookupNamespacesAndTypes
Gets the available named namespace and type symbols in the context of the specified location and optional container. Only members that are accessible and visible from the given location are returned.
Protected methodLookupNamespacesAndTypesCore
Public methodLookupStaticMembers
Gets the available named static member symbols in the context of the specified location and optional container. Only members that are accessible and visible from the given location are returned. Non-reduced extension methods are considered, since they are static methods.
Protected methodLookupStaticMembersCore
Public methodLookupSymbols
Gets the available named symbols in the context of the specified location and optional container. Only symbols that are accessible and visible from the given location are returned.
Protected methodLookupSymbolsCore
Top
Extension Methods
  NameDescription
Public Extension MethodAnalyzeControlFlow(StatementSyntax)Overloaded.
Analyze control-flow within a part of a method body.
(Defined by VisualBasicExtensions.)
Public Extension MethodAnalyzeControlFlow(StatementSyntax)Overloaded.
Analyze control-flow within a part of a method body.
(Defined by CSharpExtensions.)
Public Extension MethodAnalyzeControlFlow(SyntaxNode)Overloaded.
Analyze control-flow within a part of a method body.
(Defined by ModelExtensions.)
Public Extension MethodAnalyzeControlFlow(StatementSyntax, StatementSyntax)Overloaded.
Analyze control-flow within a part of a method body.
(Defined by VisualBasicExtensions.)
Public Extension MethodAnalyzeControlFlow(StatementSyntax, StatementSyntax)Overloaded.
Analyze control-flow within a part of a method body.
(Defined by CSharpExtensions.)
Public Extension MethodAnalyzeControlFlow(SyntaxNode, SyntaxNode)Overloaded.
Analyze control-flow within a part of a method body.
(Defined by ModelExtensions.)
Public Extension MethodAnalyzeDataFlow(ExpressionSyntax)Overloaded.
Analyze data-flow within an expression.
(Defined by VisualBasicExtensions.)
Public Extension MethodAnalyzeDataFlow(ExpressionSyntax)Overloaded.
Analyze data-flow within an expression.
(Defined by CSharpExtensions.)
Public Extension MethodAnalyzeDataFlow(StatementSyntax)Overloaded.
Analyze data-flow within a statement.
(Defined by VisualBasicExtensions.)
Public Extension MethodAnalyzeDataFlow(StatementSyntax)Overloaded.
Analyze data-flow within a part of a method body.
(Defined by CSharpExtensions.)
Public Extension MethodAnalyzeDataFlow(SyntaxNode)Overloaded.
Analyze data-flow within a part of a method body.
(Defined by ModelExtensions.)
Public Extension MethodAnalyzeDataFlow(StatementSyntax, StatementSyntax)Overloaded.
Analyze data-flow within a set of contiguous statements.
(Defined by VisualBasicExtensions.)
Public Extension MethodAnalyzeDataFlow(StatementSyntax, StatementSyntax)Overloaded.
Analyze data-flow within a part of a method body.
(Defined by CSharpExtensions.)
Public Extension MethodAnalyzeDataFlow(SyntaxNode, SyntaxNode)Overloaded.
Analyze data-flow within a part of a method body.
(Defined by ModelExtensions.)
Public Extension MethodClassifyConversion(ExpressionSyntax, ITypeSymbol)Overloaded.
Determines what kind of conversion there is between the expression syntax and a specified type.
(Defined by VisualBasicExtensions.)
Public Extension MethodClassifyConversion(Int32, ExpressionSyntax, ITypeSymbol)Overloaded.
Determines what kind of conversion there is between the expression syntax and a specified type.
(Defined by VisualBasicExtensions.)
Public Extension MethodClassifyConversion(ExpressionSyntax, ITypeSymbol, Boolean)Overloaded.
Determines what type of conversion, if any, would be used if a given expression was converted to a given type. If isExplicitInSource is true, the conversion produced is that which would be used if the conversion were done for a cast expression.
(Defined by CSharpExtensions.)
Public Extension MethodClassifyConversion(Int32, ExpressionSyntax, ITypeSymbol, Boolean)Overloaded.
Determines what type of conversion, if any, would be used if a given expression was converted to a given type. If isExplicitInSource is true, the conversion produced is that which would be used if the conversion were done for a cast expression.
(Defined by CSharpExtensions.)
Public Extension MethodGetAggregateClauseSymbolInfo
Returns information about methods associated with AggregateClauseSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetAliasInfo(IdentifierNameSyntax, CancellationToken)Overloaded.
If "nameSyntax" resolves to an alias name, return the AliasSymbol corresponding to A. Otherwise return null.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetAliasInfo(IdentifierNameSyntax, CancellationToken)Overloaded.
If nameSyntax resolves to an alias name, return the AliasSymbol corresponding to A. Otherwise return null.
(Defined by CSharpExtensions.)
Public Extension MethodGetAliasInfo(SyntaxNode, CancellationToken)Overloaded.
If "nameSyntax" resolves to an alias name, return the IAliasSymbol corresponding to A. Otherwise return null.
(Defined by ModelExtensions.)
Public Extension MethodGetAwaitExpressionInfo(AwaitExpressionSyntax)Overloaded. (Defined by CSharpExtensions.)
Public Extension MethodGetAwaitExpressionInfo(AwaitExpressionSyntax, CancellationToken)Overloaded.
Gets the corresponding AwaitExpressionInfo containing semantic info for a specified AwaitExpressionSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetCollectionInitializerSymbolInfo(ExpressionSyntax, CancellationToken)Overloaded.
Returns what 'Add' method symbol(s), if any, corresponds to the given expression syntax within Initializer.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetCollectionInitializerSymbolInfo(ExpressionSyntax, CancellationToken)Overloaded.
Returns what 'Add' method symbol(s), if any, corresponds to the given expression syntax within Initializer.
(Defined by CSharpExtensions.)
Public Extension MethodGetCollectionRangeVariableSymbolInfo
Returns information about methods associated with CollectionRangeVariableSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetConstantValue (Defined by CSharpExtensions.)
Public Extension MethodGetConversion(SyntaxNode, CancellationToken)Overloaded.
Gets the corresponding TypeInfo containing semantic info for a specified ExpressionSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetConversion(SyntaxNode, CancellationToken)Overloaded. (Defined by CSharpExtensions.)
Public Extension MethodGetDeclaredSymbol(AccessorDeclarationSyntax, CancellationToken)Overloaded.
Given a syntax node that declares a property or member accessor, get the corresponding symbol.
(Defined by CSharpExtensions.)
Public Extension MethodGetDeclaredSymbol(AccessorStatementSyntax, CancellationToken)Overloaded.
Gets the corresponding MethodSymbol for a specified AccessorStatementSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetDeclaredSymbol(AggregationRangeVariableSyntax, CancellationToken)Overloaded.
Gets the corresponding RangeVariableSymbol for a specified AggregationRangeVariableSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetDeclaredSymbol(AnonymousObjectCreationExpressionSyntax, CancellationToken)Overloaded.
Gets the corresponding NamedTypeSymbol for a specified AnonymousObjectCreationExpressionSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetDeclaredSymbol(AnonymousObjectCreationExpressionSyntax, CancellationToken)Overloaded.
Given a syntax node of anonymous object creation expression, get the anonymous object type symbol.
(Defined by CSharpExtensions.)
Public Extension MethodGetDeclaredSymbol(AnonymousObjectMemberDeclaratorSyntax, CancellationToken)Overloaded.
Given a syntax node of anonymous object creation initializer, get the anonymous object property symbol.
(Defined by CSharpExtensions.)
Public Extension MethodGetDeclaredSymbol(ArgumentSyntax, CancellationToken)Overloaded.
Given a syntax node of a tuple argument, get the tuple element symbol.
(Defined by CSharpExtensions.)
Public Extension MethodGetDeclaredSymbol(BaseMethodDeclarationSyntax, CancellationToken)Overloaded.
Given a base method declaration syntax, get the corresponding method symbol.
(Defined by CSharpExtensions.)
Public Extension MethodGetDeclaredSymbol(BasePropertyDeclarationSyntax, CancellationToken)Overloaded.
Given a syntax node that declares a property, indexer or an event, get the corresponding declared symbol.
(Defined by CSharpExtensions.)
Public Extension MethodGetDeclaredSymbol(BaseTypeDeclarationSyntax, CancellationToken)Overloaded.
Given a type declaration, get the corresponding type symbol.
(Defined by CSharpExtensions.)
Public Extension MethodGetDeclaredSymbol(CatchDeclarationSyntax, CancellationToken)Overloaded.
Given a catch declaration, get the symbol for the exception variable
(Defined by CSharpExtensions.)
Public Extension MethodGetDeclaredSymbol(CatchStatementSyntax, CancellationToken)Overloaded.
Gets the corresponding LocalSymbol for a specified CatchStatementSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetDeclaredSymbol(CollectionRangeVariableSyntax, CancellationToken)Overloaded.
Gets the corresponding RangeVariableSymbol for a specified CollectionRangeVariableSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetDeclaredSymbol(DeclareStatementSyntax, CancellationToken)Overloaded.
Gets the corresponding symbol for a specified DeclareStatementSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetDeclaredSymbol(DelegateDeclarationSyntax, CancellationToken)Overloaded.
Given a delegate declaration, get the corresponding type symbol.
(Defined by CSharpExtensions.)
Public Extension MethodGetDeclaredSymbol(DelegateStatementSyntax, CancellationToken)Overloaded.
Gets the corresponding NamedTypeSymbol for a specified DelegateStatementSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetDeclaredSymbol(EnumBlockSyntax, CancellationToken)Overloaded.
Gets the corresponding NamedTypeSymbol for a specified EnumBlockSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetDeclaredSymbol(EnumMemberDeclarationSyntax, CancellationToken)Overloaded.
Gets the corresponding FieldSymbol for a specified EnumMemberDeclarationSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetDeclaredSymbol(EnumMemberDeclarationSyntax, CancellationToken)Overloaded.
Given a enum member declaration, get the corresponding field symbol.
(Defined by CSharpExtensions.)
Public Extension MethodGetDeclaredSymbol(EnumStatementSyntax, CancellationToken)Overloaded.
Gets the corresponding NamedTypeSymbol for a specified EnumStatementSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetDeclaredSymbol(EventBlockSyntax, CancellationToken)Overloaded.
Gets the corresponding EventSymbol for a specified EventBlockSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetDeclaredSymbol(EventDeclarationSyntax, CancellationToken)Overloaded.
Given a syntax node that declares a (custom) event, get the corresponding event symbol.
(Defined by CSharpExtensions.)
Public Extension MethodGetDeclaredSymbol(EventStatementSyntax, CancellationToken)Overloaded.
Gets the corresponding EventSymbol for a specified EventStatementSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetDeclaredSymbol(ExpressionRangeVariableSyntax, CancellationToken)Overloaded.
Gets the corresponding RangeVariableSymbol for a specified ExpressionRangeVariableSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetDeclaredSymbol(ExternAliasDirectiveSyntax, CancellationToken)Overloaded.
Given an extern alias declaration get the corresponding symbol for the alias that was introduced.
(Defined by CSharpExtensions.)
Public Extension MethodGetDeclaredSymbol(FieldInitializerSyntax, CancellationToken)Overloaded.
Gets the corresponding PropertySymbol for a specified FieldInitializerSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetDeclaredSymbol(ForEachStatementSyntax, CancellationToken)Overloaded.
Given a foreach statement, get the symbol for the iteration variable
(Defined by CSharpExtensions.)
Public Extension MethodGetDeclaredSymbol(IndexerDeclarationSyntax, CancellationToken)Overloaded.
Given a syntax node that declares an indexer, get the corresponding declared symbol.
(Defined by CSharpExtensions.)
Public Extension MethodGetDeclaredSymbol(JoinIntoClauseSyntax, CancellationToken)Overloaded.
Get the query range variable declared in a join into clause.
(Defined by CSharpExtensions.)
Public Extension MethodGetDeclaredSymbol(LabeledStatementSyntax, CancellationToken)Overloaded.
Given a labeled statement syntax, get the corresponding label symbol.
(Defined by CSharpExtensions.)
Public Extension MethodGetDeclaredSymbol(LabelStatementSyntax, CancellationToken)Overloaded.
Gets the corresponding LabelSymbol for a specified LabelStatementSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetDeclaredSymbol(MemberDeclarationSyntax, CancellationToken)Overloaded.
Given a member declaration syntax, get the corresponding symbol.
(Defined by CSharpExtensions.)
Public Extension MethodGetDeclaredSymbol(MethodBlockBaseSyntax, CancellationToken)Overloaded.
Gets the corresponding MethodSymbol for a specified MethodBlockBaseSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetDeclaredSymbol(MethodStatementSyntax, CancellationToken)Overloaded.
Gets the corresponding MethodSymbol for a specified MethodStatementSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetDeclaredSymbol(ModifiedIdentifierSyntax, CancellationToken)Overloaded.
Gets the corresponding symbol for a specified identifier.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetDeclaredSymbol(NamespaceBlockSyntax, CancellationToken)Overloaded.
Gets the corresponding NamespaceSymbol for a specified NamespaceBlockSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetDeclaredSymbol(NamespaceDeclarationSyntax, CancellationToken)Overloaded.
Given a namespace declaration syntax node, get the corresponding namespace symbol for the declaration assembly.
(Defined by CSharpExtensions.)
Public Extension MethodGetDeclaredSymbol(NamespaceStatementSyntax, CancellationToken)Overloaded.
Gets the corresponding NamespaceSymbol for a specified NamespaceStatementSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetDeclaredSymbol(OperatorStatementSyntax, CancellationToken)Overloaded.
Gets the corresponding MethodSymbol for a specified OperatorStatementSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetDeclaredSymbol(ParameterSyntax, CancellationToken)Overloaded.
Gets the corresponding ParameterSymbol for a specified ParameterSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetDeclaredSymbol(ParameterSyntax, CancellationToken)Overloaded.
Given a parameter declaration syntax node, get the corresponding symbol.
(Defined by CSharpExtensions.)
Public Extension MethodGetDeclaredSymbol(PropertyBlockSyntax, CancellationToken)Overloaded.
Gets the corresponding PropertySymbol for a specified PropertyBlockSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetDeclaredSymbol(PropertyDeclarationSyntax, CancellationToken)Overloaded.
Given a syntax node that declares a property, get the corresponding declared symbol.
(Defined by CSharpExtensions.)
Public Extension MethodGetDeclaredSymbol(PropertyStatementSyntax, CancellationToken)Overloaded.
Gets the corresponding PropertySymbol for a specified PropertyStatementSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetDeclaredSymbol(QueryClauseSyntax, CancellationToken)Overloaded. (Defined by CSharpExtensions.)
Public Extension MethodGetDeclaredSymbol(QueryContinuationSyntax, CancellationToken)Overloaded.
Get the query range variable declared in a query continuation clause.
(Defined by CSharpExtensions.)
Public Extension MethodGetDeclaredSymbol(SimpleImportsClauseSyntax, CancellationToken)Overloaded.
Gets the corresponding AliasSymbol for a specified AliasImportsClauseSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetDeclaredSymbol(SingleVariableDesignationSyntax, CancellationToken)Overloaded.
Given a variable declarator syntax, get the corresponding symbol.
(Defined by CSharpExtensions.)
Public Extension MethodGetDeclaredSymbol(SubNewStatementSyntax, CancellationToken)Overloaded.
Gets the corresponding MethodSymbol for a specified SubNewStatementSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetDeclaredSymbol(SwitchLabelSyntax, CancellationToken)Overloaded.
Given a switch label syntax, get the corresponding label symbol.
(Defined by CSharpExtensions.)
Public Extension MethodGetDeclaredSymbol(SyntaxNode, CancellationToken)Overloaded.
Gets the symbol associated with a declaration syntax node.
(Defined by ModelExtensions.)
Public Extension MethodGetDeclaredSymbol(TupleElementSyntax, CancellationToken)Overloaded.
Gets the corresponding symbol for a specified tuple element.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetDeclaredSymbol(TupleElementSyntax, CancellationToken)Overloaded.
Given a tuple element syntax, get the corresponding symbol.
(Defined by CSharpExtensions.)
Public Extension MethodGetDeclaredSymbol(TupleExpressionSyntax, CancellationToken)Overloaded.
Given a syntax node of tuple expression, get the tuple type symbol.
(Defined by CSharpExtensions.)
Public Extension MethodGetDeclaredSymbol(TypeBlockSyntax, CancellationToken)Overloaded.
Gets the corresponding NamedTypeSymbol for a specified TypeBlockSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetDeclaredSymbol(TypeParameterSyntax, CancellationToken)Overloaded.
Gets the corresponding TypeParameterSymbol Symbol for a specified TypeParameterSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetDeclaredSymbol(TypeParameterSyntax, CancellationToken)Overloaded.
Given a type parameter declaration (field or method), get the corresponding symbol
(Defined by CSharpExtensions.)
Public Extension MethodGetDeclaredSymbol(TypeStatementSyntax, CancellationToken)Overloaded.
Gets the corresponding NamedTypeSymbol for a specified TypeStatementSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetDeclaredSymbol(UsingDirectiveSyntax, CancellationToken)Overloaded.
Given a using declaration get the corresponding symbol for the using alias that was introduced.
(Defined by CSharpExtensions.)
Public Extension MethodGetDeclaredSymbol(VariableDeclaratorSyntax, CancellationToken)Overloaded.
Given a variable declarator syntax, get the corresponding symbol.
(Defined by CSharpExtensions.)
Public Extension MethodGetForEachStatementInfo(CommonForEachStatementSyntax)Overloaded. (Defined by CSharpExtensions.)
Public Extension MethodGetForEachStatementInfo(ForEachBlockSyntax)Overloaded.
Gets the corresponding ForEachStatementInfo containing semantic info for a specified ForBlockSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetForEachStatementInfo(ForEachStatementSyntax)Overloaded.
Gets the corresponding ForEachStatementInfo containing semantic info for a specified ForEachStatementSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetForEachStatementInfo(ForEachStatementSyntax)Overloaded. (Defined by CSharpExtensions.)
Public Extension MethodGetIndexerGroup
Returns the list of accessible, non-hidden indexers that could be invoked with the given expression as receiver.
(Defined by CSharpExtensions.)
Public Extension MethodGetMemberGroup(AttributeSyntax, CancellationToken)Overloaded.
Gets the corresponding ImmutableArray of Symbols for a specified AttributeSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetMemberGroup(AttributeSyntax, CancellationToken)Overloaded. (Defined by CSharpExtensions.)
Public Extension MethodGetMemberGroup(ConstructorInitializerSyntax, CancellationToken)Overloaded. (Defined by CSharpExtensions.)
Public Extension MethodGetMemberGroup(ExpressionSyntax, CancellationToken)Overloaded.
Gets the corresponding ImmutableArray of Symbols for a specified ExpressionSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetMemberGroup(ExpressionSyntax, CancellationToken)Overloaded. (Defined by CSharpExtensions.)
Public Extension MethodGetMemberGroup(SyntaxNode, CancellationToken)Overloaded.
Gets a list of method or indexed property symbols for a syntax node.
(Defined by ModelExtensions.)
Public Extension MethodGetPreprocessingSymbolInfo
If the given node is within a preprocessing directive, gets the preprocessing symbol info for it.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetQueryClauseInfo
Gets the semantic information associated with a query clause.
(Defined by CSharpExtensions.)
Public Extension MethodGetSpeculativeAliasInfo(Int32, IdentifierNameSyntax, SpeculativeBindingOption)Overloaded.
Binds the name in the context of the specified location and sees if it resolves to an alias name. If it does, return the AliasSymbol corresponding to it. Otherwise, return null.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetSpeculativeAliasInfo(Int32, SyntaxNode, SpeculativeBindingOption)Overloaded.
Binds the name in the context of the specified location and sees if it resolves to an alias name. If it does, return the AliasSymbol corresponding to it. Otherwise, return null.
(Defined by ModelExtensions.)
Public Extension MethodGetSpeculativeAliasInfo(Int32, IdentifierNameSyntax, SpeculativeBindingOption)Overloaded.
Binds the name in the context of the specified location and sees if it resolves to an alias name. If it does, return the AliasSymbol corresponding to it. Otherwise, return null.
(Defined by CSharpExtensions.)
Public Extension MethodGetSpeculativeConversion(Int32, ExpressionSyntax, SpeculativeBindingOption)Overloaded. (Defined by VisualBasicExtensions.)
Public Extension MethodGetSpeculativeConversion(Int32, ExpressionSyntax, SpeculativeBindingOption)Overloaded. (Defined by CSharpExtensions.)
Public Extension MethodGetSpeculativeMemberGroup
Gets the corresponding ImmutableArray of Symbols for a speculating an ExpressionSyntax at a given position, used in Semantic Info for items not appearing in source code.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetSpeculativeSymbolInfo(Int32, AttributeSyntax)Overloaded.
Gets the corresponding SymbolInfo containing semantic info for specified AttributeSyntax at a given position, used in Semantic Info for items not appearing in source code.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetSpeculativeSymbolInfo(Int32, AttributeSyntax)Overloaded.
Bind the attribute in the context of the specified location and get semantic information such as type, symbols and diagnostics. This method is used to get semantic information about an attribute that did not actually appear in the source code.
(Defined by CSharpExtensions.)
Public Extension MethodGetSpeculativeSymbolInfo(Int32, ConstructorInitializerSyntax)Overloaded.
Bind the constructor initializer in the context of the specified location and get semantic information such as type, symbols and diagnostics. This method is used to get semantic information about a constructor initializer that did not actually appear in the source code. NOTE: This will only work in locations where there is already a constructor initializer.
(Defined by CSharpExtensions.)
Public Extension MethodGetSpeculativeSymbolInfo(Int32, ExpressionSyntax, SpeculativeBindingOption)Overloaded.
Gets the corresponding SymbolInfo containing semantic info for a specified AttributeSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetSpeculativeSymbolInfo(Int32, SyntaxNode, SpeculativeBindingOption)Overloaded.
Binds the node in the context of the specified location and get semantic information such as type, symbols and diagnostics. This method is used to get semantic information about an expression that did not actually appear in the source code.
(Defined by ModelExtensions.)
Public Extension MethodGetSpeculativeSymbolInfo(Int32, ExpressionSyntax, SpeculativeBindingOption)Overloaded.
Binds the expression in the context of the specified location and gets symbol information. This method is used to get symbol information about an expression that did not actually appear in the source code.
(Defined by CSharpExtensions.)
Public Extension MethodGetSpeculativeSymbolInfo(Int32, CrefSyntax, SpeculativeBindingOption)Overloaded.
Binds the CrefSyntax expression in the context of the specified location and gets symbol information. This method is used to get symbol information about an expression that did not actually appear in the source code.
(Defined by CSharpExtensions.)
Public Extension MethodGetSpeculativeTypeInfo(Int32, ExpressionSyntax, SpeculativeBindingOption)Overloaded.
Gets the corresponding TypeInfo containing semantic info for a speculating an ExpressionSyntax at a given position, used in Semantic Info for items not appearing in source code.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetSpeculativeTypeInfo(Int32, SyntaxNode, SpeculativeBindingOption)Overloaded.
Binds the node in the context of the specified location and get semantic information such as type, symbols and diagnostics. This method is used to get semantic information about an expression that did not actually appear in the source code.
(Defined by ModelExtensions.)
Public Extension MethodGetSpeculativeTypeInfo(Int32, ExpressionSyntax, SpeculativeBindingOption)Overloaded.
Binds the expression in the context of the specified location and gets type information. This method is used to get type information about an expression that did not actually appear in the source code.
(Defined by CSharpExtensions.)
Public Extension MethodGetSymbolInfo(AttributeSyntax, CancellationToken)Overloaded.
Gets the corresponding SymbolInfo containing semantic info for a specified AttributeSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetSymbolInfo(AttributeSyntax, CancellationToken)Overloaded.
Returns what symbol(s), if any, the given attribute syntax bound to in the program.
(Defined by CSharpExtensions.)
Public Extension MethodGetSymbolInfo(ConstructorInitializerSyntax, CancellationToken)Overloaded.
Returns what symbol(s), if any, the given constructor initializer syntax bound to in the program.
(Defined by CSharpExtensions.)
Public Extension MethodGetSymbolInfo(CrefReferenceSyntax, CancellationToken)Overloaded.
Gets the corresponding SymbolInfo containing semantic info for a specified CrefReferenceSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetSymbolInfo(CrefSyntax, CancellationToken)Overloaded.
Gets the semantic information associated with a documentation comment cref.
(Defined by CSharpExtensions.)
Public Extension MethodGetSymbolInfo(ExpressionRangeVariableSyntax, CancellationToken)Overloaded.
Returns Select method associated with ExpressionRangeVariableSyntax within a LetClauseSyntax, or None otherwise if none is.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetSymbolInfo(ExpressionSyntax, CancellationToken)Overloaded.
Gets the corresponding SymbolInfo containing semantic info for a specified ExpressionSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetSymbolInfo(ExpressionSyntax, CancellationToken)Overloaded.
Returns what symbol(s), if any, the given expression syntax bound to in the program. An AliasSymbol will never be returned by this method. What the alias refers to will be returned instead. To get information about aliases, call GetAliasInfo. If binding the type name C in the expression "new C(...)" the actual constructor bound to will be returned (or all constructor if overload resolution failed). This occurs as long as C unambiguously binds to a single type that has a constructor. If C ambiguously binds to multiple types, or C binds to a static class, then type(s) are returned.
(Defined by CSharpExtensions.)
Public Extension MethodGetSymbolInfo(FunctionAggregationSyntax, CancellationToken)Overloaded.
Returns aggregate function associated with FunctionAggregationSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetSymbolInfo(OrderingSyntax, CancellationToken)Overloaded.
Returns OrderBy/OrderByDescending/ThenBy/ThenByDescending method associated with OrderingSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetSymbolInfo(OrderingSyntax, CancellationToken)Overloaded.
Gets the semantic information for an ordering clause in an orderby query clause.
(Defined by CSharpExtensions.)
Public Extension MethodGetSymbolInfo(QueryClauseSyntax, CancellationToken)Overloaded.
Returns symbol information for a query clause.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetSymbolInfo(SelectOrGroupClauseSyntax, CancellationToken)Overloaded.
Gets the semantic information associated with a select or group clause.
(Defined by CSharpExtensions.)
Public Extension MethodGetSymbolInfo(SyntaxNode, CancellationToken)Overloaded.
Gets symbol information about a syntax node.
(Defined by ModelExtensions.)
Public Extension MethodGetTypeInfo(AttributeSyntax, CancellationToken)Overloaded.
Gets the corresponding TypeInfo containing semantic info for a specified AttributeSyntax.
(Defined by VisualBasicExtensions.)
Public Extension MethodGetTypeInfo(AttributeSyntax, CancellationToken)Overloaded.
Gets type information about an attribute.
(Defined by CSharpExtensions.)
Public Extension MethodGetTypeInfo(ConstructorInitializerSyntax, CancellationToken)Overloaded.
Gets type information about a constructor initializer.
(Defined by CSharpExtensions.)
Public Extension MethodGetTypeInfo(ExpressionSyntax, CancellationToken)Overloaded. (Defined by VisualBasicExtensions.)
Public Extension MethodGetTypeInfo(ExpressionSyntax, CancellationToken)Overloaded.
Gets type information about an expression.
(Defined by CSharpExtensions.)
Public Extension MethodGetTypeInfo(SelectOrGroupClauseSyntax, CancellationToken)Overloaded. (Defined by CSharpExtensions.)
Public Extension MethodGetTypeInfo(SyntaxNode, CancellationToken)Overloaded.
Gets type information about a syntax node.
(Defined by ModelExtensions.)
Public Extension MethodOptionCompareText
Gets the Semantic Model OptionCompareText property.
(Defined by VisualBasicExtensions.)
Public Extension MethodOptionExplicit
Gets the Semantic Model OptionExplicit property.
(Defined by VisualBasicExtensions.)
Public Extension MethodOptionInfer
Gets the Semantic Model OptionInfer property.
(Defined by VisualBasicExtensions.)
Public Extension MethodOptionStrict
Gets the Semantic Model OptionStrict property.
(Defined by VisualBasicExtensions.)
Public Extension MethodTryGetSpeculativeSemanticModel(Int32, RangeArgumentSyntax, SemanticModel)Overloaded.
Gets the SemanticModel for a RangeArgumentSyntax at a given position, used in Semantic Info for items not appearing in source code.
(Defined by VisualBasicExtensions.)
Public Extension MethodTryGetSpeculativeSemanticModel(Int32, ExecutableStatementSyntax, SemanticModel)Overloaded.
Gets the SemanticModel for a ExecutableStatementSyntax at a given position, used in Semantic Info for items not appearing in source code.
(Defined by VisualBasicExtensions.)
Public Extension MethodTryGetSpeculativeSemanticModel(Int32, EqualsValueSyntax, SemanticModel)Overloaded.
Gets the SemanticModel for a EqualsValueSyntax at a given position, used in Semantic Info for items not appearing in source code.
(Defined by VisualBasicExtensions.)
Public Extension MethodTryGetSpeculativeSemanticModel(Int32, AttributeSyntax, SemanticModel)Overloaded.
Gets the SemanticModel for a AttributeSyntax at a given position, used in Semantic Info for items not appearing in source code.
(Defined by VisualBasicExtensions.)
Public Extension MethodTryGetSpeculativeSemanticModel(Int32, CrefSyntax, SemanticModel)Overloaded.
Get a SemanticModel object that is associated with a cref syntax node that did not appear in this source code. This can be used to get detailed semantic information about sub-parts of a cref syntax that did not appear in source code.
(Defined by CSharpExtensions.)
Public Extension MethodTryGetSpeculativeSemanticModel(Int32, StatementSyntax, SemanticModel)Overloaded.
Get a SemanticModel object that is associated with a statement that did not appear in this source code. This can be used to get detailed semantic information about sub-parts of a statement that did not appear in source code.
(Defined by CSharpExtensions.)
Public Extension MethodTryGetSpeculativeSemanticModel(Int32, EqualsValueClauseSyntax, SemanticModel)Overloaded.
Get a SemanticModel object that is associated with an initializer that did not appear in this source code. This can be used to get detailed semantic information about sub-parts of a field initializer or default parameter value that did not appear in source code.
(Defined by CSharpExtensions.)
Public Extension MethodTryGetSpeculativeSemanticModel(Int32, ArrowExpressionClauseSyntax, SemanticModel)Overloaded.
Get a SemanticModel object that is associated with an expression body that did not appear in this source code. This can be used to get detailed semantic information about sub-parts of an expression body that did not appear in source code.
(Defined by CSharpExtensions.)
Public Extension MethodTryGetSpeculativeSemanticModel(Int32, ConstructorInitializerSyntax, SemanticModel)Overloaded.
Get a SemanticModel object that is associated with a constructor initializer that did not appear in this source code. This can be used to get detailed semantic information about sub-parts of a constructor initializer that did not appear in source code. NOTE: This will only work in locations where there is already a constructor initializer.
(Defined by CSharpExtensions.)
Public Extension MethodTryGetSpeculativeSemanticModel(Int32, AttributeSyntax, SemanticModel)Overloaded.
Get a SemanticModel object that is associated with an attribute that did not appear in this source code. This can be used to get detailed semantic information about sub-parts of an attribute that did not appear in source code.
(Defined by CSharpExtensions.)
Public Extension MethodTryGetSpeculativeSemanticModel(Int32, TypeSyntax, SemanticModel, SpeculativeBindingOption)Overloaded.
Gets the SemanticModel for a TypeSyntax at a given position, used in Semantic Info for items not appearing in source code.
(Defined by VisualBasicExtensions.)
Public Extension MethodTryGetSpeculativeSemanticModel(Int32, TypeSyntax, SemanticModel, SpeculativeBindingOption)Overloaded.
Get a SemanticModel object that is associated with a type syntax node that did not appear in this source code. This can be used to get detailed semantic information about sub-parts of a type syntax that did not appear in source code.
(Defined by CSharpExtensions.)
Public Extension MethodTryGetSpeculativeSemanticModelForMethodBody(Int32, MethodBlockBaseSyntax, SemanticModel)Overloaded.
Gets the SemanticModel for a MethodBlockBaseSyntax at a given position, used in Semantic Info for items not appearing in source code.
(Defined by VisualBasicExtensions.)
Public Extension MethodTryGetSpeculativeSemanticModelForMethodBody(Int32, BaseMethodDeclarationSyntax, SemanticModel)Overloaded.
Get a SemanticModel object that is associated with a method body that did not appear in this source code. Given position must lie within an existing method body of the Root syntax node for this SemanticModel. Locals and labels declared within this existing method body are not considered to be in scope of the speculated method body.
(Defined by CSharpExtensions.)
Public Extension MethodTryGetSpeculativeSemanticModelForMethodBody(Int32, AccessorDeclarationSyntax, SemanticModel)Overloaded.
Get a SemanticModel object that is associated with a method body that did not appear in this source code. Given position must lie within an existing method body of the Root syntax node for this SemanticModel. Locals and labels declared within this existing method body are not considered to be in scope of the speculated method body.
(Defined by CSharpExtensions.)
Top
Remarks

An instance of SemanticModel caches local symbols and semantic information. Thus, it is much more efficient to use a single instance of SemanticModel when asking multiple questions about a syntax tree, because information from the first question may be reused. This also means that holding onto an instance of SemanticModel for a long time may keep a significant amount of memory from being garbage collected.

When an answer is a named symbol that is reachable by traversing from the root of the symbol table, (that is, from an AssemblySymbol of the Compilation), that symbol will be returned (i.e. the returned value will be reference-equal to one reachable from the root of the symbol table). Symbols representing entities without names (e.g. array-of-int) may or may not exhibit reference equality. However, some named symbols (such as local variables) are not reachable from the root. These symbols are visible as answers to semantic questions. When the same SemanticModel object is used, the answers exhibit reference-equality.

See Also