本文整理汇总了C#中INamedTypeSymbol.IsAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# INamedTypeSymbol.IsAttribute方法的具体用法?C# INamedTypeSymbol.IsAttribute怎么用?C# INamedTypeSymbol.IsAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类INamedTypeSymbol
的用法示例。
在下文中一共展示了INamedTypeSymbol.IsAttribute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AnalyzeSymbol
public override void AnalyzeSymbol(INamedTypeSymbol namedType, Compilation compilation, Action<Diagnostic> addDiagnostic, AnalyzerOptions options, CancellationToken cancellationToken)
{
if (namedType.IsAbstract || namedType.IsSealed || !namedType.IsAttribute())
{
return;
}
// Non-sealed non-abstract attribute type.
addDiagnostic(namedType.CreateDiagnostic(Rule));
}
示例2: AnalyzeSymbol
public override void AnalyzeSymbol(INamedTypeSymbol symbol, Compilation compilation, Action<Diagnostic> addDiagnostic, CancellationToken cancellationToken)
{
if (symbol != null && symbol.IsAttribute() && symbol.DeclaredAccessibility != Accessibility.Private)
{
IEnumerable<IParameterSymbol> parametersToCheck = GetAllPublicConstructorParameters(symbol);
if (parametersToCheck.Any())
{
IDictionary<string, IPropertySymbol> propertiesMap = GetAllPropertiesInTypeChain(symbol);
AnalyzeParameters(compilation, parametersToCheck, propertiesMap, symbol, addDiagnostic);
}
}
}
示例3: AnalyzeSymbol
protected override void AnalyzeSymbol(INamedTypeSymbol symbol, Compilation compilation, Action<Diagnostic> addDiagnostic, AnalyzerOptions options, CancellationToken cancellationToken)
{
var attributeUsageAttribute = WellKnownTypes.AttributeUsageAttribute(compilation);
if (attributeUsageAttribute == null)
{
return;
}
if (symbol.IsAbstract || !symbol.IsAttribute())
{
return;
}
if (attributeUsageAttribute == null)
{
return;
}
var hasAttributeUsageAttribute = symbol.GetAttributes().Any(attribute => attribute.AttributeClass == attributeUsageAttribute);
if (!hasAttributeUsageAttribute)
{
addDiagnostic(symbol.CreateDiagnostic(Rule, symbol.Name));
}
}