You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
InvokeAsync extension method internally handles the event handler being null, per recommendation patterns like "await StartAsync?.InvokeAsync" should be awaited since it will cause NullReferenceException in case StartAsync is null. Removing "?" and letting InvokeAsync handle it does the expected action which is a no-op
The main methods that need to be implemented are [OnLoadedAsync](/dotnet/api/microsoft.visualstudio.languageserver.client.ilanguageclient.onloadedasync?view=visualstudiosdk-2017) and [ActivateAsync](/dotnet/api/microsoft.visualstudio.languageserver.client.ilanguageclient.activateasync?view=visualstudiosdk-2017). [OnLoadedAsync](/dotnet/api/microsoft.visualstudio.languageserver.client.ilanguageclient.onloadedasync?view=visualstudiosdk-2017) is called when Visual Studio has loaded your extension and your language server is ready to be started. In this method, you can invoke the [StartAsync](/dotnet/api/microsoft.visualstudio.languageserver.client.ilanguageclient.startasync?view=visualstudiosdk-2017) delegate immediately to signal that the language server should be started, or you can do additional logic and invoke [StartAsync](/dotnet/api/microsoft.visualstudio.languageserver.client.ilanguageclient.startasync?view=visualstudiosdk-2017) later. **To activate your language server, you must call StartAsync at some point.**
213
213
@@ -220,7 +220,7 @@ Once your language client class is implemented, you'll need to define two attrib
In the previous example, a content type definition is created for files that end in *.bar* file extension. The content type definition is given the name "bar" and **must** derive from [CodeRemoteContentTypeName](/dotnet/api/microsoft.visualstudio.languageserver.client.coderemotecontentdefinition.coderemotecontenttypename?view=visualstudiosdk-2017).
269
269
@@ -275,7 +275,7 @@ After adding a content type definition, you can then define when to load your la
275
275
publicclassBarLanguageClient : ILanguageClient
276
276
{
277
277
}
278
-
```
278
+
```
279
279
280
280
Adding support for LSP language servers does not require you to implement your own project system in Visual Studio. Customers can open a single file or a folder in Visual Studio to start using your language service. In fact, support for LSP language servers is designed to work only in open folder/file scenarios. If a custom project system is implemented, some features (such as settings) will not work.
281
281
@@ -289,63 +289,63 @@ Follow these steps below to add support for settings to your LSP language servic
289
289
290
290
1. Add a JSON file (for example, *MockLanguageExtensionSettings.json*) in your project that contains the settings and their default values. For example:
291
291
292
-
```json
293
-
{
292
+
```json
293
+
{
294
294
"foo.maxNumberOfProblems": -1
295
-
}
296
-
```
295
+
}
296
+
```
297
297
2. Right-click on the JSON file and select **Properties**. Change the **Build** action to "Content" and the "Include in VSIX' property to true.
298
298
299
299
3. Implement ConfigurationSections and return the list of prefixes for the settings defined in the JSON file (In Visual Studio Code, this would map to the configuration section name in package.json):
300
300
301
-
```csharp
302
-
publicIEnumerable<string>ConfigurationSections
303
-
{
301
+
```csharp
302
+
publicIEnumerable<string>ConfigurationSections
303
+
{
304
304
get
305
305
{
306
306
yieldreturn"foo";
307
307
}
308
-
}
309
-
```
308
+
}
309
+
```
310
310
4. Add a .pkgdef file to the project (add new text file and change the file extension to .pkgdef). The pkgdef file should contain this info:
1. User opens a workspace containing files your server owns.
330
330
2. User adds a file in the *.vs* folder called *VSWorkspaceSettings.json*.
331
331
3. User adds a line to the *VSWorkspaceSettings.json* file for a setting the server provides. For example:
332
332
333
-
```json
334
-
{
333
+
```json
334
+
{
335
335
"foo.maxNumberOfProblems": 10
336
-
}
337
-
```
338
-
### Enabling diagnostics tracing
339
-
Diagnostics tracing can be enabled to output all messages between the client and server, which can be useful when debugging issues. To enable diagnostic tracing, do the following:
336
+
}
337
+
```
338
+
### Enabling diagnostics tracing
339
+
Diagnostics tracing can be enabled to output all messages between the client and server, which can be useful when debugging issues. To enable diagnostic tracing, do the following:
340
340
341
-
4. Open or create the workspace settings file *VSWorkspaceSettings.json* (see "User editing of settings for a workspace").
342
-
5. Add the following line in the settings json file:
341
+
4. Open or create the workspace settings file *VSWorkspaceSettings.json* (see "User editing of settings for a workspace").
342
+
5. Add the following line in the settings json file:
343
343
344
344
```json
345
345
{
346
346
"foo.trace.server": "Off"
347
347
}
348
-
```
348
+
```
349
349
350
350
There are three possible values for trace verbosity:
351
351
* "Off": tracing turned off completely
@@ -391,7 +391,7 @@ internal class MockCustomLanguageClient : MockLanguageClient, ILanguageClientCus
391
391
}
392
392
}
393
393
}
394
-
```
394
+
```
395
395
396
396
#### Sending custom messages
397
397
@@ -424,7 +424,7 @@ internal class MockCustomLanguageClient : MockLanguageClient, ILanguageClientCus
0 commit comments