public static ITypeSymbol TryGetItemTypeForSequenceOrCollection([NotNull] this ITypeSymbol typeSymbol, [NotNull] FrameworkTypeCache typeCache) { Guard.NotNull(typeSymbol, nameof(typeSymbol)); Guard.NotNull(typeCache, nameof(typeCache)); var namedTypeSymbol = typeSymbol as INamedTypeSymbol; if (typeCache.EnumerableOfT != null) { foreach (INamedTypeSymbol type in typeSymbol.AllInterfaces.PrependIfNotNull(namedTypeSymbol)) { if (typeCache.EnumerableOfT.Equals(type.ConstructedFrom)) { return(type.TypeArguments.Single()); } } } if (typeCache.Enumerable != null) { if (typeSymbol.AllInterfaces.PrependIfNotNull(namedTypeSymbol).Any(type => typeCache.Enumerable.Equals(type))) { if (!typeSymbol.Equals(typeCache.String)) { return(typeCache.Object); } } } return(null); }
public static bool HasResharperConditionalAnnotation([NotNull] this ISymbol symbol, [NotNull] FrameworkTypeCache typeCache) { Guard.NotNull(symbol, nameof(symbol)); Guard.NotNull(typeCache, nameof(typeCache)); ImmutableArray <AttributeData> attributes = symbol.ContainingType.GetAttributes(); return(attributes.Any(attr => IsResharperConditionalAttribute(attr, typeCache))); }
public SymbolAnalyzerFactory([NotNull] IExternalAnnotationsResolver externalAnnotations, [NotNull] GeneratedCodeDocumentCache generatedCodeCache, [NotNull] FrameworkTypeCache typeCache, bool appliesToItem) { Guard.NotNull(externalAnnotations, nameof(externalAnnotations)); Guard.NotNull(generatedCodeCache, nameof(generatedCodeCache)); Guard.NotNull(typeCache, nameof(typeCache)); this.externalAnnotations = externalAnnotations; this.generatedCodeCache = generatedCodeCache; this.typeCache = typeCache; this.appliesToItem = appliesToItem; }
public SymbolAnalyzerFactory([NotNull] IExternalAnnotationsResolver externalAnnotations, [NotNull] GeneratedCodeDocumentCache generatedCodeCache, [NotNull] FrameworkTypeCache typeCache, bool appliesToItem) { Guard.NotNull(externalAnnotations, nameof(externalAnnotations)); Guard.NotNull(generatedCodeCache, nameof(generatedCodeCache)); Guard.NotNull(typeCache, nameof(typeCache)); this.externalAnnotations = externalAnnotations; this.generatedCodeCache = generatedCodeCache; this.typeCache = typeCache; this.appliesToItem = appliesToItem; }
private static bool IsResharperConditionalAttribute([NotNull] AttributeData attribute, [NotNull] FrameworkTypeCache typeCache) { if (typeCache.ConditionalAttribute != null) { if (typeCache.ConditionalAttribute.Equals(attribute.AttributeClass)) { object ctorValue = attribute.ConstructorArguments.First().Value; return((string)ctorValue == "JETBRAINS_ANNOTATIONS"); } } return(false); }
public static bool HasDebuggerNonUserCodeAnnotation([NotNull] this ISymbol memberSymbol, [NotNull] FrameworkTypeCache typeCache) { Guard.NotNull(memberSymbol, nameof(memberSymbol)); Guard.NotNull(typeCache, nameof(typeCache)); if (typeCache.DebuggerNonUserCodeAttribute != null) { ImmutableArray <AttributeData> attributes = memberSymbol.GetAttributes(); return(attributes.Any(attr => typeCache.DebuggerNonUserCodeAttribute.Equals(attr.AttributeClass))); } return(false); }
protected BaseSymbolAnalyzer(SymbolAnalysisContext context, [NotNull] IExternalAnnotationsResolver externalAnnotations, [NotNull] GeneratedCodeDocumentCache generatedCodeCache, [NotNull] FrameworkTypeCache typeCache, bool appliesToItem) { Guard.NotNull(externalAnnotations, nameof(externalAnnotations)); Guard.NotNull(generatedCodeCache, nameof(generatedCodeCache)); Guard.NotNull(typeCache, nameof(typeCache)); this.context = context; this.externalAnnotations = externalAnnotations; this.generatedCodeCache = generatedCodeCache; this.typeCache = typeCache; AppliesToItem = appliesToItem; Symbol = (TSymbol)context.Symbol; }
public AnalysisScope([NotNull] IExternalAnnotationsResolver externalAnnotations, [NotNull] GeneratedCodeDocumentCache generatedCodeCache, [NotNull] FrameworkTypeCache typeCache, [NotNull] AnalyzerSettings settings, [NotNull] DiagnosticDescriptor disableReportOnNullableValueTypesRule, bool appliesToItem) { Guard.NotNull(externalAnnotations, nameof(externalAnnotations)); Guard.NotNull(generatedCodeCache, nameof(generatedCodeCache)); Guard.NotNull(typeCache, nameof(typeCache)); Guard.NotNull(settings, nameof(settings)); Guard.NotNull(disableReportOnNullableValueTypesRule, nameof(disableReportOnNullableValueTypesRule)); ExternalAnnotations = externalAnnotations; GeneratedCodeCache = generatedCodeCache; TypeCache = typeCache; Settings = settings; DisableReportOnNullableValueTypesRule = disableReportOnNullableValueTypesRule; AppliesToItem = appliesToItem; }
public static ITypeSymbol TryGetItemTypeForLazyOrGenericTask([NotNull] this ITypeSymbol typeSymbol, [NotNull] FrameworkTypeCache typeCache) { Guard.NotNull(typeSymbol, nameof(typeSymbol)); Guard.NotNull(typeCache, nameof(typeCache)); var namedTypeSymbol = typeSymbol as INamedTypeSymbol; if (namedTypeSymbol?.ConstructedFrom != null) { bool isMatch = namedTypeSymbol.ConstructedFrom.Equals(typeCache.LazyOfT) || namedTypeSymbol.ConstructedFrom.Equals(typeCache.TaskOfT); if (isMatch) { return(namedTypeSymbol.TypeArguments.Single()); } } return(null); }
public MethodReturnValueAnalyzer(SymbolAnalysisContext context, [NotNull] IExternalAnnotationsResolver externalAnnotations, [NotNull] GeneratedCodeDocumentCache generatedCodeCache, [NotNull] FrameworkTypeCache typeCache, bool appliesToItem) : base(context, externalAnnotations, generatedCodeCache, typeCache, appliesToItem) { }