Skip to content

Commit 2c57622

Browse files
Merge pull request #5808 from dotnet/prerelease
Merge changes from prerelease into main
2 parents 92e8caa + 43174c6 commit 2c57622

File tree

3 files changed

+40
-32
lines changed

3 files changed

+40
-32
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
## C# for Visual Studio Code
2-
C# is the feature-rich, language support for C# and is shipped as part of [C# Dev Kit](csdevkitextension). This version of the extension is currently in pre-release and available for you to use today.
2+
C# is the feature-rich, language support for C# and is shipped as part of [C# Dev Kit][csdevkitextension]. This version of the extension is currently in pre-release and available for you to use today.
33

4-
C# is an extension that contributes to the [C# Dev Kit extension](csdevkitextension) for Visual Studio Code to provide performant and reliable language support. Under the hood, this extension is powered by a Language Server Protocol (LSP) Tools Host which integrates with open source components like [Roslyn](https://github.com/dotnet/roslyn) and [Razor](https://github.com/dotnet/razor) to provide rich type information and a faster, more reliable C# experience.
4+
C# is an extension that contributes to the [C# Dev Kit extension][csdevkitextension] for Visual Studio Code to provide performant and reliable language support. Under the hood, this extension is powered by a Language Server Protocol (LSP) Tools Host which integrates with open source components like [Roslyn](https://github.com/dotnet/roslyn) and [Razor](https://github.com/dotnet/razor) to provide rich type information and a faster, more reliable C# experience.
55

66
## Recommended Install
7-
While it is possible to use the C# extension as a standalone extension, we highly recommend using [C# Dev Kit](csdevkitextension).
7+
While it is possible to use the C# extension as a standalone extension, we highly recommend using [C# Dev Kit][csdevkitextension].
88

