Skip to content

Commit

Permalink
Update packages
Browse files Browse the repository at this point in the history
  • Loading branch information
Matteo Prosperi committed Nov 1, 2023
1 parent c3b9e14 commit 7c196a1
Show file tree
Hide file tree
Showing 17 changed files with 84 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.41-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.41-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.48-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.48-preview-1" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.41-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.41-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.48-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.48-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.SDK" Version="17.6.36389" ExcludeAssets="runtime" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.41-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.41-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.48-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.48-preview-1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.41-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.41-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.48-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.48-preview-1" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions New_Extensibility_Model/Samples/InsertGuid/InsertGuid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.41-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.41-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.48-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.48-preview-1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.41-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.41-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.48-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.48-preview-1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.41-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.41-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.48-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.48-preview-1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.41-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.41-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.48-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.48-preview-1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.41-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.41-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.48-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.48-preview-1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,27 @@ This sample requires installing [Rust](https://www.rust-lang.org/tools/install)
The extension contains a code file that defines a language server provider and its properties starting with the `VisualStudioContribution` class attribute which makes the server available to Visual Studio:

```csharp
[VisualStudioContribution]
internal class RustLanguageServerProvider : LanguageServerProvider
{
[VisualStudioContribution]
internal class RustLanguageServerProvider : LanguageServerProvider
{
```

The `LanguageServerProviderConfiguration` property defines information about the server that is available to Visual Studio even before the extension is loaded:

```csharp
public override LanguageServerProviderConfiguration LanguageServerProviderConfiguration => new(
"%RustLspExtension.RustLanguageServerProvider.DisplayName%",
new[]
{
DocumentFilter.FromDocumentType(RustDocumentType)
});
public override LanguageServerProviderConfiguration LanguageServerProviderConfiguration => new(
"%RustLspExtension.RustLanguageServerProvider.DisplayName%",
new[]
{
DocumentFilter.FromDocumentType(RustDocumentType)
});
```

This configuration object allows setting the display name for the server and specifying one or more document filters. You can also specify a localized string as a display name from [string-resoures.json](./.vsextension/string-resources.json):

```json
{
"RustLspExtension.RustLanguageServerProvider.DisplayName": "Rust Analyzer LSP server"
"RustLspExtension.RustLanguageServerProvider.DisplayName": "Rust Analyzer LSP server"
}
```

Expand All @@ -47,27 +47,27 @@ Once a document that has a matching document type is opened, Visual Studio calls
In our sample, the rust-analyzer executable is launched and a duplex pipe is used to communicate with the process.

```csharp
public override Task<IDuplexPipe?> CreateServerConnectionAsync(CancellationToken cancellationToken)
{
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, @"rust-analyzer.exe");
info.RedirectStandardInput = true;
info.RedirectStandardOutput = true;
info.UseShellExecute = false;
info.CreateNoWindow = true;

Process process = new Process();
process.StartInfo = info;

if (process.Start())
{
return Task.FromResult<IDuplexPipe?>(new DuplexPipe(
PipeReader.Create(process.StandardOutput.BaseStream),
PipeWriter.Create(process.StandardInput.BaseStream)));
}

return Task.FromResult<IDuplexPipe?>(null);
}
public override Task<IDuplexPipe?> CreateServerConnectionAsync(CancellationToken cancellationToken)
{
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, @"rust-analyzer.exe");
info.RedirectStandardInput = true;
info.RedirectStandardOutput = true;
info.UseShellExecute = false;
info.CreateNoWindow = true;

Process process = new Process();
process.StartInfo = info;

if (process.Start())
{
return Task.FromResult<IDuplexPipe?>(new DuplexPipe(
PipeReader.Create(process.StandardOutput.BaseStream),
PipeWriter.Create(process.StandardInput.BaseStream)));
}

return Task.FromResult<IDuplexPipe?>(null);
}
```

## Disabling the server
Expand All @@ -79,16 +79,16 @@ In our sample, the rust-analyzer executable is launched and a duplex pipe is use
After `CreateServerConnectionAsync` completes, Visual Studio will attempt to initialize the server via the provided duplex pipe following standard LSP protocol. Once this step is done, `OnServerInitializationResultAsync` is called where `ServerInitializationResult` denotes if the server succeeded or failed to initialize, and if it failed `LanguageServerInitializationFailureInfo` will contain the exception and message provided by the language server.

```csharp
public override Task OnServerInitializationResultAsync(ServerInitializationResult serverInitializationResult, LanguageServerInitializationFailureInfo? initializationFailureInfo, CancellationToken cancellationToken)
{
if (serverInitializationResult == ServerInitializationResult.Failed)
{
// Log telemetry for failure and disable the server from being activated again.
this.Enabled = false;
}

return base.OnServerInitializationResultAsync(serverInitializationResult, initializationFailureInfo, cancellationToken);
}
public override Task OnServerInitializationResultAsync(ServerInitializationResult serverInitializationResult, LanguageServerInitializationFailureInfo? initializationFailureInfo, CancellationToken cancellationToken)
{
if (serverInitializationResult == ServerInitializationResult.Failed)
{
// Log telemetry for failure and disable the server from being activated again.
this.Enabled = false;
}

return base.OnServerInitializationResultAsync(serverInitializationResult, initializationFailureInfo, cancellationToken);
}
```

## Usage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
namespace RustLanguageServerProviderExtension;

using System.Diagnostics;
using System.IO;
using System.IO.Pipelines;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.VisualStudio.Extensibility;
using Microsoft.VisualStudio.Extensibility.Editor;
using Microsoft.VisualStudio.Extensibility.LanguageServer;
using Microsoft.VisualStudio.RpcContracts.LanguageServerProvider;
using Nerdbank.Streams;

#pragma warning disable VSEXTAPI0001 // This API is marked as Preview.
/// <inheritdoc/>
[VisualStudioContribution]
internal class RustLanguageServerProvider : LanguageServerProvider
Expand Down Expand Up @@ -71,3 +75,4 @@ public override Task OnServerInitializationResultAsync(ServerInitializationResul
return base.OnServerInitializationResultAsync(serverInitializationResult, initializationFailureInfo, cancellationToken);
}
}
#pragma warning restore VSEXTAPI0001 // This API is marked as Preview.
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<TargetFramework>net8.0-windows8.0</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>10</LangVersion>
<NoWarn>$(NoWarn);VSEXTAPI0001;</NoWarn>
<LangVersion>11</LangVersion>
<NeutralLanguage>en-US</NeutralLanguage>
<NoWarn>$(NoWarn);CS1591;CA1812;CA1303;SA1600</NoWarn>

<!-- The VisualStudio.Extensibility preview packages are available from the azure-public/vside/msft_consumption feed -->
<RestoreAdditionalProjectSources>https://pkgs.dev.azure.com/azure-public/vside/_packaging/msft_consumption/nuget/v3/index.json;$(RestoreAdditionalProjectSources)</RestoreAdditionalProjectSources>
</PropertyGroup>

<ItemGroup Condition="Exists('.\rust-analyzer.exe')">
<Content Include="rust-analyzer.exe" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.42-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.42-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.48-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.48-preview-1" />
</ItemGroup>

<ItemGroup Condition="Exists('.\rust-analyzer.exe')">
<Content Include="rust-analyzer.exe" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.41-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.41-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.48-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.48-preview-1" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.41-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.41-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.48-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.48-preview-1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.41-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.41-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.48-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.48-preview-1" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.41-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.41-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.48-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.48-preview-1" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.41-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.41-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.48-preview-1" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.48-preview-1" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 7c196a1

Please sign in to comment.