Skip to content

Commit 67a2661

Browse files
committed
went async was for Razor
1 parent 9bcda6e commit 67a2661

File tree

5 files changed

+13
-2
lines changed

5 files changed

+13
-2
lines changed

src/EditorFeatures/Core/InlineRename/AbstractEditorInlineRenameService.InlineRenameLocationSet.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Linq;
88
using System.Threading;
99
using System.Threading.Tasks;
10+
using Microsoft.CodeAnalysis.Host;
1011
using Microsoft.CodeAnalysis.Rename;
1112
using Microsoft.CodeAnalysis.Shared.Extensions;
1213
using Roslyn.Utilities;
@@ -47,6 +48,8 @@ private InlineRenameLocationSet(
4748
private static async ValueTask<InlineRenameLocation> ConvertLocationAsync(Solution solution, RenameLocation location, CancellationToken cancellationToken)
4849
{
4950
var document = await solution.GetRequiredDocumentAsync(location.DocumentId, includeSourceGenerated: true, cancellationToken).ConfigureAwait(false);
51+
52+
Contract.ThrowIfTrue(location.DocumentId.IsSourceGenerated && !document.IsRazorSourceGeneratedDocument());
5053
return new InlineRenameLocation(document, location.Location.SourceSpan);
5154
}
5255

src/EditorFeatures/Core/InlineRename/InlineRenameSession.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,8 @@ private async Task<Solution> GetFinalSolutionAsync(ImmutableArray<(DocumentId, s
939939
{
940940
if (documentId.IsSourceGenerated)
941941
{
942-
_ = await finalSolution.GetDocumentAsync(documentId, includeSourceGenerated: true, CancellationToken.None).ConfigureAwait(false);
942+
var document = await finalSolution.GetDocumentAsync(documentId, includeSourceGenerated: true, CancellationToken.None).ConfigureAwait(false);
943+
Contract.ThrowIfFalse(document.IsRazorSourceGeneratedDocument());
943944
}
944945

945946
finalSolution = newRoot != null

src/VisualStudio/Core/Def/ProjectSystem/VisualStudioWorkspaceImpl.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,8 @@ internal override void ApplyMappedFileChanges(SolutionChanges solutionChanges)
672672
// so the mapper has something to compare to.
673673
foreach (var (docId, state) in solutionChanges.NewSolution.CompilationState.FrozenSourceGeneratedDocumentStates.States)
674674
{
675-
_ = await solutionChanges.OldSolution.GetRequiredDocumentAsync(docId, includeSourceGenerated: true, cancellationToken).ConfigureAwait(false);
675+
var document = await solutionChanges.OldSolution.GetRequiredDocumentAsync(docId, includeSourceGenerated: true, cancellationToken).ConfigureAwait(false);
676+
Contract.ThrowIfFalse(document.IsRazorSourceGeneratedDocument());
676677
}
677678

678679
foreach (var docId in solutionChanges.GetExplicitlyChangedSourceGeneratedDocuments())

src/Workspaces/Core/Portable/Remote/RemoteUtilities.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Collections.Immutable;
88
using System.Threading;
99
using System.Threading.Tasks;
10+
using Microsoft.CodeAnalysis.Host;
1011
using Microsoft.CodeAnalysis.PooledObjects;
1112
using Microsoft.CodeAnalysis.Shared.Extensions;
1213
using Microsoft.CodeAnalysis.Text;
@@ -65,6 +66,8 @@ public static async Task<Solution> UpdateSolutionAsync(
6566
.SelectAsArrayAsync(async (tuple, cancellationToken) =>
6667
{
6768
var document = await oldSolution.GetDocumentAsync(tuple.documentId, includeSourceGenerated: true, cancellationToken).ConfigureAwait(false);
69+
Contract.ThrowIfTrue(tuple.documentId.IsSourceGenerated && !document.IsRazorSourceGeneratedDocument());
70+
6871
var oldText = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
6972
var newText = oldText.WithChanges(tuple.textChanges);
7073
return (tuple.documentId, newText);

src/Workspaces/Core/Portable/Rename/IRemoteRenamerService.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Runtime.Serialization;
88
using System.Threading;
99
using System.Threading.Tasks;
10+
using Microsoft.CodeAnalysis.Host;
1011
using Microsoft.CodeAnalysis.Remote;
1112
using Microsoft.CodeAnalysis.Rename.ConflictEngine;
1213
using Microsoft.CodeAnalysis.Shared.Extensions;
@@ -86,6 +87,8 @@ public static SerializableRenameLocation Dehydrate(RenameLocation location)
8687
public async ValueTask<RenameLocation> RehydrateAsync(Solution solution, CancellationToken cancellation)
8788
{
8889
var document = await solution.GetRequiredDocumentAsync(DocumentId, includeSourceGenerated: true, cancellation).ConfigureAwait(false);
90+
Contract.ThrowIfTrue(DocumentId.IsSourceGenerated && !document.IsRazorSourceGeneratedDocument());
91+
8992
var tree = await document.GetRequiredSyntaxTreeAsync(cancellation).ConfigureAwait(false);
9093

9194
return new RenameLocation(

0 commit comments

Comments
 (0)