Skip to content

Commit 5ad4358

Browse files
committed
Merge pull request #1797 from sharwell/easier-debug
Run code fixes sequentially for unit testing in the debugger
2 parents 6ede78d + 4250c63 commit 5ad4358

1 file changed

Lines changed: 29 additions & 4 deletions

File tree

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

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace TestHelper
66
using System;
77
using System.Collections.Generic;
88
using System.Collections.Immutable;
9+
using System.Diagnostics;
910
using System.Linq;
1011
using System.Threading;
1112
using System.Threading.Tasks;
@@ -87,13 +88,37 @@ public bool UseTabs
8788
}
8889
else
8990
{
91+
if (Debugger.IsAttached)
92+
{
93+
await t1;
94+
}
95+
9096
var t2 = this.VerifyFixInternalAsync(LanguageNames.CSharp, this.GetCSharpDiagnosticAnalyzers().ToImmutableArray(), this.GetCSharpCodeFixProvider(), oldSource, batchNewSource ?? newSource, codeFixIndex, allowNewCompilerDiagnostics, maxNumberOfIterations, GetFixAllAnalyzerDocumentAsync, cancellationToken).ConfigureAwait(false);
97+
if (Debugger.IsAttached)
98+
{
99+
await t2;
100+
}
101+
91102
var t3 = this.VerifyFixInternalAsync(LanguageNames.CSharp, this.GetCSharpDiagnosticAnalyzers().ToImmutableArray(), this.GetCSharpCodeFixProvider(), oldSource, batchNewSource ?? newSource, codeFixIndex, allowNewCompilerDiagnostics, maxNumberOfIterations, GetFixAllAnalyzerProjectAsync, cancellationToken).ConfigureAwait(false);
103+
if (Debugger.IsAttached)
104+
{
105+
await t3;
106+
}
107+
92108
var t4 = this.VerifyFixInternalAsync(LanguageNames.CSharp, this.GetCSharpDiagnosticAnalyzers().ToImmutableArray(), this.GetCSharpCodeFixProvider(), oldSource, batchNewSource ?? newSource, codeFixIndex, allowNewCompilerDiagnostics, maxNumberOfIterations, GetFixAllAnalyzerSolutionAsync, cancellationToken).ConfigureAwait(false);
93-
await t1;
94-
await t2;
95-
await t3;
96-
await t4;
109+
if (Debugger.IsAttached)
110+
{
111+
await t4;
112+
}
113+
114+
if (!Debugger.IsAttached)
115+
{
116+
// Allow the operations to run in parallel
117+
await t1;
118+
await t2;
119+
await t3;
120+
await t4;
121+
}
97122
}
98123
}
99124

0 commit comments

Comments
 (0)