本文整理汇总了C#中INamedTypeSymbol.IsStaticHolderType方法的典型用法代码示例。如果您正苦于以下问题:C# INamedTypeSymbol.IsStaticHolderType方法的具体用法?C# INamedTypeSymbol.IsStaticHolderType怎么用?C# INamedTypeSymbol.IsStaticHolderType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类INamedTypeSymbol
的用法示例。
在下文中一共展示了INamedTypeSymbol.IsStaticHolderType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AnalyzeSymbol
protected override void AnalyzeSymbol(
INamedTypeSymbol symbol,
Compilation compilation,
Action<Diagnostic> addDiagnostic,
AnalyzerOptions options,
CancellationToken cancellationToken)
{
if (!symbol.IsStatic
&& (symbol.IsPublic() || symbol.IsProtected())
&& symbol.IsStaticHolderType())
{
addDiagnostic(symbol.CreateDiagnostic(Rule, symbol.Name));
}
}
示例2: IsOkToBeUnused
public bool IsOkToBeUnused(
INamedTypeSymbol type,
Compilation compilation,
INamedTypeSymbol systemAttributeSymbol,
INamedTypeSymbol iConfigurationSectionHandlerSymbol,
INamedTypeSymbol configurationSectionSymbol,
INamedTypeSymbol safeHandleSymbol,
INamedTypeSymbol traceListenerSymbol,
INamedTypeSymbol mef1ExportAttributeSymbol,
INamedTypeSymbol mef2ExportAttributeSymbol)
{
if (type.TypeKind != TypeKind.Class || type.IsAbstract)
{
return true;
}
// Attributes are not instantiated in IL but are created by reflection.
if (type.Inherits(systemAttributeSymbol))
{
return true;
}
// The type containing the assembly's entry point is OK.
if (ContainsEntryPoint(type, compilation))
{
return true;
}
// MEF exported classes are instantiated by MEF, by reflection.
if (IsMefExported(type, mef1ExportAttributeSymbol, mef2ExportAttributeSymbol))
{
return true;
}
// Types implementing the (deprecated) IConfigurationSectionHandler interface
// are OK because they are instantiated by the configuration system.
if (type.Inherits(iConfigurationSectionHandlerSymbol))
{
return true;
}
// Likewise for types derived from ConfigurationSection.
if (type.Inherits(configurationSectionSymbol))
{
return true;
}
// SafeHandles can be created from within the type itself by native code.
if (type.Inherits(safeHandleSymbol))
{
return true;
}
if (type.Inherits(traceListenerSymbol))
{
return true;
}
if (type.IsStaticHolderType())
{
return true;
}
return false;
}