Exemple #1
0
        internal static ImmutableArray <Diagnostic> GetMethodBodyDiagnosticsForTree(CSharpCompilation compilation, SyntaxTree tree, TextSpan?span, CancellationToken cancellationToken)
        {
            DiagnosticBag diagnostics = DiagnosticBag.GetInstance();

            CompileMethodBodies(
                compilation: compilation,
                moduleBeingBuilt: null,
                generateDebugInfo: false,
                hasDeclarationErrors: false,
                filter: null,
                filterTree: tree,
                filterSpanWithinTree: span,
                diagnostics: diagnostics,
                cancellationToken: cancellationToken);
            DocumentationCommentCompiler.WriteDocumentationCommentXml(compilation, null, null, diagnostics, cancellationToken, tree, span);

            // Report unused directives only if computing diagnostics for the entire tree.
            // Otherwise we cannot determine if a particular directive is used outside of the given sub-span within the tree.
            if (!span.HasValue || span.Value == tree.GetRoot(cancellationToken).FullSpan)
            {
                compilation.ReportUnusedImports(diagnostics, cancellationToken, tree);
            }

            return(diagnostics.ToReadOnlyAndFree());
        }
 // Do the steps in compilation to get the method body diagnostics, but don't actually generate
 // IL or emit an assembly.
 public static ImmutableArray<Diagnostic> GetAllMethodBodyDiagnostics(CSharpCompilation compilation, CancellationToken cancellationToken)
 {
     DiagnosticBag diagnostics = DiagnosticBag.GetInstance();
     CompileMethodBodies(
         compilation: compilation, 
         moduleBeingBuilt: null, 
         generateDebugInfo: false, 
         hasDeclarationErrors: false, 
         filter: null, 
         filterTree: null, 
         filterSpanWithinTree: null,
         diagnostics: diagnostics, 
         cancellationToken: cancellationToken);
     DocumentationCommentCompiler.WriteDocumentationCommentXml(compilation, null, null, diagnostics, cancellationToken);
     compilation.ReportUnusedImports(diagnostics, cancellationToken);
     return diagnostics.ToReadOnlyAndFree();
 }
Exemple #3
0
        // Do the steps in compilation to get the method body diagnostics, but don't actually generate
        // IL or emit an assembly.
        public static ImmutableArray <Diagnostic> GetAllMethodBodyDiagnostics(CSharpCompilation compilation, CancellationToken cancellationToken)
        {
            DiagnosticBag diagnostics = DiagnosticBag.GetInstance();

            CompileMethodBodies(
                compilation: compilation,
                moduleBeingBuilt: null,
                generateDebugInfo: false,
                hasDeclarationErrors: false,
                filter: null,
                filterTree: null,
                filterSpanWithinTree: null,
                diagnostics: diagnostics,
                cancellationToken: cancellationToken);
            DocumentationCommentCompiler.WriteDocumentationCommentXml(compilation, null, null, diagnostics, cancellationToken);
            compilation.ReportUnusedImports(diagnostics, cancellationToken);
            return(diagnostics.ToReadOnlyAndFree());
        }
        internal static ImmutableArray<Diagnostic> GetMethodBodyDiagnosticsForTree(CSharpCompilation compilation, SyntaxTree tree, TextSpan? span, CancellationToken cancellationToken)
        {
            DiagnosticBag diagnostics = DiagnosticBag.GetInstance();
            CompileMethodBodies(
                compilation: compilation,
                moduleBeingBuilt: null,
                generateDebugInfo: false,
                hasDeclarationErrors: false,
                filter: null,
                filterTree: tree,
                filterSpanWithinTree: span,
                diagnostics: diagnostics,
                cancellationToken: cancellationToken);
            DocumentationCommentCompiler.WriteDocumentationCommentXml(compilation, null, null, diagnostics, cancellationToken, tree, span);

            // Report unused directives only if computing diagnostics for the entire tree.
            // Otherwise we cannot determine if a particular directive is used outside of the given sub-span within the tree.
            if (!span.HasValue || span.Value == tree.GetRoot(cancellationToken).FullSpan)
            {
                compilation.ReportUnusedImports(diagnostics, cancellationToken, tree);
            }

            return diagnostics.ToReadOnlyAndFree();
        }