Пример #1
0
        protected override ImmutableArray <Diagnostic> AnalyzeCodeBlock(CodeBlockAnalysisContext context)
        {
            var semanticModel     = context.SemanticModel;
            var cancellationToken = context.CancellationToken;

            var options = context.GetCSharpAnalyzerOptions().GetSimplifierOptions();

            using var simplifier = new TypeSyntaxSimplifierWalker(this, semanticModel, options, ignoredSpans: null, cancellationToken);
            simplifier.Visit(context.CodeBlock);
            return(simplifier.Diagnostics);
        }
        protected override ImmutableArray <Diagnostic> AnalyzeCodeBlock(CodeBlockAnalysisContext context)
        {
            var semanticModel     = context.SemanticModel;
            var cancellationToken = context.CancellationToken;

            var syntaxTree = semanticModel.SyntaxTree;
            var optionSet  = context.Options.GetAnalyzerOptionSet(syntaxTree, cancellationToken);
            var simplifier = new TypeSyntaxSimplifierWalker(this, semanticModel, optionSet, ignoredSpans: null, cancellationToken);

            simplifier.Visit(context.CodeBlock);
            return(simplifier.Diagnostics);
        }
Пример #3
0
        protected override ImmutableArray <Diagnostic> AnalyzeSemanticModel(SemanticModelAnalysisContext context, SimpleIntervalTree <TextSpan, TextSpanIntervalIntrospector>?codeBlockIntervalTree)
        {
            var semanticModel     = context.SemanticModel;
            var cancellationToken = context.CancellationToken;

            var options = context.GetCSharpAnalyzerOptions().GetSimplifierOptions();
            var root    = semanticModel.SyntaxTree.GetRoot(cancellationToken);

            var simplifier = new TypeSyntaxSimplifierWalker(this, semanticModel, options, ignoredSpans: codeBlockIntervalTree, cancellationToken);

            simplifier.Visit(root);
            return(simplifier.Diagnostics);
        }
        protected override void AnalyzeSemanticModel(SemanticModelAnalysisContext context)
        {
            var semanticModel     = context.SemanticModel;
            var cancellationToken = context.CancellationToken;

            var syntaxTree = semanticModel.SyntaxTree;
            var options    = context.Options;
            var optionSet  = options.GetDocumentOptionSetAsync(syntaxTree, cancellationToken).GetAwaiter().GetResult() !;
            var root       = syntaxTree.GetRoot(cancellationToken);

            var simplifier = new TypeSyntaxSimplifierWalker(this, semanticModel, optionSet, cancellationToken);

            simplifier.Visit(root);

            foreach (var diagnostic in simplifier.Diagnostics)
            {
                context.ReportDiagnostic(diagnostic);
            }
        }
Пример #5
0
        protected override void AnalyzeCodeBlock(CodeBlockAnalysisContext context)
        {
            var semanticModel     = context.SemanticModel;
            var cancellationToken = context.CancellationToken;

            var syntaxTree = semanticModel.SyntaxTree;
            var optionSet  = context.Options.GetAnalyzerOptionSet(syntaxTree, cancellationToken);
            var simplifier = new TypeSyntaxSimplifierWalker(this, semanticModel, optionSet, ignoredSpans: null, cancellationToken);

            simplifier.Visit(context.CodeBlock);
            if (!simplifier.HasDiagnostics)
            {
                return;
            }

            foreach (var diagnostic in simplifier.Diagnostics)
            {
                context.ReportDiagnostic(diagnostic);
            }
        }
Пример #6
0
        protected override void AnalyzeSemanticModel(SemanticModelAnalysisContext context, SimpleIntervalTree <TextSpan, TextSpanIntervalIntrospector>?codeBlockIntervalTree)
        {
            var semanticModel     = context.SemanticModel;
            var cancellationToken = context.CancellationToken;

            var syntaxTree = semanticModel.SyntaxTree;
            var optionSet  = context.Options.GetAnalyzerOptionSet(syntaxTree, cancellationToken);
            var root       = syntaxTree.GetRoot(cancellationToken);

            var simplifier = new TypeSyntaxSimplifierWalker(this, semanticModel, optionSet, ignoredSpans: codeBlockIntervalTree, cancellationToken);

            simplifier.Visit(root);
            if (!simplifier.HasDiagnostics)
            {
                return;
            }

            foreach (var diagnostic in simplifier.Diagnostics)
            {
                context.ReportDiagnostic(diagnostic);
            }
        }