共用方式為


ModelExtensions.GetDeclaredSymbol 方法

定義

取得與宣告語法節點相關聯的符號。

public static Microsoft.CodeAnalysis.ISymbol GetDeclaredSymbol (this Microsoft.CodeAnalysis.SemanticModel semanticModel, Microsoft.CodeAnalysis.SyntaxNode declaration, System.Threading.CancellationToken cancellationToken = default);
public static Microsoft.CodeAnalysis.ISymbol? GetDeclaredSymbol (this Microsoft.CodeAnalysis.SemanticModel semanticModel, Microsoft.CodeAnalysis.SyntaxNode declaration, System.Threading.CancellationToken cancellationToken = default);
static member GetDeclaredSymbol : Microsoft.CodeAnalysis.SemanticModel * Microsoft.CodeAnalysis.SyntaxNode * System.Threading.CancellationToken -> Microsoft.CodeAnalysis.ISymbol
<Extension()>
Public Function GetDeclaredSymbol (semanticModel As SemanticModel, declaration As SyntaxNode, Optional cancellationToken As CancellationToken = Nothing) As ISymbol

參數

semanticModel
SemanticModel
declaration
SyntaxNode

屬於宣告的語法節點。 這可以是衍生自 MemberDeclarationSyntax、TypeDeclarationSyntax、EnumDeclarationSyntax、NamespaceDeclarationSyntax、ParameterSyntax、TypeParameterSyntax 或 UsingDirectiveSyntax 的別名部分的任何類型

cancellationToken
CancellationToken

取消語彙基元。

傳回

節點所宣告的符號,如果節點不是宣告,則為 null。

適用於