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


C# INamedTypeSymbol.GetBaseTypesAndThis方法代码示例

本文整理汇总了C#中INamedTypeSymbol.GetBaseTypesAndThis方法的典型用法代码示例。如果您正苦于以下问题:C# INamedTypeSymbol.GetBaseTypesAndThis方法的具体用法?C# INamedTypeSymbol.GetBaseTypesAndThis怎么用?C# INamedTypeSymbol.GetBaseTypesAndThis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在INamedTypeSymbol的用法示例。


在下文中一共展示了INamedTypeSymbol.GetBaseTypesAndThis方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AnalyzeSymbol

 private void AnalyzeSymbol(INamedTypeSymbol symbol, INamedTypeSymbol attributeType, Compilation compilation, Action<Diagnostic> addDiagnostic)
 {
     if (symbol != null && symbol.GetBaseTypesAndThis().Contains(WellKnownTypes.Attribute(compilation)) && symbol.DeclaredAccessibility != Accessibility.Private)
     {
         IEnumerable<IParameterSymbol> parametersToCheck = GetAllPublicConstructorParameters(symbol);
         if (parametersToCheck.Any())
         {
             IDictionary<string, IPropertySymbol> propertiesMap = GetAllPropertiesInTypeChain(symbol);
             AnalyzeParameters(compilation, parametersToCheck, propertiesMap, symbol, addDiagnostic);
         }
     }
 }
开发者ID:GloryChou,项目名称:roslyn,代码行数:12,代码来源:DefineAccessorsForAttributeArguments.cs

示例2: AnalyzeSymbol

        private static void AnalyzeSymbol(INamedTypeSymbol namedType, INamedTypeSymbol attributeType, Action<Diagnostic> addDiagnostic)
        {
            if (namedType.IsAbstract || namedType.IsSealed || !namedType.GetBaseTypesAndThis().Contains(attributeType))
            {
                return;
            }

            // Non-sealed non-abstract attribute type.
            addDiagnostic(namedType.CreateDiagnostic(Rule));
        }
开发者ID:duracellko,项目名称:roslyn-analyzers,代码行数:10,代码来源:AvoidUnsealedAttributes.cs

示例3: AnalyzeSymbol

        private static void AnalyzeSymbol(INamedTypeSymbol symbol, INamedTypeSymbol attributeType, INamedTypeSymbol attributeUsageAttributeType, Action<Diagnostic> addDiagnostic)
        {
            if (symbol.IsAbstract || !symbol.GetBaseTypesAndThis().Contains(attributeType))
            {
                return;
            }

            bool hasAttributeUsageAttribute = symbol.GetAttributes().Any(attribute => attribute.AttributeClass.Equals(attributeUsageAttributeType));
            if (!hasAttributeUsageAttribute)
            {
                addDiagnostic(symbol.CreateDiagnostic(Rule, symbol.Name));
            }
        }
开发者ID:bkoelman,项目名称:roslyn-analyzers,代码行数:13,代码来源:MarkAttributesWithAttributeUsage.cs

示例4: GetAllPropertiesInTypeChain

        private static IDictionary<string, IPropertySymbol> GetAllPropertiesInTypeChain(INamedTypeSymbol attributeType)
        {
            var propertiesMap = new Dictionary<string, IPropertySymbol>(StringComparer.OrdinalIgnoreCase);
            foreach (var currentType in attributeType.GetBaseTypesAndThis())
            {
                foreach (IPropertySymbol property in currentType.GetMembers().Where(m => m.Kind == SymbolKind.Property))
                {
                    if (!propertiesMap.ContainsKey(property.Name))
                    {
                        propertiesMap.Add(property.Name, property);
                    }
                }
            }

            return propertiesMap;
        }
开发者ID:riversky,项目名称:roslyn,代码行数:16,代码来源:CA1019DiagnosticAnalyzer.cs

示例5: HasVisibleAlternate

        private static bool HasVisibleAlternate(INamedTypeSymbol namedType, IMethodSymbol interfaceMethod, INamedTypeSymbol iDisposableTypeSymbol)
        {
            foreach (INamedTypeSymbol type in namedType.GetBaseTypesAndThis())
            {
                foreach (IMethodSymbol method in type.GetMembers(interfaceMethod.Name).OfType<IMethodSymbol>())
                {
                    if (method.GetResultantVisibility() == SymbolVisibility.Public)
                    {
                        return true;
                    }
                }
            }

            // This rule does not report a violation for an explicit implementation of IDisposable.Dispose when an externally visible Close() or System.IDisposable.Dispose(Boolean) method is provided.
            return interfaceMethod.Equals("Dispose") &&
                interfaceMethod.ContainingType.Equals(iDisposableTypeSymbol) &&
                namedType.GetBaseTypesAndThis().Any(t =>
                    t.GetMembers("Close").OfType<IMethodSymbol>().Any(m =>
                        m.GetResultantVisibility() == SymbolVisibility.Public));
        }
开发者ID:Anniepoh,项目名称:roslyn-analyzers,代码行数:20,代码来源:InterfaceMethodsShouldBeCallableByChildTypes.cs


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