클래스 (또는 기본 유형 중 하나)에 특정 속성이 있는지 여부를 감지하기 위해 ICodeIssueProvider
을 구현하려고합니다.기본 유형의 속성 찾기
public IEnumerable<CodeIssue> GetIssues(IDocument document,
CommonSyntaxNode node,
CancellationToken cancellationToken)
{
var methodDeclaration = (MethodDeclarationSyntax)node;
var semanticModel = document.GetSemanticModel(cancellationToken);
var methodSymbol = semanticModel.GetDeclaredSymbol(methodDeclaration);
var typeSymbol = methodSymbol.ContainingType;
// The following only gets attributes declared on this class, how to
// also include those declared on a base class ?
var attributes = typeSymbol.GetAttributes();
System.Object
에 typeSymbol.BaseType
모든 길을 걷고있는 길에 GetAttributes()
를 호출하는 것보다 더 좋은 방법이 있나요? 또한
하는 typeSymbol
가 .BaseType
를 걸어 수동
MethodDeclarationSyntax
노드를 확인하기 위해 아래의 샘플에서 분명이 없다 및 아니
ClassDeclarationSyntax
노드)