提交 d7962505 编写于 作者: A angocke

Add missing ConfigureAwait(false)'s to the compiler . (changeset 1277353)

上级 03758376
......@@ -438,7 +438,7 @@ private async Task MonitorPipeForDisconnectionAsync(PipeStream pipeStream, Cance
}
CompilerServerLogger.Log("After poking pipe.");
// Wait a hundredth of a second before trying again
await Task.Delay(10);
await Task.Delay(10).ConfigureAwait(false);
}
if (!cancellationToken.IsCancellationRequested)
......
......@@ -51,7 +51,7 @@ public AnalyzerDriver3(IDiagnosticAnalyzer[] analyzers, Func<SyntaxNode, TSyntax
initialWorker = Task.Run(async () => {
try
{
await InitialWorker(analyzers, continueOnError, cancellationToken);
await InitialWorker(analyzers, continueOnError, cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException)
{
......@@ -90,7 +90,7 @@ public async Task<ImmutableArray<Diagnostic>> DiagnosticsAsync()
{
var q = DiagnosticQueue;
var allDiagnostics = DiagnosticBag.GetInstance();
await q.WhenCompleted;
await q.WhenCompleted.ConfigureAwait(false);
Diagnostic d;
while (q.TryDequeue(out d))
{
......@@ -108,10 +108,10 @@ public async Task<ImmutableArray<Diagnostic>> DiagnosticsAsync()
/// <returns></returns>
public async Task WhenCompleted()
{
await CompilationEventQueue.WhenCompleted;
await CompilationEventQueue.WhenCompleted.ConfigureAwait(false);
foreach (var worker in workers)
{
await worker;
await worker.ConfigureAwait(false);
}
}
......@@ -124,7 +124,7 @@ public void Dispose()
private async Task InitialWorker(IDiagnosticAnalyzer[] analyzers, bool continueOnError, CancellationToken cancellationToken)
{
// Pull out the first event, which should be the "start compilation" event.
var firstEvent = await CompilationEventQueue.DequeueAsync(/*cancellationToken*/);
var firstEvent = await CompilationEventQueue.DequeueAsync(/*cancellationToken*/).ConfigureAwait(false);
var startCompilation = firstEvent as CompilationEvent.CompilationStarted;
if (startCompilation == null)
{
......@@ -135,7 +135,7 @@ private async Task InitialWorker(IDiagnosticAnalyzer[] analyzers, bool continueO
DiagnosticQueue.Complete();
while (CompilationEventQueue.Count != 0)
{
var drainedEvent = await CompilationEventQueue.DequeueAsync();
var drainedEvent = await CompilationEventQueue.DequeueAsync().ConfigureAwait(false);
}
throw new InvalidOperationException("First event must be CompilationEvent.CompilationStarted, not " + startCompilation.GetType().Name);
}
......@@ -227,7 +227,7 @@ private async void ProcessCompilationEvents(CancellationToken cancellationToken)
{
try
{
await ProcessEvents(cancellationToken);
await ProcessEvents(cancellationToken).ConfigureAwait(false);
}
catch (TaskCanceledException)
{
......@@ -242,8 +242,8 @@ private async Task ProcessEvents(CancellationToken cancellationToken)
{
try
{
var e = await CompilationEventQueue.DequeueAsync(/*cancellationToken*/);
await ProcessEvent(e, cancellationToken);
var e = await CompilationEventQueue.DequeueAsync(/*cancellationToken*/).ConfigureAwait(false);
await ProcessEvent(e, cancellationToken).ConfigureAwait(false);
}
catch (TaskCanceledException)
{
......@@ -264,21 +264,21 @@ private async Task ProcessEvent(CompilationEvent e, CancellationToken cancellati
var symbolEvent = e as CompilationEvent.SymbolDeclared;
if (symbolEvent != null)
{
await ProcessSymbolDeclared(symbolEvent, cancellationToken);
await ProcessSymbolDeclared(symbolEvent, cancellationToken).ConfigureAwait(false);
return;
}
var completedEvent = e as CompilationEvent.CompilationUnitCompleted;
if (completedEvent != null)
{
await ProcessCompilationUnitCompleted(completedEvent, cancellationToken);
await ProcessCompilationUnitCompleted(completedEvent, cancellationToken).ConfigureAwait(false);
return;
}
var endEvent = e as CompilationEvent.CompilationCompleted;
if (endEvent != null)
{
await ProcessCompilationCompleted(endEvent, cancellationToken);
await ProcessCompilationCompleted(endEvent, cancellationToken).ConfigureAwait(false);
return;
}
......@@ -339,7 +339,7 @@ private Task AnalyzeSymbol(CompilationEvent.SymbolDeclared symbolEvent, Cancella
private async Task AnalyzeDeclaringReference(CompilationEvent.SymbolDeclared symbolEvent, SyntaxReference decl, Action<Diagnostic> addDiagnostic, CancellationToken cancellationToken)
{
var symbol = symbolEvent.Symbol;
var syntax = await decl.GetSyntaxAsync();
var syntax = await decl.GetSyntaxAsync().ConfigureAwait(false);
var endedAnalyzers = ArrayBuilder<ICodeBlockEndedAnalyzer>.GetInstance();
endedAnalyzers.AddRange(CodeBlockEndedAnalyzers);
var nodeAnalyzers = ArrayBuilder<ISyntaxNodeAnalyzer<TSyntaxKind>>.GetInstance();
......@@ -471,7 +471,7 @@ private async Task ProcessCompilationCompleted(CompilationEvent.CompilationCompl
foreach (var task in tasks)
{
await task;
await task.ConfigureAwait(false);
}
DiagnosticQueue.Complete();
......
......@@ -65,7 +65,7 @@ public async Task ServeConnection()
try
{
Log("Begin reading request");
request = await BuildRequest.ReadAsync(pipeStream, cancellationTokenSource.Token);
request = await BuildRequest.ReadAsync(pipeStream, cancellationTokenSource.Token).ConfigureAwait(false);
Log("End reading request");
}
catch (IOException e)
......@@ -103,14 +103,14 @@ public async Task ServeConnection()
{
throw ExceptionUtilities.Unreachable;
}
});
}).ConfigureAwait(false);
Log("End compilation");
try
{
Log("Begin writing response");
await response.WriteAsync(pipeStream, cancellationTokenSource.Token);
await response.WriteAsync(pipeStream, cancellationTokenSource.Token).ConfigureAwait(false);
Log("End writing response");
}
catch (IOException e)
......@@ -152,7 +152,7 @@ private async Task MonitorPipeForDisconnection()
}
Log("After poking pipe.");
// Wait a tenth of a second before trying again
await Task.Delay(100);
await Task.Delay(100).ConfigureAwait(false);
}
Log("Pipe disconnected; cancelling.");
......
......@@ -85,7 +85,7 @@ public partial class FindAllDeclarationsTests : TestBase
public static async Task FindDeclarationsAsync_Test(string searchTerm, bool ignoreCase, WorkspaceKind workspaceKind, string[] expectedResults)
{
var project = GetProject(workspaceKind);
var declarations = await SymbolFinder.FindDeclarationsAsync(project, searchTerm, ignoreCase);
var declarations = await SymbolFinder.FindDeclarationsAsync(project, searchTerm, ignoreCase).ConfigureAwait(false);
Verify(searchTerm, ignoreCase, workspaceKind, declarations, expectedResults);
}
......@@ -200,7 +200,7 @@ public static void FindDeclarationsAsync_Test_Cancellation()
public static async Task FindSourceDeclarationsAsync_Project_Test(string searchTerm, bool ignoreCase, WorkspaceKind workspaceKind, string[] expectedResults)
{
var project = GetProject(workspaceKind);
var declarations = await SymbolFinder.FindSourceDeclarationsAsync(project, searchTerm, ignoreCase);
var declarations = await SymbolFinder.FindSourceDeclarationsAsync(project, searchTerm, ignoreCase).ConfigureAwait(false);
Verify(searchTerm, ignoreCase, workspaceKind, declarations, expectedResults);
}
......@@ -315,7 +315,7 @@ public static void FindSourceDeclarationsAsync_Project_Test_Cancellation()
public static async Task FindSourceDeclarationsAsync_Solution_Test(string searchTerm, bool ignoreCase, WorkspaceKind workspaceKind, string[] expectedResults)
{
var solution = GetSolution(workspaceKind);
var declarations = await SymbolFinder.FindSourceDeclarationsAsync(solution, searchTerm, ignoreCase);
var declarations = await SymbolFinder.FindSourceDeclarationsAsync(solution, searchTerm, ignoreCase).ConfigureAwait(false);
Verify(searchTerm, ignoreCase, workspaceKind, declarations, expectedResults);
}
......@@ -375,7 +375,7 @@ public static void FindSourceDeclarationsAsync_Solution_Test_Cancellation()
public static async Task FindSourceDeclarationsAsync_Project_Func_Test(WorkspaceKind workspaceKind, string[] expectedResults)
{
var project = GetProject(workspaceKind);
var declarations = await SymbolFinder.FindSourceDeclarationsAsync(project, str => str.Contains("Test"));
var declarations = await SymbolFinder.FindSourceDeclarationsAsync(project, str => str.Contains("Test")).ConfigureAwait(false);
Verify(workspaceKind, declarations, expectedResults);
}
......@@ -383,7 +383,7 @@ public static async Task FindSourceDeclarationsAsync_Project_Func_Test(Workspace
public static async Task FindSourceDeclarationsAsync_Project_Func_Test_AlwaysTruePredicate()
{
var project = GetProject(WorkspaceKind.SingleClass);
var declarations = await SymbolFinder.FindSourceDeclarationsAsync(project, str => true);
var declarations = await SymbolFinder.FindSourceDeclarationsAsync(project, str => true).ConfigureAwait(false);
Verify(WorkspaceKind.SingleClass, declarations, "TestCases", "TestCases.TestCase");
}
......@@ -391,7 +391,7 @@ public static async Task FindSourceDeclarationsAsync_Project_Func_Test_AlwaysTru
public static async Task FindSourceDeclarationsAsync_Project_Func_Test_AlwaysFalsePredicate()
{
var project = GetProject(WorkspaceKind.SingleClass);
var declarations = await SymbolFinder.FindSourceDeclarationsAsync(project, str => false);
var declarations = await SymbolFinder.FindSourceDeclarationsAsync(project, str => false).ConfigureAwait(false);
Verify(WorkspaceKind.SingleClass, declarations);
}
......@@ -467,7 +467,7 @@ public static void FindSourceDeclarationsAsync_Project_Func_Test_Cancellation()
public static async Task FindSourceDeclarationsAsync_Solution_Func_Test(WorkspaceKind workspaceKind, string[] expectedResult)
{
var solution = GetSolution(workspaceKind);
var declarations = await SymbolFinder.FindSourceDeclarationsAsync(solution, str => str.Contains("Test"));
var declarations = await SymbolFinder.FindSourceDeclarationsAsync(solution, str => str.Contains("Test")).ConfigureAwait(false);
Verify(workspaceKind, declarations, expectedResult);
}
......@@ -475,7 +475,7 @@ public static async Task FindSourceDeclarationsAsync_Solution_Func_Test(Workspac
public static async Task FindSourceDeclarationsAsync_Solution_Func_Test_AlwaysTruePredicate()
{
var solution = GetSolution(WorkspaceKind.SingleClass);
var declarations = await SymbolFinder.FindSourceDeclarationsAsync(solution, str => true);
var declarations = await SymbolFinder.FindSourceDeclarationsAsync(solution, str => true).ConfigureAwait(false);
Verify(WorkspaceKind.SingleClass, declarations, "TestCases", "TestCases.TestCase");
}
......@@ -483,7 +483,7 @@ public static async Task FindSourceDeclarationsAsync_Solution_Func_Test_AlwaysTr
public static async Task FindSourceDeclarationsAsync_Solution_Func_Test_AlwaysFalsePredicate()
{
var solution = GetSolution(WorkspaceKind.SingleClass);
var declarations = await SymbolFinder.FindSourceDeclarationsAsync(solution, str => false);
var declarations = await SymbolFinder.FindSourceDeclarationsAsync(solution, str => false).ConfigureAwait(false);
Verify(WorkspaceKind.SingleClass, declarations);
}
......
......@@ -38,7 +38,7 @@ public async Task TestEnqueueStoreAsync()
var tree = CSharp.SyntaxFactory.SyntaxTree(root);
// EnqueueStore and EnqueueStoreAsync is basically same thing. only difference is EnqueueStoreAsync returns Task that can be waited.
await syntaxTreeStorageService.EnqueueStoreAsync(tree, root, tempStorageService, CancellationToken.None);
await syntaxTreeStorageService.EnqueueStoreAsync(tree, root, tempStorageService, CancellationToken.None).ConfigureAwait(false);
Assert.True(syntaxTreeStorageService.CanRetrieve(tree));
}
......@@ -67,7 +67,7 @@ public async Task TestStoreAsync()
var root = CSharp.SyntaxFactory.CompilationUnit();
var tree = CSharp.SyntaxFactory.SyntaxTree(root);
await syntaxTreeStorageService.StoreAsync(tree, root, tempStorageService, CancellationToken.None);
await syntaxTreeStorageService.StoreAsync(tree, root, tempStorageService, CancellationToken.None).ConfigureAwait(false);
Assert.True(syntaxTreeStorageService.CanRetrieve(tree));
}
......@@ -108,7 +108,7 @@ public async Task TestRetrieveAsync()
Assert.True(syntaxTreeStorageService.CanRetrieve(tree));
var syntaxFactoryService = new CSharp.CSharpSyntaxTreeFactoryServiceFactory().CreateLanguageService(provider: null) as ISyntaxTreeFactoryService;
var newRoot = await syntaxTreeStorageService.RetrieveAsync(tree, syntaxFactoryService, CancellationToken.None);
var newRoot = await syntaxTreeStorageService.RetrieveAsync(tree, syntaxFactoryService, CancellationToken.None).ConfigureAwait(false);
Assert.True(root.IsEquivalentTo(newRoot));
......@@ -140,7 +140,7 @@ public async Task TestRemoveAsync()
{
GC.Collect();
await Task.Delay(5);
await Task.Delay(5).ConfigureAwait(false);
count++;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册