提交 399b5120 编写于 作者: M Manish Vasani

Workaround for #31381, which seems to be causing duplicate diagnostics being passed to FixAll

上级 7c064e5d
......@@ -64,7 +64,10 @@ public sealed override async Task<CodeAction> GetFixAsync(FixAllContext fixAllCo
// Ensure that diagnostics for this document are always in document location
// order. This provides a consistent and deterministic order for fixers
// that want to update a document.
var filteredDiagnostics = diagnostics.WhereAsArray(d => _codeFixProvider.IncludeDiagnosticDuringFixAll(fixAllState, d, cancellationToken))
// Also ensure that we do not pass in duplicates by invoking Distinct.
// See https://github.com/dotnet/roslyn/issues/31381, that seems to be causing duplicate diagnostics.
var filteredDiagnostics = diagnostics.Distinct()
.WhereAsArray(d => _codeFixProvider.IncludeDiagnosticDuringFixAll(fixAllState, d, cancellationToken))
.Sort((d1, d2) => d1.Location.SourceSpan.Start - d2.Location.SourceSpan.Start);
// PERF: Do not invoke FixAllAsync on the code fix provider if there are no diagnostics to be fixed.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册