Esempio n. 1
0
        private static async Task <bool> HasNewAnalyzerDiagnosticsAsync(string originalDocument, string updatedDocument, string diagnosticId)
        {
            using var workspace = TestUtils.CreateSingleDocumentWorkspace(originalDocument, out var document);

            var comparer = new SolutionDiagnosticsComparer(document.Project.Solution);

            return(await comparer.HasNewAnalyzerDiagnosticsAsync(document.WithText(
                                                                     SourceText.From(updatedDocument)),
                                                                 diagnosticIdFilter : ImmutableArray.Create(diagnosticId),
                                                                 CancellationToken.None).ConfigureAwait(false));
        }
        private static async Task <string> FixAllInSingleDocumentWorkspaceAsync(string documentText)
        {
            using var workspace = TestUtils.CreateSingleDocumentWorkspace(documentText, out var document);

            var comparer = new SolutionDiagnosticsComparer(document.Project.Solution);

            var fixedDocument = await SuppressionFixer.FixAllInDocumentAsync(document, comparer, afterRemoval : _ => { }, CancellationToken.None);

            var fixedText = await fixedDocument.GetTextAsync();

            return(fixedText.ToString());
        }