From dd804e77fe01f2c69004729f8dd8cf4e00de6f9b Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 10 Nov 2015 22:01:10 -0800 Subject: [PATCH] Make more tests async. --- .../GenerateConstructor/GenerateConstructorTests.vb | 12 ++++++------ .../Rename/CSharpRenameRewriterLanguageService.cs | 7 +++---- .../Rename/ConflictEngine/ConflictResolution.cs | 5 +++-- .../ConflictEngine/ConflictResolver.Session.cs | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateConstructor/GenerateConstructorTests.vb b/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateConstructor/GenerateConstructorTests.vb index b0fc6952dbc..38ef851232f 100644 --- a/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateConstructor/GenerateConstructorTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateConstructor/GenerateConstructorTests.vb @@ -504,8 +504,8 @@ NewLines("Imports System.Linq \n Class C \n Private v As Integer \n Sub New() \n - Public Sub TestGenerateInDerivedType1() - Test( + Public Async Function TestGenerateInDerivedType1() As Task + Await TestAsync( " Public Class Base Public Sub New(a As String) @@ -531,12 +531,12 @@ Public Class Derived MyBase.New(a) End Sub End Class") - End Sub + End Function - Public Sub TestGenerateInDerivedType2() - Test( + Public Async Function TestGenerateInDerivedType2() As Task + Await TestAsync( " Public Class Base Public Sub New(a As Integer, Optional b As String = Nothing) @@ -562,6 +562,6 @@ Public Class Derived MyBase.New(a, b) End Sub End Class") - End Sub + End Function End Class End Namespace diff --git a/src/Workspaces/CSharp/Portable/Rename/CSharpRenameRewriterLanguageService.cs b/src/Workspaces/CSharp/Portable/Rename/CSharpRenameRewriterLanguageService.cs index 2450a5f6107..2d04f0c75e5 100644 --- a/src/Workspaces/CSharp/Portable/Rename/CSharpRenameRewriterLanguageService.cs +++ b/src/Workspaces/CSharp/Portable/Rename/CSharpRenameRewriterLanguageService.cs @@ -218,7 +218,7 @@ public override SyntaxToken VisitToken(SyntaxToken token) if (tokenNeedsConflictCheck) { - newToken = RenameAndAnnotateAsync(token, newToken, isRenameLocation, isOldText).WaitAndGetResult(_cancellationToken); + newToken = RenameAndAnnotateAsync(token, newToken, isRenameLocation, isOldText).WaitAndGetResult_CanCallOnBackground(_cancellationToken); if (!_isProcessingComplexifiedSpans) { @@ -382,9 +382,8 @@ private async Task RenameAndAnnotateAsync(SyntaxToken token, Syntax AddModifiedSpan(oldSpan, newToken.Span); } - RenameDeclarationLocationReference[] renameDeclarationLocations = - ConflictResolver.CreateDeclarationLocationAnnotationsAsync(_solution, symbols, _cancellationToken) - .WaitAndGetResult(_cancellationToken); + var renameDeclarationLocations = await + ConflictResolver.CreateDeclarationLocationAnnotationsAsync(_solution, symbols, _cancellationToken).ConfigureAwait(false); var isNamespaceDeclarationReference = false; if (isRenameLocation && token.GetPreviousToken().IsKind(SyntaxKind.NamespaceKeyword)) diff --git a/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolution.cs b/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolution.cs index 775dd155e8c..535c76c8a6c 100644 --- a/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolution.cs +++ b/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolution.cs @@ -6,6 +6,7 @@ using System.Diagnostics; using System.Linq; using System.Threading; +using System.Threading.Tasks; using Microsoft.CodeAnalysis.LanguageServices; using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; @@ -59,14 +60,14 @@ internal void UpdateCurrentSolution(Solution solution) _newSolution = solution; } - internal void RemoveAllRenameAnnotations(IEnumerable documentWithRenameAnnotations, AnnotationTable annotationSet, CancellationToken cancellationToken) + internal async Task RemoveAllRenameAnnotationsAsync(IEnumerable documentWithRenameAnnotations, AnnotationTable annotationSet, CancellationToken cancellationToken) { foreach (var documentId in documentWithRenameAnnotations) { if (_renamedSpansTracker.IsDocumentChanged(documentId)) { var document = _newSolution.GetDocument(documentId); - var root = document.GetSyntaxRootAsync(cancellationToken).WaitAndGetResult(cancellationToken); + var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); // For the computeReplacementToken and computeReplacementNode functions, use // the "updated" node to maintain any annotation removals from descendants. diff --git a/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.Session.cs b/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.Session.cs index e6991ed1a3f..9ea2c1b0978 100644 --- a/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.Session.cs +++ b/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.Session.cs @@ -199,7 +199,7 @@ public async Task ResolveConflictsAsync() // Step 3: Simplify the project conflictResolution.UpdateCurrentSolution(await renamedSpansTracker.SimplifyAsync(conflictResolution.NewSolution, documentsByProject, _replacementTextValid, _renameAnnotations, _cancellationToken).ConfigureAwait(false)); - conflictResolution.RemoveAllRenameAnnotations(documentsByProject, _renameAnnotations, _cancellationToken); + await conflictResolution.RemoveAllRenameAnnotationsAsync(documentsByProject, _renameAnnotations, _cancellationToken).ConfigureAwait(false); } } -- GitLab