Skip to content

Commit c53f5e2

Browse files
authored
Merge pull request #5869 from dibarbet/merge_main_to_prerelease
Merge main to prerelease
2 parents 88c61f3 + 2881a9d commit c53f5e2

File tree

6 files changed

+82
-27
lines changed

6 files changed

+82
-27
lines changed

.vscode/launch.json

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@
4141
"request": "launch",
4242
"runtimeExecutable": "${execPath}",
4343
"args": [
44-
"--disable-extensions",
44+
// Create a temp profile that has no extensions / user settings.
45+
// This allows us to only have the C# extension + the dotnet runtime installer extension dependency.
46+
"--profile-temp",
4547
"--extensionDevelopmentPath=${workspaceRoot}",
4648
"--extensionTestsPath=${workspaceRoot}/out/test/featureTests"
4749
],
@@ -63,7 +65,9 @@
6365
"request": "launch",
6466
"runtimeExecutable": "${execPath}",
6567
"args": [
66-
"--disable-extensions",
68+
// Create a temp profile that has no extensions / user settings.
69+
// This allows us to only have the C# extension + the dotnet runtime installer extension dependency.
70+
"--profile-temp",
6771
"${workspaceRoot}/test/integrationTests/testAssets/singleCsproj",
6872
"--extensionDevelopmentPath=${workspaceRoot}",
6973
"--extensionTestsPath=${workspaceRoot}/out/test/integrationTests"
@@ -78,7 +82,8 @@
7882
},
7983
"sourceMaps": true,
8084
"outFiles": [
81-
"${workspaceRoot}/dist/*.js"
85+
"${workspaceRoot}/dist/*.js",
86+
"${workspaceRoot}/out/test/**/*.js"
8287
],
8388
"preLaunchTask": "buildDev"
8489
},
@@ -88,7 +93,9 @@
8893
"request": "launch",
8994
"runtimeExecutable": "${execPath}",
9095
"args": [
91-
"--disable-extensions",
96+
// Create a temp profile that has no extensions / user settings.
97+
// This allows us to only have the C# extension + the dotnet runtime installer extension dependency.
98+
"--profile-temp",
9299
"${workspaceRoot}/test/integrationTests/testAssets/BasicRazorApp2_1",
93100
"--extensionDevelopmentPath=${workspaceRoot}",
94101
"--extensionTestsPath=${workspaceRoot}/out/test/integrationTests"
@@ -108,7 +115,9 @@
108115
"request": "launch",
109116
"runtimeExecutable": "${execPath}",
110117
"args": [
111-
"--disable-extensions",
118+
// Create a temp profile that has no extensions / user settings.
119+
// This allows us to only have the C# extension + the dotnet runtime installer extension dependency.
120+
"--profile-temp",
112121
"${workspaceRoot}/test/integrationTests/testAssets/slnWithCsproj",
113122
"--extensionDevelopmentPath=${workspaceRoot}",
114123
"--extensionTestsPath=${workspaceRoot}/out/test/integrationTests"
@@ -124,7 +133,8 @@
124133
"stopOnEntry": false,
125134
"sourceMaps": true,
126135
"outFiles": [
127-
"${workspaceRoot}/dist/*.js"
136+
"${workspaceRoot}/dist/*.js",
137+
"${workspaceRoot}/out/test/**/*.js"
128138
],
129139
"preLaunchTask": "buildDev"
130140
},
@@ -134,7 +144,9 @@
134144
"request": "launch",
135145
"runtimeExecutable": "${execPath}",
136146
"args": [
137-
"--disable-extensions",
147+
// Create a temp profile that has no extensions / user settings.
148+
// This allows us to only have the C# extension + the dotnet runtime installer extension dependency.
149+
"--profile-temp",
138150
"${workspaceRoot}/test/integrationTests/testAssets/singleCsproj",
139151
"--extensionDevelopmentPath=${workspaceRoot}",
140152
"--extensionTestsPath=${workspaceRoot}/out/test/integrationTests"
@@ -150,7 +162,8 @@
150162
"stopOnEntry": false,
151163
"sourceMaps": true,
152164
"outFiles": [
153-
"${workspaceRoot}/dist/*.js"
165+
"${workspaceRoot}/dist/*.js",
166+
"${workspaceRoot}/out/test/**/*.js"
154167
],
155168
"preLaunchTask": "buildDev"
156169
},
@@ -160,7 +173,9 @@
160173
"request": "launch",
161174
"runtimeExecutable": "${execPath}",
162175
"args": [
163-
"--disable-extensions",
176+
// Create a temp profile that has no extensions / user settings.
177+
// This allows us to only have the C# extension + the dotnet runtime installer extension dependency.
178+
"--profile-temp",
164179
"${workspaceRoot}/test/integrationTests/testAssets/BasicRazorApp2_1",
165180
"--extensionDevelopmentPath=${workspaceRoot}",
166181
"--extensionTestsPath=${workspaceRoot}/out/test/integrationTests"
@@ -180,7 +195,9 @@
180195
"request": "launch",
181196
"runtimeExecutable": "${execPath}",
182197
"args": [
183-
"--disable-extensions",
198+
// Create a temp profile that has no extensions / user settings.
199+
// This allows us to only have the C# extension + the dotnet runtime installer extension dependency.
200+
"--profile-temp",
184201
"${workspaceRoot}/test/integrationTests/testAssets/slnWithCsproj",
185202
"--extensionDevelopmentPath=${workspaceRoot}",
186203
"--extensionTestsPath=${workspaceRoot}/out/test/integrationTests"
@@ -195,7 +212,8 @@
195212
},
196213
"sourceMaps": true,
197214
"outFiles": [
198-
"${workspaceRoot}/dist/*.js"
215+
"${workspaceRoot}/dist/*.js",
216+
"${workspaceRoot}/out/test/**/*.js"
199217
],
200218
"preLaunchTask": "buildDev"
201219
},
@@ -205,7 +223,9 @@
205223
"request": "launch",
206224
"runtimeExecutable": "${execPath}",
207225
"args": [
208-
"--disable-extensions",
226+
// Create a temp profile that has no extensions / user settings.
227+
// This allows us to only have the C# extension + the dotnet runtime installer extension dependency.
228+
"--profile-temp",
209229
"${workspaceRoot}/test/integrationTests/testAssets/slnFilterWithCsproj",
210230
"--extensionDevelopmentPath=${workspaceRoot}",
211231
"--extensionTestsPath=${workspaceRoot}/out/test/integrationTests"
@@ -219,7 +239,8 @@
219239
},
220240
"sourceMaps": true,
221241
"outFiles": [
222-
"${workspaceRoot}/dist/*.js"
242+
"${workspaceRoot}/dist/*.js",
243+
"${workspaceRoot}/out/test/**/*.js"
223244
],
224245
"preLaunchTask": "buildDev"
225246
},
@@ -229,7 +250,9 @@
229250
"request": "launch",
230251
"runtimeExecutable": "${execPath}",
231252
"args": [
232-
"--disable-extensions",
253+
// Create a temp profile that has no extensions / user settings.
254+
// This allows us to only have the C# extension + the dotnet runtime installer extension dependency.
255+
"--profile-temp",
233256
"${workspaceRoot}/test/integrationTests/testAssets/slnWithGenerator",
234257
"--extensionDevelopmentPath=${workspaceRoot}",
235258
"--extensionTestsPath=${workspaceRoot}/out/test/integrationTests"
@@ -243,7 +266,8 @@
243266
},
244267
"sourceMaps": true,
245268
"outFiles": [
246-
"${workspaceRoot}/dist/*.js"
269+
"${workspaceRoot}/dist/*.js",
270+
"${workspaceRoot}/out/test/**/*.js"
247271
],
248272
"preLaunchTask": "buildDev"
249273
},