9-
1. Installing [C# Dev Kit](csdevkitextension) will automatically install this extension as a required dependency
9+
1. Installing [C# Dev Kit][csdevkitextension] will automatically install this extension as a required dependency
1010
2. Open a folder/workspace that contains a C# project (.csproj) and a C# solution (.sln) and the extension will activate.
1111

1212
Note: If working on a solution that requires versions prior to .NET 6, install a Full Framework runtime and MSBuild tooling.

src/lsptoolshost/roslynLanguageServer.ts

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,10 @@ export class RoslynLanguageServer {
151151
}
152152

153153
/**
154-
* Resolves server options and starts the dotnet language server process.
154+
* Resolves server options and starts the dotnet language server process. The process is started asynchronously and this method will not wait until
155+
* the process is launched.
155156
*/
156-
public async start(): Promise<void> {
157+
public start(): void {
157158
let options = this.optionProvider.GetLatestOptions();
158159
let logLevel = options.languageServerOptions.logLevel;
159160
const languageClientTraceLevel = this.GetTraceLevel(logLevel);
@@ -208,7 +209,11 @@ export class RoslynLanguageServer {
208209
this._languageClient.onDidChangeState(async (state) => {
209210
if (state.newState === State.Running) {
210211
await this._languageClient!.setTrace(languageClientTraceLevel);
211-
await this.sendOpenSolutionNotification();
212+
if (this._solutionFile) {
213+
await this.sendOpenSolutionNotification();
214+
} else {
215+
await this.openDefaultSolution();
216+
}
212217
await this.sendOrSubscribeForServiceBrokerConnection();
213218
this._eventBus.emit(RoslynLanguageServer.serverStateChangeEvent, ServerStateChange.Started);
214219
}
@@ -223,20 +228,6 @@ export class RoslynLanguageServer {
223228

224229
// Register Razor dynamic file info handling
225230
this.registerRazor(this._languageClient);
226-
227-
// If Dev Kit isn't installed, then we are responsible for picking the solution to open, assuming the user hasn't explicitly
228-
// disabled it.
229-
if (!this._wasActivatedWithCSharpDevkit && options.commonOptions.defaultSolution !== 'disable' && this._solutionFile === undefined) {
230-
if (options.commonOptions.defaultSolution !== '') {
231-
this.openSolution(vscode.Uri.file(options.commonOptions.defaultSolution));
232-
} else {
233-
// Auto open if there is just one solution target; if there's more the one we'll just let the user pick with the picker.
234-
const solutionUris = await vscode.workspace.findFiles('**/*.sln', '**/node_modules/**', 2);
235-
if (solutionUris && solutionUris.length === 1) {
236-
this.openSolution(solutionUris[0]);
237-
}
238-
}
239-
}
240231
}
241232

242233
public async stop(): Promise<void> {
@@ -246,13 +237,13 @@ export class RoslynLanguageServer {
246237
}
247238

248239
/**
249-
* Restarts the language server.
240+
* Restarts the language server. This does not wait until the server has been restarted.
250241
* Note that since some options affect how the language server is initialized, we must
251-
* re-create the LanguageClient instance instead of just stopping/starting it.
242+
* re-create the LanguageClient instance instead of just stopping/starting it.
252243
*/
253244
public async restart(): Promise<void> {
254245
await this.stop();
255-
await this.start();
246+
this.start();
256247
}
257248

258249
/**
@@ -310,14 +301,32 @@ export class RoslynLanguageServer {
310301
await this.sendOpenSolutionNotification();
311302
}
312303

313-
private async sendOpenSolutionNotification() {
304+
private async sendOpenSolutionNotification(): Promise<void> {
314305
if (this._solutionFile !== undefined && this._languageClient !== undefined && this._languageClient.isRunning()) {
315306
let protocolUri = this._languageClient.clientOptions.uriConverters!.code2Protocol(this._solutionFile);
316307
await this._languageClient.sendNotification("solution/open", new OpenSolutionParams(protocolUri));
317308
}
318309
}
319310

320-
private async sendOrSubscribeForServiceBrokerConnection() {
311+
private async openDefaultSolution(): Promise<void> {
312+
const options = this.optionProvider.GetLatestOptions();
313+
314+
// If Dev Kit isn't installed, then we are responsible for picking the solution to open, assuming the user hasn't explicitly
315+
// disabled it.
316+
if (!this._wasActivatedWithCSharpDevkit && options.commonOptions.defaultSolution !== 'disable' && this._solutionFile === undefined) {
317+
if (options.commonOptions.defaultSolution !== '') {
318+
this.openSolution(vscode.Uri.file(options.commonOptions.defaultSolution));
319+
} else {
320+
// Auto open if there is just one solution target; if there's more the one we'll just let the user pick with the picker.
321+
const solutionUris = await vscode.workspace.findFiles('**/*.sln', '**/node_modules/**', 2);
322+
if (solutionUris && solutionUris.length === 1) {
323+
this.openSolution(solutionUris[0]);
324+
}
325+
}
326+
}
327+
}
328+
329+
private async sendOrSubscribeForServiceBrokerConnection(): Promise<void> {
321330
const csharpDevKitExtension = vscode.extensions.getExtension<CSharpDevKitExports>(csharpDevkitExtensionId);
322331
if (csharpDevKitExtension) {
323332
const exports = await csharpDevKitExtension.activate();
@@ -429,6 +438,7 @@ export class RoslynLanguageServer {
429438
_channel.appendLine(`Starting server at ${serverPath}`);
430439
}
431440

441+
// shouldn't this arg only be set if it's running with CSDevKit?
432442
args.push("--telemetryLevel", this.telemetryReporter.telemetryLevel);
433443

434444
let childProcess: cp.ChildProcessWithoutNullStreams;
@@ -520,9 +530,6 @@ export class RoslynLanguageServer {
520530

521531
const extensionPaths = options.languageServerOptions.extensionsPaths || [this.getLanguageServicesDevKitComponentPath(exports)];
522532

523-
// required for the telemetry service to work
524-
await exports.writeCommonPropsAsync(this.context);
525-
526533
let args: string[] = [];
527534

528535
args.push("--sharedDependencies");
@@ -631,7 +638,7 @@ export async function activateRoslynLanguageServer(context: vscode.ExtensionCont
631638
});
632639

633640
// Start the language server.
634-
await _languageServer.start();
641+
_languageServer.start();
635642
}
636643

637644
async function applyAutoInsertEdit(e: vscode.TextDocumentChangeEvent, token: vscode.CancellationToken) {

version.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
3-
"version": "2.0-beta",
3+
"version": "2.0",
44
"publicReleaseRefSpec": [
5-
"^refs/heads/release$"
5+
"^refs/heads/release$",
6+
"^refs/heads/prerelease$"
67
],
78
"cloudBuild": {
89
"buildNumber": {

0 commit comments

Comments
 (0)