private static async Task <Solution> FixDocumentAsync(FixAllContext fixAllContext, Document document)
        {
            Solution solution    = document.Project.Solution;
            var      diagnostics = await fixAllContext.GetDocumentDiagnosticsAsync(document).ConfigureAwait(false);

            if (diagnostics.Length == 0 || fixAllContext.CodeActionEquivalenceKey != await SA1412CodeFixProvider.GetEquivalenceKeyForDocumentAsync(document).ConfigureAwait(false))
            {
                return(solution);
            }

            return(await SA1412CodeFixProvider.GetTransformedSolutionAsync(document).ConfigureAwait(false));
        }
Example #2
0
        private static async Task <Solution> FixDocumentAsync(Solution solution, DocumentId documentId, ImmutableArray <Diagnostic> diagnostics, string codeActionEquivalenceKey, CancellationToken cancellationToken)
        {
            if (diagnostics.IsEmpty)
            {
                return(solution);
            }

            string equivalenceKey = nameof(SA1412CodeFixProvider) + "." + diagnostics[0].Properties[SA1412StoreFilesAsUtf8.EncodingProperty];

            if (codeActionEquivalenceKey != equivalenceKey)
            {
                return(solution);
            }

            Document document = solution.GetDocument(documentId);

            return(await SA1412CodeFixProvider.GetTransformedSolutionAsync(document, cancellationToken).ConfigureAwait(false));
        }
Example #3
0
        private static async Task <Solution> FixDocumentAsync(FixAllContext fixAllContext, Document document)
        {
            Solution solution    = document.Project.Solution;
            var      diagnostics = await fixAllContext.GetDocumentDiagnosticsAsync(document).ConfigureAwait(false);

            if (diagnostics.Length == 0)
            {
                return(solution);
            }

            string equivalenceKey = nameof(SA1412CodeFixProvider) + "." + diagnostics[0].Properties[SA1412StoreFilesAsUtf8.EncodingProperty];

            if (fixAllContext.CodeActionEquivalenceKey != equivalenceKey)
            {
                return(solution);
            }

            return(await SA1412CodeFixProvider.GetTransformedSolutionAsync(document, fixAllContext.CancellationToken).ConfigureAwait(false));
        }