diff --git a/NuGet.config b/NuGet.config
index 8214834570..1e97e5860d 100644
--- a/NuGet.config
+++ b/NuGet.config
@@ -80,7 +80,6 @@
-
diff --git a/eng/Versions.props b/eng/Versions.props
index 63cc51559f..95055dd031 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -84,8 +84,6 @@
$(RoslynPackageVersion)
- 1.0.7
-
6.0.0
6.0.0
diff --git a/src/Razor/benchmarks/Microsoft.AspNetCore.Razor.Microbenchmarks/LanguageServer/RazorSemanticTokensBenchmark.cs b/src/Razor/benchmarks/Microsoft.AspNetCore.Razor.Microbenchmarks/LanguageServer/RazorSemanticTokensBenchmark.cs
index f15bbdb04a..b021065e66 100644
--- a/src/Razor/benchmarks/Microsoft.AspNetCore.Razor.Microbenchmarks/LanguageServer/RazorSemanticTokensBenchmark.cs
+++ b/src/Razor/benchmarks/Microsoft.AspNetCore.Razor.Microbenchmarks/LanguageServer/RazorSemanticTokensBenchmark.cs
@@ -104,7 +104,6 @@ namespace Microsoft.AspNetCore.Razor.Microbenchmarks.LanguageServer
public async Task CleanupServerAsync()
{
var innerServer = RazorLanguageServer.GetInnerLanguageServerForTesting();
-
await innerServer.ShutdownAsync();
await innerServer.ExitAsync();
}
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServer.ContainedLanguage/DefaultLSPDocumentSynchronizer.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServer.ContainedLanguage/DefaultLSPDocumentSynchronizer.cs
index e5bbeaefc4..42a0015142 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServer.ContainedLanguage/DefaultLSPDocumentSynchronizer.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServer.ContainedLanguage/DefaultLSPDocumentSynchronizer.cs
@@ -5,10 +5,8 @@ using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.Build.Framework;
using Microsoft.VisualStudio.LanguageServer.Client;
using Microsoft.VisualStudio.LanguageServer.ContainedLanguage.Extensions;
using Microsoft.VisualStudio.Text;
@@ -46,14 +44,9 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
_documentManager = documentManager;
}
- internal record SynchronizedResult(bool Synchronized, TVirtualDocumentSnapshot? VirtualSnapshot)
+ internal record SynchronizedResult(bool Synchronized, TVirtualDocumentSnapshot VirtualSnapshot)
where TVirtualDocumentSnapshot : VirtualDocumentSnapshot
{
- public bool TryGetVirtualSnapshot([NotNullWhen(true)] out TVirtualDocumentSnapshot? virtualDocumentSnapshot)
- {
- virtualDocumentSnapshot = VirtualSnapshot;
- return Synchronized;
- }
}
public override Task> TrySynchronizeVirtualDocumentAsync(
@@ -82,11 +75,7 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
Task onSynchronizedTask;
lock (_documentContextLock)
{
- if (!TryGetVirtualDocumentSnapshot(hostDocumentUri, out var preSyncedSnapshot))
- {
- return new SynchronizedResult(false, preSyncedSnapshot);
- }
-
+ var preSyncedSnapshot = GetVirtualDocumentSnapshot(hostDocumentUri);
var virtualDocumentUri = preSyncedSnapshot.Uri;
if (!_virtualDocumentContexts.TryGetValue(virtualDocumentUri, out var documentContext))
{
@@ -105,11 +94,8 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
}
var onSynchronizedResult = await onSynchronizedTask.ConfigureAwait(false);
- TVirtualDocumentSnapshot? virtualDocumentSnapshot = null;
- if (onSynchronizedResult)
- {
- onSynchronizedResult = TryGetVirtualDocumentSnapshot(hostDocumentUri, out virtualDocumentSnapshot);
- }
+
+ var virtualDocumentSnapshot = GetVirtualDocumentSnapshot(hostDocumentUri);
return new SynchronizedResult(onSynchronizedResult, virtualDocumentSnapshot);
}
@@ -146,7 +132,7 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
}
}
- private bool TryGetVirtualDocumentSnapshot(Uri hostDocumentUri, [NotNullWhen(true)] out TVirtualDocumentSnapshot? virtualDocumentSnapshot)
+ private TVirtualDocumentSnapshot GetVirtualDocumentSnapshot(Uri hostDocumentUri)
where TVirtualDocumentSnapshot : VirtualDocumentSnapshot
{
var normalizedString = hostDocumentUri.GetAbsoluteOrUNCPath();
@@ -154,20 +140,15 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
if (!_documentManager.TryGetDocument(normalizedUri, out var documentSnapshot))
{
- // Unable to retrieve snapshot for document {normalizedUri} after synchronization
- virtualDocumentSnapshot = null;
- return false;
+ throw new InvalidOperationException($"Unable to retrieve snapshot for document {normalizedUri} after synchronization");
}
if (!documentSnapshot.TryGetVirtualDocument(out var virtualDoc))
{
- // Unable to retrieve virtual document for {normalizedUri} after document synchronization
- virtualDocumentSnapshot = null;
- return false;
+ throw new InvalidOperationException($"Unable to retrieve virtual document for {normalizedUri} after document synchronization");
}
- virtualDocumentSnapshot = virtualDoc;
- return true;
+ return virtualDoc;
}
private void VirtualDocumentBuffer_PostChanged(object sender, EventArgs e)
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServerClient.Razor/DefaultRazorLanguageServerCustomMessageTarget.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServerClient.Razor/DefaultRazorLanguageServerCustomMessageTarget.cs
index 35dea6b84a..8e348b59be 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServerClient.Razor/DefaultRazorLanguageServerCustomMessageTarget.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServerClient.Razor/DefaultRazorLanguageServerCustomMessageTarget.cs
@@ -24,7 +24,6 @@ using Microsoft.VisualStudio.LanguageServer.Protocol;
using Microsoft.VisualStudio.LanguageServerClient.Razor.Extensions;
using Microsoft.VisualStudio.LanguageServerClient.Razor.HtmlCSharp;
using Microsoft.VisualStudio.LanguageServerClient.Razor.WrapWithTag;
-using Microsoft.VisualStudio.OLE.Interop;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Threading;
using Newtonsoft.Json.Linq;
@@ -171,20 +170,20 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
await _joinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
- var htmlResult = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync(
+ var (synchronized, htmlDocument) = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync(
request.HostDocumentVersion,
request.TextDocument.Uri,
cancellationToken);
- if (!htmlResult.TryGetVirtualSnapshot(out var htmlDocument))
+ var languageServerName = RazorLSPConstants.HtmlLanguageServerName;
+ var projectedUri = htmlDocument.Uri;
+
+ if (!synchronized)
{
Debug.Fail("RangeFormatting not synchronized.");
return response;
}
- var languageServerName = RazorLSPConstants.HtmlLanguageServerName;
- var projectedUri = htmlDocument.Uri;
-
var formattingParams = new DocumentFormattingParams()
{
TextDocument = new TextDocumentIdentifier() { Uri = projectedUri },
@@ -211,10 +210,10 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
var hostDocumentUri = request.TextDocument.Uri;
var languageServerName = RazorLSPConstants.HtmlLanguageServerName;
- var htmlResult = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync(
+ var (synchronized, htmlDocument) = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync(
request.HostDocumentVersion, hostDocumentUri, cancellationToken);
- if (!htmlResult.TryGetVirtualSnapshot(out var htmlDocument))
+ if (!synchronized)
{
return response;
}
@@ -252,7 +251,7 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
await _joinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
var hostDocumentUri = new Uri(request.HostDocumentFilePath);
- var csharpResult = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync(
+ var (synchronized, csharpDocument) = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync(
request.HostDocumentVersion,
hostDocumentUri,
cancellationToken);
@@ -260,7 +259,7 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
string languageServerName;
Uri projectedUri;
- if (!csharpResult.TryGetVirtualSnapshot(out var csharpDocument))
+ if (!synchronized)
{
// Document could not be synchronized
return response;
@@ -436,14 +435,9 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
throw new ArgumentNullException(nameof(documentColorParams));
}
- var htmlResult = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync(
+ var (synchronized, htmlDoc) = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync(
documentColorParams.RequiredHostDocumentVersion, documentColorParams.TextDocument.Uri, cancellationToken);
- if (!htmlResult.TryGetVirtualSnapshot(out var htmlDoc))
- {
- return null;
- }
-
documentColorParams.TextDocument.Uri = htmlDoc.Uri;
var htmlTextBuffer = htmlDoc.Snapshot.TextBuffer;
var requests = _requestInvoker.ReinvokeRequestOnMultipleServersAsync(
@@ -519,12 +513,12 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
var response = new VSInternalWrapWithTagResponse(wrapWithParams.Range, Array.Empty());
- var htmlResult = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync(
+ var (synchronized, htmlDocument) = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync(
wrapWithParams.TextDocument.Version,
wrapWithParams.TextDocument.Uri,
cancellationToken);
- if (!htmlResult.TryGetVirtualSnapshot(out var htmlDocument))
+ if (!synchronized)
{
Debug.Fail("Document was not synchronized");
return response;
@@ -603,10 +597,10 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
var csharpRanges = new List();
var csharpTask = Task.Run(async () =>
{
- var csharpResult = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync(
+ var (synchronized, csharpSnapshot) = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync(
foldingRangeParams.HostDocumentVersion, foldingRangeParams.TextDocument.Uri, cancellationToken);
- if (csharpResult.TryGetVirtualSnapshot(out var csharpSnapshot))
+ if (synchronized)
{
var csharpRequestParams = new FoldingRangeParams()
{
@@ -640,10 +634,10 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
var htmlTask = Task.CompletedTask;
htmlTask = Task.Run(async () =>
{
- var htmlResult = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync(
+ var (synchronized, htmlDocument) = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync(
foldingRangeParams.HostDocumentVersion, foldingRangeParams.TextDocument.Uri, cancellationToken);
- if (htmlResult.TryGetVirtualSnapshot(out var htmlDocument))
+ if (synchronized)
{
var htmlRequestParams = new FoldingRangeParams()
{
@@ -721,20 +715,12 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
hostDocumentVersion,
hostDocumentUri,
cancellationToken);
- if (syncResult.TryGetVirtualSnapshot(out var virtualSnapshot))
+ languageServerName = RazorLSPConstants.RazorCSharpLanguageServerName;
+ presentationParams.TextDocument = new TextDocumentIdentifier
{
- languageServerName = RazorLSPConstants.RazorCSharpLanguageServerName;
- presentationParams.TextDocument = new TextDocumentIdentifier
- {
- Uri = virtualSnapshot.Uri,
- };
- document = virtualSnapshot;
- }
- else
- {
- // Unable to synchronize
- return null;
- }
+ Uri = syncResult.VirtualSnapshot.Uri,
+ };
+ document = syncResult.VirtualSnapshot;
}
else if (kind == RazorLanguageKind.Html)
{
@@ -742,20 +728,12 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
hostDocumentVersion,
hostDocumentUri,
cancellationToken);
- if (syncResult.TryGetVirtualSnapshot(out var virtualSnapshot))
+ languageServerName = RazorLSPConstants.HtmlLanguageServerName;
+ presentationParams.TextDocument = new TextDocumentIdentifier
{
- languageServerName = RazorLSPConstants.HtmlLanguageServerName;
- presentationParams.TextDocument = new TextDocumentIdentifier
- {
- Uri = virtualSnapshot.Uri,
- };
- document = virtualSnapshot;
- }
- else
- {
- // Unable to synchronize
- return null;
- }
+ Uri = syncResult.VirtualSnapshot.Uri,
+ };
+ document = syncResult.VirtualSnapshot;
}
else
{
@@ -782,41 +760,26 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
var hostDocumentUri = request.HostDocument.Uri;
string languageServerName;
- Uri? projectedUri;
+ Uri projectedUri;
+ bool synchronized;
VirtualDocumentSnapshot virtualDocumentSnapshot;
if (request.ProjectedKind == RazorLanguageKind.Html)
{
- var htmlResult = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync(
+ (synchronized, virtualDocumentSnapshot) = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync(
request.HostDocument.Version,
request.HostDocument.Uri,
cancellationToken);
- if (htmlResult.TryGetVirtualSnapshot(out var htmlSnapshot))
- {
- languageServerName = RazorLSPConstants.HtmlLanguageServerName;
- projectedUri = htmlSnapshot.Uri;
- virtualDocumentSnapshot = htmlSnapshot;
- }
- else
- {
- return null;
- }
+ languageServerName = RazorLSPConstants.HtmlLanguageServerName;
+ projectedUri = virtualDocumentSnapshot.Uri;
}
else if (request.ProjectedKind == RazorLanguageKind.CSharp)
{
- var csharpResult = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync(
+ (synchronized, virtualDocumentSnapshot) = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync(
request.HostDocument.Version,
hostDocumentUri,
cancellationToken);
- if (csharpResult.TryGetVirtualSnapshot(out var csharpSnapshot))
- {
- languageServerName = RazorLSPConstants.RazorCSharpLanguageServerName;
- projectedUri = csharpSnapshot.Uri;
- virtualDocumentSnapshot = csharpSnapshot;
- }
- else
- {
- return null;
- }
+ languageServerName = RazorLSPConstants.RazorCSharpLanguageServerName;
+ projectedUri = virtualDocumentSnapshot.Uri;
}
else
{
@@ -824,6 +787,11 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
return null;
}
+ if (!synchronized)
+ {
+ return null;
+ }
+
var completionParams = new CompletionParams()
{
Context = request.Context,
@@ -933,34 +901,22 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
public override async Task ProvideResolvedCompletionItemAsync(DelegatedCompletionItemResolveParams request, CancellationToken cancellationToken)
{
string languageServerName;
- VirtualDocumentSnapshot? virtualDocumentSnapshot;
+ bool synchronized;
+ VirtualDocumentSnapshot virtualDocumentSnapshot;
if (request.OriginatingKind == RazorLanguageKind.Html)
{
- var htmlResult = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync(
+ (synchronized, virtualDocumentSnapshot) = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync(
request.HostDocument.Version,
request.HostDocument.Uri,
cancellationToken);
- if (!htmlResult.TryGetVirtualSnapshot(out var htmlSnapshot))
- {
- return null;
- }
-
- virtualDocumentSnapshot = htmlSnapshot;
languageServerName = RazorLSPConstants.HtmlLanguageServerName;
}
else if (request.OriginatingKind == RazorLanguageKind.CSharp)
{
- var csharpResult = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync(
+ (synchronized, virtualDocumentSnapshot) = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync(
request.HostDocument.Version,
request.HostDocument.Uri,
cancellationToken);
-
- if (!csharpResult.TryGetVirtualSnapshot(out var csharpSnapshot))
- {
- return null;
- }
-
- virtualDocumentSnapshot = csharpSnapshot;
languageServerName = RazorLSPConstants.RazorCSharpLanguageServerName;
}
else
@@ -969,6 +925,12 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
return null;
}
+ if (!synchronized)
+ {
+ // Document was not synchronized
+ return null;
+ }
+
var completionResolveParams = request.CompletionItem;
var textBuffer = virtualDocumentSnapshot.Snapshot.TextBuffer;
@@ -1120,36 +1082,24 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
{
string languageServerName;
+ bool synchronized;
VirtualDocumentSnapshot virtualDocumentSnapshot;
if (request.ProjectedKind == RazorLanguageKind.Html)
{
- var htmlResult = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync(
+ (synchronized, virtualDocumentSnapshot) = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync(
request.HostDocument.Version,
request.HostDocument.Uri,
rejectOnNewerParallelRequest: false,
cancellationToken);
-
- if (!htmlResult.TryGetVirtualSnapshot(out var htmlSnapshot))
- {
- return null;
- }
-
- virtualDocumentSnapshot = htmlSnapshot;
languageServerName = RazorLSPConstants.HtmlLanguageServerName;
}
else if (request.ProjectedKind == RazorLanguageKind.CSharp)
{
- var csharpResult = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync(
+ (synchronized, virtualDocumentSnapshot) = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync(
request.HostDocument.Version,
request.HostDocument.Uri,
rejectOnNewerParallelRequest: false,
cancellationToken);
- if(!csharpResult.TryGetVirtualSnapshot(out var csharpSnapshot))
- {
- return null;
- }
-
- virtualDocumentSnapshot = csharpSnapshot;
languageServerName = RazorLSPConstants.RazorCSharpLanguageServerName;
}
else
@@ -1158,6 +1108,11 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
return null;
}
+ if (!synchronized)
+ {
+ return null;
+ }
+
return new DelegationRequestDetails(languageServerName, virtualDocumentSnapshot.Uri, virtualDocumentSnapshot.Snapshot.TextBuffer);
}
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServerClient.Razor/HtmlCSharp/DefaultLSPProjectionProvider.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServerClient.Razor/HtmlCSharp/DefaultLSPProjectionProvider.cs
index c6354733c0..d8c80067f0 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServerClient.Razor/HtmlCSharp/DefaultLSPProjectionProvider.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServerClient.Razor/HtmlCSharp/DefaultLSPProjectionProvider.cs
@@ -144,33 +144,26 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor.HtmlCSharp
}
else
{
+ bool synchronized;
if (languageResponse.Kind == RazorLanguageKind.CSharp)
{
- var csharpResult = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync(documentSnapshot.Version, documentSnapshot.Uri, rejectOnNewerParallelRequest, cancellationToken).ConfigureAwait(false);
- if (!csharpResult.TryGetVirtualSnapshot(out var csharpSnapshot))
- {
- _logHubLogger?.LogInformation("Could not synchronize.");
- return null;
- }
-
- virtualDocument = csharpSnapshot;
+ (synchronized, virtualDocument) = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync(documentSnapshot.Version, documentSnapshot.Uri, rejectOnNewerParallelRequest, cancellationToken).ConfigureAwait(false);
}
else if (languageResponse.Kind == RazorLanguageKind.Html)
{
- var htmlResult = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync(documentSnapshot.Version, documentSnapshot.Uri, rejectOnNewerParallelRequest, cancellationToken).ConfigureAwait(false);
- if (!htmlResult.TryGetVirtualSnapshot(out var htmlSnapshot))
- {
- _logHubLogger?.LogInformation("Could not synchronize.");
- return null;
- }
-
- virtualDocument = htmlSnapshot;
+ (synchronized, virtualDocument) = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync(documentSnapshot.Version, documentSnapshot.Uri, rejectOnNewerParallelRequest, cancellationToken).ConfigureAwait(false);
}
else
{
_logHubLogger?.LogInformation("Could not find projection for {languageResponseKind:G}.", languageResponse.Kind);
return null;
}
+
+ if (!synchronized)
+ {
+ _logHubLogger?.LogInformation("Could not synchronize.");
+ return null;
+ }
}
var result = new ProjectionResult()
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServerClient.Razor/HtmlCSharp/DocumentPullDiagnosticsHandler.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServerClient.Razor/HtmlCSharp/DocumentPullDiagnosticsHandler.cs
index 5cc87a8cda..843237d926 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServerClient.Razor/HtmlCSharp/DocumentPullDiagnosticsHandler.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServerClient.Razor/HtmlCSharp/DocumentPullDiagnosticsHandler.cs
@@ -97,11 +97,11 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor.HtmlCSharp
return clearedDiagnosticReport;
}
- var csharpResult = await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync(
+ var (synchronized, csharpDoc)= await _documentSynchronizer.TrySynchronizeVirtualDocumentAsync(
documentSnapshot.Version,
request.TextDocument.Uri,
cancellationToken).ConfigureAwait(false);
- if (!csharpResult.TryGetVirtualSnapshot(out var csharpDoc))
+ if (!synchronized)
{
_logger.LogInformation("Failed to synchronize document {hostDocument}.", request.TextDocument.Uri);
diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/RazorLanguageServerTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/RazorLanguageServerTest.cs
index 315f10851f..19bc5f7e4b 100644
--- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/RazorLanguageServerTest.cs
+++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/RazorLanguageServerTest.cs
@@ -36,6 +36,7 @@ public class RazorLanguageServerTest : TestBase
// We turn this into a Set to handle cases like Completion where we have two handlers, only one of which will be registered
// CLaSP will throw if two handlers register for the same method, so if THAT doesn't hold it's a CLaSP bug, not a Razor bug.
var typeMethods = handlerTypes.Select(t => GetMethodFromType(t)).ToHashSet();
+
if (registeredMethods.Length != typeMethods.Count)
{
var unregisteredHandlers = typeMethods.Where(t => !registeredMethods.Any(m => m.MethodName == t));
diff --git a/src/Razor/test/Microsoft.VisualStudio.Razor.IntegrationTests/GoToImplementationTests.cs b/src/Razor/test/Microsoft.VisualStudio.Razor.IntegrationTests/GoToImplementationTests.cs
index 9b90b548f7..d25849c52f 100644
--- a/src/Razor/test/Microsoft.VisualStudio.Razor.IntegrationTests/GoToImplementationTests.cs
+++ b/src/Razor/test/Microsoft.VisualStudio.Razor.IntegrationTests/GoToImplementationTests.cs
@@ -14,7 +14,7 @@ namespace Microsoft.VisualStudio.Razor.IntegrationTests
// Open the file
await TestServices.SolutionExplorer.OpenFileAsync(RazorProjectConstants.BlazorProjectName, RazorProjectConstants.CounterRazorFile, ControlledHangMitigatingCancellationToken);
- await TestServices.Editor.PlaceCaretAsync("IncrementCou", charsOffset: 1, ControlledHangMitigatingCancellationToken);
+ await TestServices.Editor.PlaceCaretAsync("IncrementCount", charsOffset: -1, ControlledHangMitigatingCancellationToken);
// Act
await TestServices.Editor.InvokeGoToImplementationAsync(ControlledHangMitigatingCancellationToken);
@@ -31,7 +31,7 @@ namespace Microsoft.VisualStudio.Razor.IntegrationTests
// Change text to refer back to Program class
await TestServices.Editor.SetTextAsync(@" Modifiers;
- public readonly VirtualKeyCode VirtualKeyCode;
- public readonly char? Character;
- public readonly string? Text;
-
- public InputKey(VirtualKeyCode virtualKeyCode)
- {
- Modifiers = ImmutableArray.Empty;
- VirtualKeyCode = virtualKeyCode;
- Character = null;
- Text = null;
- }
-
- public InputKey(VirtualKeyCode virtualKeyCode, ImmutableArray modifiers)
- {
- Modifiers = modifiers;
- VirtualKeyCode = virtualKeyCode;
- Character = null;
- Text = null;
- }
-
- public InputKey(char character)
- {
- Modifiers = ImmutableArray.Empty;
- VirtualKeyCode = 0;
- Character = character;
- Text = null;
- }
-
- public InputKey(string text)
- {
- Modifiers = ImmutableArray.Empty;
- VirtualKeyCode = 0;
- Character = null;
- Text = text;
- }
-
- public static implicit operator InputKey(VirtualKeyCode virtualKeyCode)
- => new(virtualKeyCode);
-
- public static implicit operator InputKey(char character)
- => new(character);
-
- public static implicit operator InputKey(string text)
- => new(text);
-
- public void Apply(IInputSimulator simulator)
- {
- if (Character is { } c)
- {
- if (c == '\n')
- simulator.Keyboard.KeyPress(VirtualKeyCode.RETURN);
- else if (c == '\t')
- simulator.Keyboard.KeyPress(VirtualKeyCode.TAB);
- else
- simulator.Keyboard.TextEntry(c);
-
- return;
- }
- else if (Text is not null)
- {
- var offset = 0;
- while (offset < Text.Length)
- {
- if (Text[offset] == '\r' && offset < Text.Length - 1 && Text[offset + 1] == '\n')
- {
- // Treat \r\n as a single RETURN character
- offset++;
- continue;
- }
- else if (Text[offset] == '\n')
- {
- simulator.Keyboard.KeyPress(VirtualKeyCode.RETURN);
- offset++;
- continue;
- }
- else if (Text[offset] == '\t')
- {
- simulator.Keyboard.KeyPress(VirtualKeyCode.TAB);
- offset++;
- continue;
- }
- else
- {
- var nextSpecial = Text.IndexOfAny(new[] { '\r', '\n', '\t' }, offset);
- var endOfCurrentSegment = nextSpecial < 0 ? Text.Length : nextSpecial;
- simulator.Keyboard.TextEntry(Text[offset..endOfCurrentSegment]);
- offset = endOfCurrentSegment;
- }
- }
-
- return;
- }
-
- if (Modifiers.IsEmpty)
- {
- simulator.Keyboard.KeyPress(VirtualKeyCode);
- }
- else
- {
- simulator.Keyboard.ModifiedKeyStroke(Modifiers, VirtualKeyCode);
- }
- }
- }
-
[TestService]
internal partial class InputInProcess
{
- internal Task SendAsync(InputKey key, CancellationToken cancellationToken)
- => SendAsync(new InputKey[] { key }, cancellationToken);
-
- internal Task SendAsync(InputKey[] keys, CancellationToken cancellationToken)
- {
- return SendAsync(
- simulator =>
- {
- foreach (var key in keys)
- {
- key.Apply(simulator);
- }
- }, cancellationToken);
- }
-
- internal async Task SendAsync(Action callback, CancellationToken cancellationToken)
- {
- // AbstractSendKeys runs synchronously, so switch to a background thread before the call
- await TaskScheduler.Default;
-
- TestServices.JoinableTaskFactory.Run(async () =>
- {
- await TestServices.Editor.ActivateAsync(cancellationToken);
- });
-
- callback(new InputSimulator());
-
- TestServices.JoinableTaskFactory.Run(async () =>
- {
- await WaitForApplicationIdleAsync(cancellationToken);
- });
- }
-
internal void Send(string keys)
{
SendKeys.Send(keys);
diff --git a/src/Razor/test/Microsoft.VisualStudio.Razor.IntegrationTests/Microsoft.VisualStudio.Razor.IntegrationTests.csproj b/src/Razor/test/Microsoft.VisualStudio.Razor.IntegrationTests/Microsoft.VisualStudio.Razor.IntegrationTests.csproj
index ca49d60283..66fb4b22c7 100644
--- a/src/Razor/test/Microsoft.VisualStudio.Razor.IntegrationTests/Microsoft.VisualStudio.Razor.IntegrationTests.csproj
+++ b/src/Razor/test/Microsoft.VisualStudio.Razor.IntegrationTests/Microsoft.VisualStudio.Razor.IntegrationTests.csproj
@@ -23,9 +23,8 @@
-
+
-
diff --git a/src/Razor/test/Microsoft.VisualStudio.Razor.IntegrationTests/OnEnterRulesTests.cs b/src/Razor/test/Microsoft.VisualStudio.Razor.IntegrationTests/OnEnterRulesTests.cs
index b3e6acfce5..24bce94d66 100644
--- a/src/Razor/test/Microsoft.VisualStudio.Razor.IntegrationTests/OnEnterRulesTests.cs
+++ b/src/Razor/test/Microsoft.VisualStudio.Razor.IntegrationTests/OnEnterRulesTests.cs
@@ -116,8 +116,7 @@ A
// Act
await TestServices.Editor.PlaceCaretAsync("@onclick='thing'", charsOffset: 1, ControlledHangMitigatingCancellationToken);
- await TestServices.Input.SendAsync(WindowsInput.Native.VirtualKeyCode.RETURN, ControlledHangMitigatingCancellationToken);
-
+ TestServices.Input.Send("{ENTER}");
// Assert
await TestServices.Editor.VerifyTextContainsAsync(@"