当前位置: 首页>>代码示例>>C#>>正文


C# INamedTypeSymbol.IsStaticHolderType方法代码示例

本文整理汇总了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));
     }
 }
开发者ID:richardlford,项目名称:roslyn-analyzers,代码行数:14,代码来源:CA1052DiagnosticAnalyzer.cs

示例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;
        }
开发者ID:bkoelman,项目名称:roslyn-analyzers,代码行数:65,代码来源:AvoidUninstantiatedInternalClasses.cs


注:本文中的INamedTypeSymbol.IsStaticHolderType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。