How can I get the semantic class model ( ITypeSymbol
) from ClassDeclarationSyntax
in Roslyn? From this syntax tree:
It seems to me that the only point I can use is ClassDeclaration
because the tokens seem IdentifierToken
to be unable to be passed to the method GetSymbolInfo
. But when I write
context.SemanticModel.GetSymbolInfo(classDeclaration)
result
context.SemanticModel.GetSymbolInfo(classDeclaration)
{Microsoft.CodeAnalysis.SymbolInfo}
CandidateReason: None
CandidateSymbols: Length = 0
IsEmpty: true
Symbol: null
_candidateSymbols: Length = 0
... Then no. Interestingly, the problem is that I am setting the wrong syntax element, or the problem I actually ask at the moment when I analyze the attribute of the class, and the class itself is not yet prepared.
source
share