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: 6 additions & 1 deletion eng/Signing.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!--
The `Condition` in this Import was added because publishing pipelines rely
on importing this file but it doesn't import MPack.props.
The condition can be removed once this issue is fixed:
The condition can be removed once this issue is fixed:
https://github.com/dotnet/arcade/issues/2371
-->
<Import Project="MPack.props" Condition="Exists('MPack.props')" />
Expand All @@ -14,6 +14,11 @@
-->
<ItemGroup>
<FileSignInfo Include="Newtonsoft.Json.dll" CertificateName="3PartySHA2" />
<FileSignInfo Include="MediatR.dll" CertificateName="3PartySHA2" />
<FileSignInfo Include="MediatR.Extensions.Microsoft.DependencyInjection.dll" CertificateName="3PartySHA2" />
<FileSignInfo Include="OmniSharp.Extensions.JsonRpc.dll" CertificateName="3PartySHA2" />
<FileSignInfo Include="OmniSharp.Extensions.LanguageProtocol.dll" CertificateName="3PartySHA2" />
<FileSignInfo Include="OmniSharp.Extensions.LanguageServer.dll" CertificateName="3PartySHA2" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.LanguageServer.Common\Microsoft.AspNetCore.Razor.LanguageServer.Common.csproj" />
</ItemGroup>

<Target Name="_GetOutputPath" Returns="@(_ServerOutputPath)">
<ItemGroup>
<_ServerOutputPath Include="$(OutputPath)">
</_ServerOutputPath>
</ItemGroup>
</Target>

<Target Name="_IncludeOmniSharpPlugin" Condition="Exists('$(PublishDir)')">
<PropertyGroup>
<TargetPluginOutputPath>$(PublishDir)\OmniSharpPlugin</TargetPluginOutputPath>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.VisualStudio.LanguageServer.Client;
using Microsoft.VisualStudio.Threading;
using Microsoft.VisualStudio.Utilities;

namespace Microsoft.VisualStudio.LanguageServerClient.Razor
{
[Export(typeof(ILanguageClient))]
[ContentType(RazorLSPContentTypeDefinition.Name)]
internal class RazorLanguageServerClient : ILanguageClient
{
public string Name => "Razor Language Server Client";

public IEnumerable<string> ConfigurationSections => null;

public object InitializationOptions => null;

public IEnumerable<string> FilesToWatch => null;

public event AsyncEventHandler<EventArgs> StartAsync;
public event AsyncEventHandler<EventArgs> StopAsync
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the add/remove explicitly defined here but implicitly defined for StartAsync?

Also, I don't see anywhere that StopAsync is actually called? I suspect I misunderstand the workflow of ILanguageClient. Could you go into the expected flow a bit?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StartAsync is called when we actually start the language server but we don't actually take control of stopping the language server currently. We rely on the ILanguageClient infrastructure to stop us. The gist here is that our ILanguageClient is very "dumb" currently. It's just the boiler plate to start a basic language server and then I plan to fill it out later as we flesh it all out more.

{
add { }
remove { }
}

public async Task<Connection> ActivateAsync(CancellationToken token)
{
await Task.Yield();

var currentAssembly = typeof(RazorLanguageServerClient).Assembly;
var currentAssemblyLocation = currentAssembly.Location;
var extensionDirectory = Path.GetDirectoryName(currentAssemblyLocation);
var languageServerPath = Path.Combine(extensionDirectory, "LanguageServer", "rzls.exe");
var info = new ProcessStartInfo();
info.FileName = languageServerPath;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible nit:

var info = new ProcessStartInfo{
    info.FileName = languageServerPath,
    // ...
}

info.Arguments = "-lsp --logLevel Trace";
info.RedirectStandardInput = true;
info.RedirectStandardOutput = true;
info.UseShellExecute = false;
info.CreateNoWindow = true;

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

if (process.Start())
{
return new Connection(process.StandardOutput.BaseStream, process.StandardInput.BaseStream);
}

return null;
}

public async Task OnLoadedAsync()
{
await StartAsync.InvokeAsync(this, EventArgs.Empty);
}

public Task OnServerInitializeFailedAsync(Exception e)
{
return Task.CompletedTask;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All three of these functions strike me as in need of diagnostic logging (but especially OnServerInitializeFailedAsync). Would it be possible to add a constructor that takes a logger so it can be used here, or will the DI system not enable that?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're definitely right. We'll expand on the implementation of this class in the coming months. For now it's just basic boiler plate to get the ball rolling 😄

}

public Task OnServerInitializedAsync()
{
return Task.CompletedTask;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<IsPackable>false</IsPackable>
</PropertyGroup>

<!-- Include Razor SDK design time assets in the VSIX -->
<!-- Include Razor SDK design time assets in the VSIX -->
<ItemGroup>
<Content Include="..\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.DesignTime.targets">
<IncludeInVsix>true</IncludeInVsix>
Expand Down Expand Up @@ -113,6 +113,29 @@
<_GeneratedVSIXBindingRedirectFile>$(IntermediateOutputPath)$(MSBuildProjectName).BindingRedirects.cs</_GeneratedVSIXBindingRedirectFile>
</PropertyGroup>

<Target Name="_BuildLanguageServer">
<MSBuild Projects="..\Microsoft.AspNetCore.Razor.LanguageServer\Microsoft.AspNetCore.Razor.LanguageServer.csproj"
Targets="Build" />
</Target>

<Target Name="_IncludeLanguageServer" DependsOnTargets="PrepareForBuild;_BuildLanguageServer" BeforeTargets="CoreCompile">
<MSBuild Projects="..\Microsoft.AspNetCore.Razor.LanguageServer\Microsoft.AspNetCore.Razor.LanguageServer.csproj"
Targets="_GetOutputPath">
<Output TaskParameter="TargetOutputs" ItemName="_ResolvedPackageVersionInfo" />
</MSBuild>

<PropertyGroup>
<_ResolvedPackageVersionInfoProperty>@(_ResolvedPackageVersionInfo)</_ResolvedPackageVersionInfoProperty>
</PropertyGroup>

<ItemGroup>
<Content Include="$(_ResolvedPackageVersionInfoProperty)\*">
<IncludeInVsix>true</IncludeInVsix>
<VSIXSubPath>LanguageServer\</VSIXSubPath>
</Content>
</ItemGroup>
</Target>

<Target Name="_GenerateVSIXBindingRedirects" DependsOnTargets="PrepareForBuild;GetAssemblyVersion" BeforeTargets="CoreCompile" Inputs="$(MSBuildAllProjects)" Outputs="$(_GeneratedVSIXBindingRedirectFile)">
<ItemGroup>
<BindingRedirectAssemblies Include="@(ProjectReference)" AssemblyName="%(Filename)" />
Expand Down