Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge release/dev17.12 to main #10732

Merged
merged 5 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.LanguageServer.EndpointContracts;
using Microsoft.AspNetCore.Razor.Telemetry;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CommonLanguageServerProtocol.Framework;
using Microsoft.VisualStudio.LanguageServer.Protocol;

namespace Microsoft.AspNetCore.Razor.LanguageServer;

[RazorLanguageServerEndpoint(Methods.InitializeName)]
internal class RazorInitializeEndpoint : IRazorDocumentlessRequestHandler<InitializeParams, InitializeResult>
internal class RazorInitializeEndpoint(
LanguageServerFeatureOptions options,
ITelemetryReporter telemetryReporter) : IRazorDocumentlessRequestHandler<InitializeParams, InitializeResult>
{
private static bool s_reportedFeatureFlagState = false;

private readonly LanguageServerFeatureOptions _options = options;
private readonly ITelemetryReporter _telemetryReporter = telemetryReporter;

public bool MutatesSolutionState { get; } = true;

public Task<InitializeResult> HandleRequestAsync(InitializeParams request, RazorRequestContext requestContext, CancellationToken cancellationToken)
Expand All @@ -21,6 +30,16 @@ public Task<InitializeResult> HandleRequestAsync(InitializeParams request, Razor
capabilitiesManager.SetInitializeParams(request);
var serverCapabilities = capabilitiesManager.GetInitializeResult();

// Initialize can be called multiple times in a VS session, but the feature flag can't change in that time, so we only
// need to report once. In VS Code things could change between solution loads, but each solution load starts a new rzls
// process, so the static field gets reset anyway.
if (!s_reportedFeatureFlagState)
{
s_reportedFeatureFlagState = true;
_telemetryReporter.ReportEvent("initialize", Severity.Normal, new
Property(nameof(LanguageServerFeatureOptions.ForceRuntimeCodeGeneration), _options.ForceRuntimeCodeGeneration));
}

return Task.FromResult(serverCapabilities);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
"Description"="Enable combined design time/runtime code generation for Razor files"
"Value"=dword:00000000
"Title"="Force use of runtime code generation for Razor (requires restart)"
"PreviewPaneChannels"="IntPreview,int.main"
"PreviewPaneChannels"="*"
"VisibleToInternalUsersOnlyChannels"="*"

// CacheTag value should be changed when registration file changes
// See https://devdiv.visualstudio.com/DevDiv/_wiki/wikis/DevDiv.wiki/39345/Manifest-Build-Deployment-and-Setup-Authoring-In-Depth?anchor=example-pkgdef-key for more infomation
Expand Down