Skip to content

Commit 54f38b5

Browse files
author
Andrew Hall
authored
Send named pipe name to roslyn and razor (#7273)
Use named pipes to communicate between roslyn and razor processes for project information. Update Roslyn to: dnceng.visualstudio.com/internal/_build/results?buildId=2491728&view=results Update Razor to: dev.azure.com/dnceng/internal/_build/results?buildId=2484091&view=results
1 parent b57a92f commit 54f38b5

File tree

6 files changed

+57
-7
lines changed

6 files changed

+57
-7
lines changed

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,32 @@
44
- Debug from .csproj and .sln [#5876](https://github.com/dotnet/vscode-csharp/issues/5876)
55

66
# Latest
7+
* Update Razor to 9.0.0-preview.24327.6 (PR: [#7273](https://github.com/dotnet/vscode-csharp/pull/7273))
8+
* Use a named pipe to communicate projectinfo in vscode (PR: [#10521](https://github.com/dotnet/razor/pull/10521))
9+
* Reduce allocations in Razor's DirectiveVisitor (PR: [10521](https://github.com/dotnet/razor/pull/10521))
10+
* Update Roslyn to 4.12.0-1.24359.8 (PR: [#7273](https://github.com/dotnet/vscode-csharp/pull/7273))
11+
* Fix UseNullPropagationCodeFixProvider for parenthesized property access (PR: [#74316](https://github.com/dotnet/roslyn/pull/74316))
12+
* Sync solution contents consistently(PR: [#72860](https://github.com/dotnet/roslyn/pull/72860))
13+
* Rename the record parameter when its property get renamed (PR: [#74168](https://github.com/dotnet/roslyn/pull/74168))
14+
* Make project system workspace transformation functions resilient to being attempted twice (PR: [#74189](https://github.com/dotnet/roslyn/pull/74189))
15+
* Report a diagnostic on missing body in partial property implementation (PR [#74224](https://github.com/dotnet/roslyn/pull/74224))
16+
* Do not offer 'convert' namespace when the ns has sibling types (PR [#74216](https://github.com/dotnet/roslyn/pull/74216)
17+
* Consume new Razor EA (PR: [#74134](https://github.com/dotnet/roslyn/pull/74134))
18+
* Report diagnostic for field and value in property accessors when used as primary expressions only (PR: [#74164](https://github.com/dotnet/roslyn/pull/74164))
19+
* Ensure an empty run result doesn't throw when generators are present (PR: [#74034](https://github.com/dotnet/roslyn/pull/74034))
20+
* Support navigating to an interceptor location when on an intercepted method call (PR: [#74006](https://github.com/dotnet/roslyn/pull/74006))
21+
* Add type hints for collection expressions (PR: [#74051](https://github.com/dotnet/roslyn/pull/74051))
22+
* Ensure source generated documents are up-to-date before analyzing EnC changes (PR: [#73989](https://github.com/dotnet/roslyn/pull/73989))
23+
* Support goto-def taking you from an interceptor method to the location being intercepted (PR: [#73992](https://github.com/dotnet/roslyn/pull/73992))
24+
* Various performance fixes
25+
* Reduce closures allocated during invocation of CapturedSymbolReplacement.Replacement (PR: [#74258](https://github.com/dotnet/roslyn/pull/74258))
26+
* Reduce allocations in SymbolDeclaredCompilationEvent (PR: [#74250](https://github.com/dotnet/roslyn/pull/74250))
27+
* Reduce allocations in AbstractProjectExtensionProvider.FilterExtensions (PR [#74112](https://github.com/dotnet/roslyn/pull/74112))
28+
* Avoid re-running all codeaction requests at low priority (PR: [#74083](https://github.com/dotnet/roslyn/pull/74083))
29+
* Reduce time spent in ConflictResolver.Session.GetNodesOrTokensToCheckForConflicts (PR: [#74101](https://github.com/dotnet/roslyn/pull/74101))
30+
* Avoid allocations in AbstractSyntaxIndex<>.GetIndexAsync( PR: [#74075](https://github.com/dotnet/roslyn/pull/74075))
31+
32+
# 2.37.x
733
* Bump xamltools to 17.12.35103.251 (PR: [#7309](https://github.com/dotnet/vscode-csharp/pull/7309))
834
* Fixed issue with Exception type related to https://github.com/microsoft/vscode-dotnettools/issues/1247
935

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
}
3838
},
3939
"defaults": {
40-
"roslyn": "4.11.0-3.24320.2",
40+
"roslyn": "4.12.0-1.24359.8",
4141
"omniSharp": "1.39.11",
42-
"razor": "9.0.0-preview.24325.5",
42+
"razor": "9.0.0-preview.24327.6",
4343
"razorOmnisharp": "7.0.0-preview.23363.1",
4444
"xamlTools": "17.12.35103.251"
4545
},

src/lsptoolshost/razorCommands.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,9 @@ export function registerRazorCommands(context: vscode.ExtensionContext, language
133133
// a project. We want to defer this work until necessary, so this command is called by the Razor document manager to tell
134134
// us when they need us to initialize the Razor things.
135135
context.subscriptions.push(
136-
vscode.commands.registerCommand(razorInitializeCommand, async () => {
137-
await languageServer.sendNotification('razor/initialize', {});
136+
vscode.commands.registerCommand(razorInitializeCommand, async (pipeName) => {
137+
// params object must match https://github.com/dotnet/roslyn/blob/325ec8d93f9a28701fdcacffb175d2b01c3ac682/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/RazorInitializeHandler.cs#L37
138+
await languageServer.sendNotification('razor/initialize', { pipeName: pipeName });
138139
})
139140
);
140141
}

src/razor/src/document/razorDocumentManager.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { RazorDocumentChangeKind } from './razorDocumentChangeKind';
1919
import { createDocument } from './razorDocumentFactory';
2020
import { razorInitializeCommand } from '../../../lsptoolshost/razorCommands';
2121
import { PlatformInformation } from '../../../shared/platform';
22+
import { generateUuid } from 'vscode-languageclient/lib/common/utils/uuid';
2223

2324
export class RazorDocumentManager implements IRazorDocumentManager {
2425
public roslynActivated = false;
@@ -176,7 +177,11 @@ export class RazorDocumentManager implements IRazorDocumentManager {
176177
// a Razor file.
177178
if (this.roslynActivated && !this.razorDocumentGenerationInitialized) {
178179
this.razorDocumentGenerationInitialized = true;
179-
vscode.commands.executeCommand(razorInitializeCommand);
180+
const pipeName = generateUuid();
181+
182+
vscode.commands.executeCommand(razorInitializeCommand, pipeName);
183+
this.serverClient.connectNamedPipe(pipeName);
184+
180185
for (const document of this.documents) {
181186
await this.ensureDocumentAndProjectedDocumentsOpen(document);
182187
}

src/razor/src/razorLanguageServerClient.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,14 @@ export class RazorLanguageServerClient implements vscode.Disposable {
150150
return this.client.sendRequest<TResponseType>(method, param);
151151
}
152152

153+
public async sendNotification(method: string, param: any) {
154+
if (!this.isStarted) {
155+
throw new Error(vscode.l10n.t('Tried to send requests while server is not started.'));
156+
}
157+
158+
return this.client.sendNotification(method, param);
159+
}
160+
153161
public async onRequestWithParams<P, R, E>(method: RequestType<P, R, E>, handler: RequestHandler<P, R, E>) {
154162
if (!this.isStarted) {
155163
throw new Error(vscode.l10n.t('Tried to bind on request logic while server is not started.'));
@@ -210,6 +218,13 @@ export class RazorLanguageServerClient implements vscode.Disposable {
210218
return this.stopHandle;
211219
}
212220

221+
public async connectNamedPipe(pipeName: string): Promise<void> {
222+
await this.startHandle;
223+
224+
// Params must match https://github.com/dotnet/razor/blob/92005deac54f3e9d1a4d1d8f04389379cccfa354/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/RazorNamedPipeConnectParams.cs#L9
225+
await this.sendNotification('razor/namedPipeConnect', { pipeName: pipeName });
226+
}
227+
213228
private setupLanguageServer() {
214229
const languageServerTrace = resolveRazorLanguageServerLogLevel(this.vscodeType);
215230
const options: RazorLanguageServerOptions = resolveRazorLanguageServerOptions(
@@ -240,8 +255,6 @@ export class RazorLanguageServerClient implements vscode.Disposable {
240255

241256
// TODO: When all of this code is on GitHub, should we just pass `--omnisharp` as a flag to rzls, and let it decide?
242257
if (!options.usingOmniSharp) {
243-
args.push('--projectConfigurationFileName');
244-
args.push('project.razor.vscode.bin');
245258
args.push('--DelegateToCSharpOnDiagnosticPublish');
246259
args.push('true');
247260
args.push('--UpdateBuffersForClosedDocuments');

test/integrationTests/completion.integration.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ describe(`[${testAssetWorkspace.description}] Test Completion`, function () {
4141
const methodOverrideItem = completionList.items.find(
4242
(item) => item.label === 'Method(singleCsproj2.NeedsImport n)'
4343
);
44+
45+
if (!methodOverrideItem) {
46+
throw new Error(completionList.items.reduce((acc, item) => acc + item.label + '\n', ''));
47+
}
48+
4449
expect(methodOverrideItem).toBeDefined();
4550
expect(methodOverrideItem!.kind).toEqual(vscode.CompletionItemKind.Method);
4651
expect(methodOverrideItem!.command).toBeDefined();

0 commit comments

Comments
 (0)