Skip to content

Commit 5050d46

Browse files
committed
Add server path as an option to allow Razor to re-use the runtime resolver
1 parent 0bc35c0 commit 5050d46

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/lsptoolshost/dotnetRuntimeExtensionResolver.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import * as path from 'path';
77
import * as vscode from 'vscode';
88
import { HostExecutableInformation } from "../shared/constants/HostExecutableInformation";
99
import { IHostExecutableResolver } from "../shared/constants/IHostExecutableResolver";
10-
import { getServerPath } from "../lsptoolshost/roslynLanguageServer";
1110
import { PlatformInformation } from "../shared/platform";
1211
import { Options } from "../shared/options";
1312
import { existsSync } from 'fs';
@@ -20,16 +19,21 @@ interface IDotnetAcquireResult {
2019
}
2120

2221
/**
23-
* Resolves the dotnet runtime from given options and the dotnet runtime VSCode extension.
22+
* Resolves the dotnet runtime for a server executable from given options and the dotnet runtime VSCode extension.
2423
*/
2524
export class DotnetRuntimeExtensionResolver implements IHostExecutableResolver {
26-
constructor(private platformInfo: PlatformInformation) { }
25+
constructor(
26+
private platformInfo: PlatformInformation,
27+
/**
28+
* This is a function instead of a string because the server path can change while the extension is active (when the option changes).
29+
*/
30+
private getServerPath: (options: Options, platform: PlatformInformation) => string) { }
2731

2832
private hostInfo: HostExecutableInformation | undefined;
2933

3034
async getHostExecutableInfo(options: Options): Promise<HostExecutableInformation> {
3135
let dotnetRuntimePath = options.commonOptions.dotnetPath;
32-
const serverPath = getServerPath(options, this.platformInfo);
36+
const serverPath = this.getServerPath(options, this.platformInfo);
3337
if (!dotnetRuntimePath)
3438
{
3539
let dotnetInfo = await this.acquireDotNetProcessDependencies(serverPath);

src/lsptoolshost/roslynLanguageServer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ export async function activateRoslynLanguageServer(context: vscode.ExtensionCont
538538
// Create a separate channel for outputting trace logs - these are incredibly verbose and make other logs very difficult to see.
539539
_traceChannel = vscode.window.createOutputChannel("C# LSP Trace Logs");
540540

541-
const hostExecutableResolver = new DotnetRuntimeExtensionResolver(platformInfo);
541+
const hostExecutableResolver = new DotnetRuntimeExtensionResolver(platformInfo, getServerPath);
542542
_languageServer = new RoslynLanguageServer(platformInfo, hostExecutableResolver, optionProvider, context, reporter);
543543

544544
// Register any commands that need to be handled by the extension.
@@ -584,7 +584,7 @@ export async function activateRoslynLanguageServer(context: vscode.ExtensionCont
584584
_languageServer.start();
585585
}
586586

587-
export function getServerPath(options: Options, platformInfo: PlatformInformation) {
587+
function getServerPath(options: Options, platformInfo: PlatformInformation) {
588588
let clientRoot = __dirname;
589589

590590
let serverPath = options.commonOptions.serverPath;

0 commit comments

Comments
 (0)