예제 #1
0
        private void AnalyzeClassDeclaration(SyntaxNodeAnalysisContext context, INamedTypeSymbol packageType)
        {
            var            declaration = (ClassDeclarationSyntax)context.Node;
            BaseTypeSyntax baseType    = declaration.BaseList?.Types.FirstOrDefault();

            if (baseType == null)
            {
                return;
            }

            SymbolInfo baseTypeSymbol = context.SemanticModel.GetSymbolInfo(baseType.Type, context.CancellationToken);

            if (baseTypeSymbol.Symbol?.OriginalDefinition == packageType.OriginalDefinition)
            {
                context.ReportDiagnostic(Diagnostic.Create(
                                             Descriptor,
                                             baseType.GetLocation()));
            }
        }
        private void AnalyzeSyntaxNode(SyntaxNodeAnalysisContext context)
        {
            if (GeneratedCodeAnalyzer?.IsGeneratedCode(context) == true)
            {
                return;
            }

            var enumDeclaration = (EnumDeclarationSyntax)context.Node;

            AnalyzeStatements(context, enumDeclaration);

            BaseTypeSyntax baseType = GetRedundantBaseType(context, enumDeclaration);

            if (baseType != null)
            {
                context.ReportDiagnostic(
                    DiagnosticDescriptors.RemoveEnumDefaultUnderlyingType,
                    baseType.GetLocation());
            }
        }
예제 #3
0
        public static void Analyze(SyntaxNodeAnalysisContext context, EnumDeclarationSyntax enumDeclaration)
        {
            BaseTypeSyntax baseType = GetRedundantBaseType(context, enumDeclaration);

            if (baseType != null)
            {
                context.ReportDiagnostic(DiagnosticDescriptors.RemoveEnumDefaultUnderlyingType, baseType.GetLocation());
            }
        }
예제 #4
0
 public static Diagnostic CreateGA0025(BaseTypeSyntax baseTypeNode)
 {
     return(Diagnostic.Create(Instance[0025], baseTypeNode?.GetLocation()));
 }