Skip to content

Commit b8a422b

Browse files
committed
Remove code duplication in VerifyCSharpFixAsync.
1 parent dbc9e62 commit b8a422b

1 file changed

Lines changed: 2 additions & 44 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/CodeFixVerifier.cs

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -48,51 +48,9 @@ public abstract partial class CodeFixVerifier : DiagnosticVerifier
4848
/// value is less than 0, the negated value is treated as an upper limit as opposed to an exact value.</param>
4949
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that the task will observe.</param>
5050
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
51-
protected async Task VerifyCSharpFixAsync(string oldSource, string newSource, string batchNewSource = null, int? codeFixIndex = null, bool allowNewCompilerDiagnostics = false, int numberOfIncrementalIterations = DefaultNumberOfIncrementalIterations, int numberOfFixAllIterations = 1, CancellationToken cancellationToken = default(CancellationToken))
51+
protected Task VerifyCSharpFixAsync(string oldSource, string newSource, string batchNewSource = null, int? codeFixIndex = null, bool allowNewCompilerDiagnostics = false, int numberOfIncrementalIterations = DefaultNumberOfIncrementalIterations, int numberOfFixAllIterations = 1, CancellationToken cancellationToken = default(CancellationToken))
5252
{
53-
var t1 = this.VerifyFixInternalAsync(LanguageNames.CSharp, this.GetCSharpDiagnosticAnalyzers().ToImmutableArray(), this.GetCSharpCodeFixProvider(), new[] { oldSource }, new[] { newSource }, codeFixIndex, allowNewCompilerDiagnostics, numberOfIncrementalIterations, FixEachAnalyzerDiagnosticAsync, cancellationToken).ConfigureAwait(false);
54-
55-
var fixAllProvider = this.GetCSharpCodeFixProvider().GetFixAllProvider();
56-
Assert.NotEqual(WellKnownFixAllProviders.BatchFixer, fixAllProvider);
57-
58-
if (fixAllProvider == null)
59-
{
60-
await t1;
61-
}
62-
else
63-
{
64-
if (Debugger.IsAttached)
65-
{
66-
await t1;
67-
}
68-
69-
var t2 = this.VerifyFixInternalAsync(LanguageNames.CSharp, this.GetCSharpDiagnosticAnalyzers().ToImmutableArray(), this.GetCSharpCodeFixProvider(), new[] { oldSource }, new[] { batchNewSource ?? newSource }, codeFixIndex, allowNewCompilerDiagnostics, numberOfFixAllIterations, FixAllAnalyzerDiagnosticsInDocumentAsync, cancellationToken).ConfigureAwait(false);
70-
if (Debugger.IsAttached)
71-
{
72-
await t2;
73-
}
74-
75-
var t3 = this.VerifyFixInternalAsync(LanguageNames.CSharp, this.GetCSharpDiagnosticAnalyzers().ToImmutableArray(), this.GetCSharpCodeFixProvider(), new[] { oldSource }, new[] { batchNewSource ?? newSource }, codeFixIndex, allowNewCompilerDiagnostics, numberOfFixAllIterations, FixAllAnalyzerDiagnosticsInProjectAsync, cancellationToken).ConfigureAwait(false);
76-
if (Debugger.IsAttached)
77-
{
78-
await t3;
79-
}
80-
81-
var t4 = this.VerifyFixInternalAsync(LanguageNames.CSharp, this.GetCSharpDiagnosticAnalyzers().ToImmutableArray(), this.GetCSharpCodeFixProvider(), new[] { oldSource }, new[] { batchNewSource ?? newSource }, codeFixIndex, allowNewCompilerDiagnostics, numberOfFixAllIterations, FixAllAnalyzerDiagnosticsInSolutionAsync, cancellationToken).ConfigureAwait(false);
82-
if (Debugger.IsAttached)
83-
{
84-
await t4;
85-
}
86-
87-
if (!Debugger.IsAttached)
88-
{
89-
// Allow the operations to run in parallel
90-
await t1;
91-
await t2;
92-
await t3;
93-
await t4;
94-
}
95-
}
53+
return this.VerifyCSharpFixAsync(new[] { oldSource }, new[] { newSource }, batchNewSource == null ? null : new[] { batchNewSource }, codeFixIndex, allowNewCompilerDiagnostics, numberOfIncrementalIterations, numberOfFixAllIterations, cancellationToken);
9654
}
9755

9856
/// <summary>

0 commit comments

Comments
 (0)