Skip to content
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
- Debug from .csproj and .sln [#5876](https://github.com/dotnet/vscode-csharp/issues/5876)

# 2.102.x
* Update Roslyn to 5.3.0-2.25568.9 (PR: [#8799](https://github.com/dotnet/vscode-csharp/pull/8799))
* Handle automatic restores on directly on the server (PR: [#81233](https://github.com/dotnet/roslyn/pull/81233))
* Only treat a file with directives as an FBP (PR: [#81307](https://github.com/dotnet/roslyn/pull/81307))
* Document excerpt for Razor, and fix Find All Refs (PR: [#81291](https://github.com/dotnet/roslyn/pull/81291))
* Filter IntelliSense attribute suggestions by AttributeTargets (PR: [#81157](https://github.com/dotnet/roslyn/pull/81157))
* Fix IDE0055: Enforce import directive grouping when groups are contiguous, regardless of sorting (PR: [#81202](https://github.com/dotnet/roslyn/pull/81202))
* Fix indentation of if statement after else on separate line (PR: [#81178](https://github.com/dotnet/roslyn/pull/81178))
* Automatically reload extension when workspace is trusted (PR: [#8794](https://github.com/dotnet/vscode-csharp/pull/8794))
* Update to new language client with range semantic tokens refresh (PR: [#8783](https://github.com/dotnet/vscode-csharp/pull/8783))
* Bump Razor to 10.0.0-preview.25564.2 (PR: [#8790](https://github.com/dotnet/vscode-csharp/pull/8790))
Expand Down
1 change: 0 additions & 1 deletion l10n/bundle.l10n.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@
"Suppress notification": "Suppress notification",
"Restore {0}": "Restore {0}",
"Restore already in progress": "Restore already in progress",
"Sending request": "Sending request",
"C# Project Context Status": "C# Project Context Status",
"Active File Context": "Active File Context",
"Initializing dotnet-trace.../dotnet-trace is a command name and should not be localized": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"workspace"
],
"defaults": {
"roslyn": "5.3.0-2.25557.6",
"roslyn": "5.3.0-2.25568.9",
"omniSharp": "1.39.14",
"razor": "10.0.0-preview.25564.2",
"razorOmnisharp": "7.0.0-preview.23363.1",
Expand Down
91 changes: 17 additions & 74 deletions src/lsptoolshost/projectRestore/restore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,11 @@

import * as vscode from 'vscode';
import { RoslynLanguageServer } from '../server/roslynLanguageServer';
import {
RestorableProjects,
RestoreParams,
RestorePartialResult,
RestoreRequest,
ProjectNeedsRestoreRequest,
} from '../server/roslynProtocol';
import { RestorableProjects, RestoreParams, RestoreRequest } from '../server/roslynProtocol';
import path from 'path';
import { showErrorMessage } from '../../shared/observers/utils/showMessage';
import { getCSharpDevKit } from '../../utils/getCSharpDevKit';
import { CancellationToken } from 'vscode-jsonrpc';

let _restoreInProgress = false;

Expand All @@ -32,33 +27,10 @@ export function registerRestoreCommands(
);
context.subscriptions.push(
vscode.commands.registerCommand('dotnet.restore.all', async (): Promise<void> => {
return restore(languageServer, csharpOutputChannel, [], true);
return restore(languageServer, csharpOutputChannel, []);
})
);
}

languageServer.registerOnRequest(ProjectNeedsRestoreRequest.type, async (params) => {
let projectFilePaths = params.projectFilePaths;
if (getCSharpDevKit()) {
// Only restore '.cs' files (file-based apps) if CDK is loaded.
const csharpFiles = [];
for (const path of projectFilePaths) {
if (path.endsWith('.cs')) {
csharpFiles.push(path);
} else {
csharpOutputChannel.debug(
`[.NET Restore] Not restoring '${path}' from C# extension, because C# Dev Kit is expected to handle restore for it.`
);
}
}

projectFilePaths = csharpFiles;
}

if (projectFilePaths.length > 0) {
await restore(languageServer, csharpOutputChannel, params.projectFilePaths, false);
}
});
}

async function chooseProjectAndRestore(
Expand Down Expand Up @@ -93,63 +65,34 @@ async function chooseProjectAndRestore(
return;
}

await restore(languageServer, outputChannel, [pickedItem.description!], true);
await restore(languageServer, outputChannel, [pickedItem.description!]);
}

export async function restore(
languageServer: RoslynLanguageServer,
outputChannel: vscode.LogOutputChannel,
projectFiles: string[],
showOutput: boolean
projectFiles: string[]
): Promise<void> {
if (_restoreInProgress) {
showErrorMessage(vscode, vscode.l10n.t('Restore already in progress'));
return;
}
_restoreInProgress = true;
if (showOutput) {
outputChannel.show(true);
}
outputChannel.show(true);

const request: RestoreParams = { projectFilePaths: projectFiles };
await vscode.window
.withProgress(
{
location: vscode.ProgressLocation.Notification,
title: vscode.l10n.t('Restore'),
cancellable: true,
},
async (progress, token) => {
const writeOutput = (output: RestorePartialResult) => {
if (output.message) {
outputChannel.debug(`[.NET Restore] ${output.message}`);
}

progress.report({ message: output.stage });
};

progress.report({ message: vscode.l10n.t('Sending request') });
const responsePromise = languageServer.sendRequestWithProgress(
RestoreRequest.type,
request,
async (p) => writeOutput(p),
token
);

await responsePromise.then(
(result) => result.forEach((r) => writeOutput(r)),
(err) => outputChannel.error(`[.NET Restore] ${err}`)
);
}
)
.then(
() => {
_restoreInProgress = false;
},
() => {
_restoreInProgress = false;
}
);
// server will show a work done progress with cancellation. no need to pass a token to the request.
const resultPromise = languageServer.sendRequest(RestoreRequest.type, request, CancellationToken.None).then(
() => {
_restoreInProgress = false;
},
(err) => {
outputChannel.error(`[.NET Restore] ${err}`);
_restoreInProgress = false;
}
);

await resultPromise;
return;
}
19 changes: 3 additions & 16 deletions src/lsptoolshost/server/roslynProtocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,8 @@ export interface RestoreParams extends WorkDoneProgressParams, PartialResultPara
projectFilePaths: string[];
}

export interface RestorePartialResult {
stage: string;
message: string;
export interface RestoreResult {
success: boolean;
}

export interface ProjectNeedsRestoreName {
Expand Down Expand Up @@ -336,13 +335,7 @@ export namespace CodeActionFixAllResolveRequest {
export namespace RestoreRequest {
export const method = 'workspace/_roslyn_restore';
export const messageDirection: MessageDirection = MessageDirection.clientToServer;
export const type = new ProtocolRequestType<
RestoreParams,
RestorePartialResult[],
RestorePartialResult,
void,
void
>(method);
export const type = new RequestType<RestoreParams, RestoreResult, void>(method);
}

export namespace RestorableProjects {
Expand All @@ -351,12 +344,6 @@ export namespace RestorableProjects {
export const type = new RequestType0<string[], void>(method);
}

export namespace ProjectNeedsRestoreRequest {
export const method = 'workspace/_roslyn_projectNeedsRestore';
export const messageDirection: MessageDirection = MessageDirection.serverToClient;
export const type = new RequestType<ProjectNeedsRestoreName, void, void>(method);
}

export namespace SourceGeneratorGetTextRequest {
export const method = 'sourceGeneratedDocument/_roslyn_getText';
export const messageDirection: MessageDirection = MessageDirection.clientToServer;
Expand Down