CONTRIBUTING.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,24 @@ To **test** do the following: `npm run test` or <kbd>F5</kbd> in VS Code with th
2323

2424
### Using a locally developed Roslyn server
2525

26-
https://github.com/dotnet/roslyn contains the server implementation. Follow the instructions there to build the repo as normal. Once built, the server executable will be located in the build output directory, typically
26+
https://github.com/dotnet/roslyn contains the server implementation. Follow the instructions there to build the repo as normal. Once built, the server executable will be located in the build output directory, typically
2727

2828
`$roslynRepoRoot/artifacts/bin/Microsoft.CodeAnalysis.LanguageServer/Debug/net7.0/Microsoft.CodeAnalysis.LanguageServer.exe`
2929

3030
depending on which configuration is built. Then, launch the extension here and change the VSCode setting `dotnet.server.path` to point to the Roslyn executable path you built above and restart the language server.
3131

3232
If you need to debug the server, you can set the VSCode setting `dotnet.server.waitForDebugger` to true. This will trigger a `Debugger.Launch()` on the server side as it starts.
3333

34+
### Using a locally developed Razor server
35+
36+
https://github.com/dotnet/razor contains the server implementation. Follow the instructions there to build the repo as normal. Once built, the server will be located in the build output directory, typically
37+
38+
`$razorRepoRoot/artifacts/bin/rzls/Debug/net7.0`
39+
40+
depending on which configuration is built. Then, launch the extension here and change the VSCode setting `razor.languageServer.directory` to point to the Razor executable path you built above and reload the window.
41+
42+
If you need to debug the server, you can set the VSCode setting `razor.languageServer.debug` to true. This will trigger a `Debugger.Launch()` on the server side as it starts. You can also set `razor.trace` to `Verbose` to get more log messages in the output window
43+
3444
### Creating VSIXs
3545

