Skip to content

Commit 0eb0e9b

Browse files
committed
PR Feedback
1 parent a19208c commit 0eb0e9b

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

src/Razor/src/Microsoft.CodeAnalysis.Razor.CohostingShared/CohostStartupService.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost;
1717

1818
[Export(typeof(ICohostStartupService))]
1919
[method: ImportingConstructor]
20-
internal class CohostStartupService(
20+
internal sealed class CohostStartupService(
2121
[ImportMany] IEnumerable<Lazy<IRazorCohostStartupService>> lazyStartupServices,
2222
ILoggerFactory loggerFactory) : ICohostStartupService
2323
{
@@ -32,11 +32,17 @@ public async Task StartupAsync(string clientCapabilitiesString, RazorCohostReque
3232

3333
foreach (var provider in providers)
3434
{
35+
if (cancellationToken.IsCancellationRequested)
36+
{
37+
_logger.LogInformation($"Razor extension startup cancelled.");
38+
return;
39+
}
40+
3541
try
3642
{
3743
await provider.StartupAsync(clientCapabilities, requestContext, cancellationToken).ConfigureAwait(false);
3844
}
39-
catch (Exception ex)
45+
catch (Exception ex) when (ex is not OperationCanceledException)
4046
{
4147
_logger.LogError(ex, $"Error initializing Razor startup service '{provider.GetType().Name}'");
4248
}

src/Razor/src/Microsoft.CodeAnalysis.Razor.CohostingShared/Diagnostics/CohostDocumentPullDiagnosticsEndpointBase.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ internal abstract class CohostDocumentPullDiagnosticsEndpointBase<TRequest, TRes
4141

4242
protected virtual LspDiagnostic[] ExtractHtmlDiagnostics(TResponse result)
4343
{
44-
throw new NotImplementedException("If SupportsHtmlDiagnostics is true, you must implement GetHtmlDiagnostics");
44+
throw new NotSupportedException("If SupportsHtmlDiagnostics is true, you must implement GetHtmlDiagnostics");
4545
}
4646

4747
protected virtual TRequest CreateHtmlParams(Uri uri)
4848
{
49-
throw new NotImplementedException("If SupportsHtmlDiagnostics is true, you must implement CreateHtmlParams");
49+
throw new NotSupportedException("If SupportsHtmlDiagnostics is true, you must implement CreateHtmlParams");
5050
}
5151

5252
protected async Task<LspDiagnostic[]?> GetDiagnosticsAsync(TextDocument razorDocument, CancellationToken cancellationToken)
@@ -75,6 +75,11 @@ protected virtual TRequest CreateHtmlParams(Uri uri)
7575
throw;
7676
}
7777

78+
if (cancellationToken.IsCancellationRequested)
79+
{
80+
return null;
81+
}
82+
7883
var csharpDiagnostics = csharpTask.VerifyCompleted();
7984
var htmlDiagnostics = htmlTask.VerifyCompleted();
8085

src/Razor/src/Microsoft.CodeAnalysis.Razor.CohostingShared/RazorCohostDynamicRegistrationService.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,5 @@ await razorCohostClientLanguageServerManager.SendRequestAsync(
7777
Registrations = allRegistrations
7878
},
7979
cancellationToken).ConfigureAwait(false);
80-
8180
}
8281
}

0 commit comments

Comments
 (0)