private static void AnalyzeSymbol(SymbolAnalysisContext context)
        {
            var propertySymbol = (IPropertySymbol)context.Symbol;

            // need to discover if containing type is a glass interface factory type
            var parentType = propertySymbol.ContainingType;

            if (!GlassFactoryAnalyzerUtil.IsTypeGlassFactoryType(parentType) ||
                propertySymbol.IsAbstract ||
                !IsDefaultGetProperty(propertySymbol))
            {
                return;
            }

            // We're a valid analysis target
            foreach (var location in propertySymbol.Locations)
            {
                var diagnostic = Diagnostic.Create(Rule, location, propertySymbol.Name);
                context.ReportDiagnostic(diagnostic);
            }
        }
示例#2
0
        private static void AnalyzeSymbol(SymbolAnalysisContext context)
        {
            var namedTypeSymbol = (INamedTypeSymbol)context.Symbol;

            // need to find out if Attribute is assigned to class
            var attribute = context.Symbol.GetAttributes().FirstOrDefault(IsGlassFactoryTypeAttribute);

            // Are we a valid analysis target?
            if (attribute == null || !GlassFactoryAnalyzerUtil.InheritsBaseInterfaceClass(namedTypeSymbol) ||
                DoesAttributeTypeMatchBaseInterfaceGenericType(attribute, namedTypeSymbol, context.Compilation))
            {
                return;
            }

            // We're a valid analysis target
            foreach (var location in namedTypeSymbol.Locations)
            {
                var diagnostic = Diagnostic.Create(Rule, location, namedTypeSymbol.Name);
                context.ReportDiagnostic(diagnostic);
            }
        }