3646
VSIXs can be created using the gulp command `gulp vsix:release:package`. This will create all the platform specific VSIXs that you can then install manually in VSCode.
@@ -42,4 +52,4 @@ To update the version of the roslyn server used by the extension do the followin
4252
2. In the official build stage, look for the `Publish Assets` step. In there you will see it publishing the `Microsoft.CodeAnalysis.LanguageServer` package with some version, e.g. `4.6.0-3.23158.4`. Take note of that version number.
4353
3. In the [package.json](package.json) inside the `defaults` section update the `roslyn` key to point to the version number you found above in step 2.
4454
4. Build and test the change (make sure to run `gulp installDependencies` to get the new version!). If everything looks good, submit a PR.
45-
* Adding new package versions might require authentication, run with the `--interactive` flag to login. You may need to install [azure artifacts nuget credential provider](https://github.com/microsoft/artifacts-credprovider#installation-on-windows) to run interactive authentication.
55+
* Adding new package versions might require authentication, run with the `--interactive` flag to login. You may need to install [azure artifacts nuget credential provider](https://github.com/microsoft/artifacts-credprovider#installation-on-windows) to run interactive authentication.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"displayName": "C#",
77
"author": "Microsoft Corporation",
88
"license": "SEE LICENSE IN RuntimeLicenses/license.txt",
9+
"qna": "https://github.com/dotnet/vscode-csharp/issues",
910
"icon": "images/csharpIcon.png",
1011
"preview": false,
1112
"bugs": {
@@ -35,7 +36,7 @@
3536
}
3637
},
3738
"defaults": {
38-
"roslyn": "4.7.0-3.23316.4",
39+
"roslyn": "4.7.0-3.23326.2",
3940
"omniSharp": "1.39.6",
4041
"razor": "7.0.0-preview.23275.2"
4142
},

src/lsptoolshost/roslynLanguageServer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ export class RoslynLanguageServer {
433433
if (serverPath.endsWith('.dll')) {
434434
// If we were given a path to a dll, launch that via dotnet.
435435
const argsWithPath = [ serverPath ].concat(args);
436-
childProcess = cp.spawn('dotnet', argsWithPath, cpOptions);
436+
childProcess = cp.spawn(dotnetExecutablePath, argsWithPath, cpOptions);
437437
} else {
438438
// Otherwise assume we were given a path to an executable.
439439
childProcess = cp.spawn(serverPath, args, cpOptions);

src/razor/src/Completion/RazorCompletionItemProvider.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { getUriPath } from '../UriPaths';
1313
import { ProvisionalCompletionOrchestrator } from './ProvisionalCompletionOrchestrator';
1414
import { LanguageKind } from '../RPC/LanguageKind';
1515
import { RoslynLanguageServer } from '../../../lsptoolshost/roslynLanguageServer';
16-
import { CompletionItem, CompletionParams, CompletionTriggerKind } from 'vscode-languageclient';
16+
import { CompletionItem, CompletionList, CompletionParams, CompletionTriggerKind, MarkupContent } from 'vscode-languageclient';
1717
import { UriConverter } from '../../../lsptoolshost/uriConverter';
1818
import * as RazorConventions from '../RazorConventions';
1919
import { MappingHelpers } from '../Mapping/MappingHelpers';
@@ -35,11 +35,6 @@ export class RazorCompletionItemProvider
3535

3636
let completions: vscode.CompletionList | vscode.CompletionItem[];
3737

38-
// For CSharp, completions need to keep the "data" field
39-
// on the completion item for lazily resolving the edits in
40-
// the resolveCompletionItem step. Using the vs code command
41-
// drops that field because it doesn't exist in the declared vs code
42-
// CompletionItem type.
4338
if (language === LanguageKind.CSharp) {
4439
const params: CompletionParams = {
4540
context: {
@@ -52,6 +47,11 @@ export class RazorCompletionItemProvider
5247
position: projectedPosition
5348
};
5449

50+
// For CSharp, completions need to keep the "data" field on the
51+
// completion item for lazily resolving the edits in the
52+
// resolveCompletionItem step. Using the vs code command drops
53+
// that field because it doesn't exist in the declared vs code
54+
// CompletionItem type.
5555
completions = await vscode
5656
.commands
5757
.executeCommand<vscode.CompletionList | vscode.CompletionItem[]>(
@@ -71,6 +71,8 @@ export class RazorCompletionItemProvider
7171
completions instanceof Array ? completions // was vscode.CompletionItem[]
7272
: completions ? completions.items // was vscode.CompletionList
7373
: [];
74+
75+
const data = (<CompletionList>completions)?.itemDefaults?.data;
7476

7577
// There are times when the generated code will not line up with the content of the .razor/.cshtml file.
7678
// Therefore, we need to offset all completion items' characters by a certain amount in order
@@ -79,7 +81,7 @@ export class RazorCompletionItemProvider
7981
const completionCharacterOffset = projectedPosition.character - hostDocumentPosition.character;
8082
for (const completionItem of completionItems) {
8183
const doc = completionItem.documentation as vscode.MarkdownString;
82-
if (doc) {
84+
if (doc && doc.value) {
8385
// Without this, the documentation doesn't get rendered in the editor.
8486
const newDoc = new vscode.MarkdownString(doc.value);
8587
newDoc.isTrusted = doc.isTrusted;
@@ -128,6 +130,10 @@ export class RazorCompletionItemProvider
128130
completionItem.insertText = intellicodeCompletion.textEditText;
129131
}
130132
}
133+
134+
if (!(<CompletionItem>completionItem).data) {
135+
(<CompletionItem>completionItem).data = data;
136+
}
131137
}
132138

133139
const isIncomplete = completions instanceof Array ? false
@@ -204,6 +210,13 @@ export class RazorCompletionItemProvider
204210

205211
item = newItem;
206212

213+
// The documentation object Roslyn returns is a MarkupContent,
214+
// which we need to convert to a MarkdownString.
215+
const markupContent = <MarkupContent>(<unknown>(item.documentation));
216+
if (markupContent && markupContent.value) {
217+
item.documentation = new vscode.MarkdownString(markupContent.value);
218+
}
219+
207220
if (item.command && item.command.arguments?.length === 4) {
208221
let uri = vscode.Uri.parse(item.command.arguments[0]);
209222

@@ -238,4 +251,3 @@ function getTriggerKind(triggerKind: vscode.CompletionTriggerKind): CompletionTr
238251

239252
}
240253
}
241-

test/integrationTests/integrationHelpers.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ export interface ActivationResult {
1616
}
1717

1818
export async function activateCSharpExtension(): Promise<ActivationResult> {
19+
// Ensure the dependent extension exists - when launching via F5 launch.json we can't install the extension prior to opening vscode.
20+
const vscodeDotnetRuntimeExtensionId = "ms-dotnettools.vscode-dotnet-runtime";
21+
let dotnetRuntimeExtension = vscode.extensions.getExtension<OmnisharpExtensionExports>(vscodeDotnetRuntimeExtensionId);
22+
if (!dotnetRuntimeExtension) {
23+
await vscode.commands.executeCommand("workbench.extensions.installExtension", vscodeDotnetRuntimeExtensionId);
24+
await vscode.commands.executeCommand("workbench.action.reloadWindow");
25+
}
26+
1927
const configuration = vscode.workspace.getConfiguration();
2028
configuration.update('omnisharp.enableLspDriver', process.env.OMNISHARP_DRIVER === 'lsp' ? true : false);
2129
if (process.env.OMNISHARP_LOCATION) {

0 commit comments

Comments
 (0)