本文整理汇总了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);
}
}
}
示例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));
}
示例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));
}
}
示例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;
}
示例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));
}