зеркало из https://github.com/dotnet/razor.git
Integrate Razor LanguageServer (without plugin) into src/Razor.
- Added tests for both the language server and the common language server projects. - Updated publish MSBuild bits to publish to `artifacts/LanguageServer/$(Configuration)/TFM` - Updated the language server to be netcoreapp3.0 aspnet/AspNetCore#13494
This commit is contained in:
Родитель
8f92ae5457
Коммит
984c638b37
|
@ -8,4 +8,24 @@
|
|||
Text="$(RazorExtensionVSIXName) was not generated."
|
||||
Condition="!Exists('$(VSSetupDir)$(Configuration)\$(RazorExtensionVSIXName)')" />
|
||||
</Target>
|
||||
|
||||
<Target Name="_ZipLanguageServerBinaries" AfterTargets="Pack" Condition=" '$(OS)' == 'Windows_NT' ">
|
||||
<!-- Build a .zip file from each platform's directory and write it to 'artifacts' -->
|
||||
<PropertyGroup>
|
||||
<RidsPublishDir>$(ArtifactsDir)LanguageServer\$(Configuration)\</RidsPublishDir>
|
||||
<ZipOutputDir>$(RidsPublishDir)</ZipOutputDir>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<LanguageServiceBinaryDir Include="$([System.IO.Directory]::GetDirectories("$(RidsPublishDir)"))" />
|
||||
<LanguageServiceBinary Include="@(LanguageServiceBinaryDir)">
|
||||
<SourceDir>%(LanguageServiceBinaryDir.Identity)</SourceDir>
|
||||
<ZipFile>$(ZipOutputDir)RazorLanguageServer-%(LanguageServiceBinaryDir.Filename)-$(PackageVersion).zip</ZipFile>
|
||||
</LanguageServiceBinary>
|
||||
</ItemGroup>
|
||||
|
||||
<MakeDir Directories="$(ZipOutputDir)" />
|
||||
<Delete Files="%(LanguageServiceBinary.ZipFile)" />
|
||||
<Exec Command="powershell.exe -NonInteractive -command "&{ Write-Host "Writing %(LanguageServiceBinary.ZipFile)..." ; Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::CreateFromDirectory('%(LanguageServiceBinary.SourceDir)', '%(LanguageServiceBinary.ZipFile)') }"" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
<Project>
|
||||
|
||||
<Target Name="_PublishLanguageServerRids" AfterTargets="Pack" Condition=" '$(OS)' == 'Windows_NT' ">
|
||||
<PropertyGroup>
|
||||
<LanguageServerProject>$(MSBuildThisFileDirectory)..\src\Razor\src\Microsoft.AspNetCore.Razor.LanguageServer\Microsoft.AspNetCore.Razor.LanguageServer.csproj</LanguageServerProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<MSBuild Projects="$(LanguageServerProject)"
|
||||
Targets="PublishAllRids" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
|
@ -120,6 +120,7 @@
|
|||
<MoqPackageVersion>4.10.0</MoqPackageVersion>
|
||||
<!-- STOP!!! We need to reference the version of JSON that our HOSTS supprt. -->
|
||||
<NewtonsoftJsonPackageVersion>9.0.1</NewtonsoftJsonPackageVersion>
|
||||
<OmniSharpExtensionsLanguageServerPackageVersion>0.13.1</OmniSharpExtensionsLanguageServerPackageVersion>
|
||||
<VS_NewtonsoftJsonPackageVersion>12.0.1</VS_NewtonsoftJsonPackageVersion>
|
||||
<VSMAC_NewtonsoftJsonPackageVersion>10.0.3</VSMAC_NewtonsoftJsonPackageVersion>
|
||||
<TEST_NewtonsoftJsonPackageVersion>12.0.1</TEST_NewtonsoftJsonPackageVersion>
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<Description>Razor is a markup syntax for adding server-side logic to web pages. This package contains common assets that are used in the Razor language server and other assemblies.</Description>
|
||||
<EnableApiCheck>false</EnableApiCheck>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X" Version="$(MicrosoftAspNetCoreMvcRazorExtensionsVersion1_XPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X" Version="$(MicrosoftAspNetCoreMvcRazorExtensionsVersion2_XPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.Extensions" Version="$(MicrosoftAspNetCoreMvcRazorExtensionsPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Razor.Workspaces" Version="$(MicrosoftCodeAnalysisRazorWorkspacesPackageVersion)" />
|
||||
|
||||
<!-- Needed to make use of the adhoc workspace -->
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Features" Version="$(MicrosoftCodeAnalysisCSharpFeaturesPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.Features" Version="$(MicrosoftCodeAnalysisVisualBasicFeaturesPackageVersion)" />
|
||||
|
||||
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -1,42 +0,0 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="PublishAll.targets" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<OutputType>Exe</OutputType>
|
||||
<Description>Razor is a markup syntax for adding server-side logic to web pages. This package contains a Razor language server.</Description>
|
||||
<EnableApiCheck>false</EnableApiCheck>
|
||||
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;osx-x64;</RuntimeIdentifiers>
|
||||
<AssemblyName>rzls</AssemblyName>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="OmniSharp.Extensions.LanguageServer" Version="$(OmniSharpExtensionsLanguageServerPackageVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.LanguageServer.Common\Microsoft.AspNetCore.Razor.LanguageServer.Common.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PublishLanguageServerNativeExecutables" AfterTargets="Pack" DependsOnTargets="PublishAllRids" />
|
||||
|
||||
<Target Name="IncludeOmniSharpPlugin" AfterTargets="Publish" Condition="Exists('$(PublishDir)')">
|
||||
<MSBuild Projects="..\Microsoft.AspNetCore.Razor.OmniSharpPlugin\Microsoft.AspNetCore.Razor.OmniSharpPlugin.csproj" Properties="PublishDir=$(MSBuildProjectDirectory)\..\Microsoft.AspNetCore.Razor.OmniSharpPlugin\bin\$(Configuration)\net472\publish;RuntimeIdentifier=" Targets="Publish" />
|
||||
|
||||
<PropertyGroup>
|
||||
<PluginReferenceOutputPath>$(MSBuildProjectDirectory)\..\Microsoft.AspNetCore.Razor.OmniSharpPlugin\bin\$(Configuration)\net472\publish</PluginReferenceOutputPath>
|
||||
<TargetPluginOutputPath>$(PublishDir)\OmniSharpPlugin</TargetPluginOutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<RemoveDir Directories="$(TargetPluginOutputPath)" />
|
||||
<MakeDir Directories="$(TargetPluginOutputPath)" />
|
||||
|
||||
<ItemGroup>
|
||||
<PluginAssets Include="$(PluginReferenceOutputPath)\**\*.*" />
|
||||
</ItemGroup>
|
||||
|
||||
<Copy SourceFiles="@(PluginAssets)" DestinationFiles="@(PluginAssets->'$(TargetPluginOutputPath)\%(RecursiveDir)%(Filename)%(Extension)')" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
|
@ -1,42 +0,0 @@
|
|||
<Project>
|
||||
<!--
|
||||
Technique for publishing multiple RIDs from
|
||||
https://github.com/dotnet/cli/issues/9221#issuecomment-387512008
|
||||
|
||||
Example usage:
|
||||
dotnet msbuild -restore -t:PublishAllRids -p:Configuration=Release
|
||||
-->
|
||||
|
||||
<PropertyGroup>
|
||||
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||
|
||||
<!-- Enable roll-forward to latest patch. This allows one restore operation
|
||||
to apply to all of the self-contained publish operations. -->
|
||||
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="PublishAllRids">
|
||||
<PropertyGroup>
|
||||
<RidsPublishDir>bin\$(Configuration)\$(TargetFramework)\publish\</RidsPublishDir>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!-- Transform RuntimeIdentifiers property to item -->
|
||||
<RuntimeIdentifierForPublish Include="$(RuntimeIdentifiers)" />
|
||||
|
||||
<!-- Transform RuntimeIdentifierForPublish items to project items to pass to MSBuild task -->
|
||||
<ProjectToPublish Include="@(RuntimeIdentifierForPublish->'$(MSBuildProjectFullPath)')">
|
||||
<AdditionalProperties>RuntimeIdentifier=%(RuntimeIdentifierForPublish.Identity);PublishDir=$(RidsPublishDir)%(RuntimeIdentifierForPublish.Identity)\</AdditionalProperties>
|
||||
</ProjectToPublish>
|
||||
</ItemGroup>
|
||||
|
||||
<!--
|
||||
Calling "Build" here, even though it's already just been built, is a workaround for
|
||||
https://github.com/dotnet/cli/issues/9656. Once that is fixed we should be able
|
||||
to reduce this to just calling "Publish".
|
||||
-->
|
||||
<MSBuild Projects="@(ProjectToPublish)"
|
||||
Targets="Build;Publish"
|
||||
BuildInParallel="false" />
|
||||
</Target>
|
||||
</Project>
|
|
@ -1,15 +0,0 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="$(MicrosoftExtensionsLoggingAbstractionsPackageVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Razor.LanguageServer.Common\Microsoft.AspNetCore.Razor.LanguageServer.Common.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -1,49 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.CodeAnalysis.Host;
|
||||
using Microsoft.CodeAnalysis.Razor;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Test.Common
|
||||
{
|
||||
internal class TestLanguageServices : HostLanguageServices
|
||||
{
|
||||
private readonly HostWorkspaceServices _workspaceServices;
|
||||
private readonly IEnumerable<ILanguageService> _languageServices;
|
||||
|
||||
public TestLanguageServices(HostWorkspaceServices workspaceServices, IEnumerable<ILanguageService> languageServices)
|
||||
{
|
||||
if (workspaceServices == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(workspaceServices));
|
||||
}
|
||||
|
||||
if (languageServices == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(languageServices));
|
||||
}
|
||||
|
||||
_workspaceServices = workspaceServices;
|
||||
_languageServices = languageServices;
|
||||
}
|
||||
|
||||
public override HostWorkspaceServices WorkspaceServices => _workspaceServices;
|
||||
|
||||
public override string Language => RazorLanguage.Name;
|
||||
|
||||
public override TLanguageService GetService<TLanguageService>()
|
||||
{
|
||||
var service = _languageServices.OfType<TLanguageService>().FirstOrDefault();
|
||||
|
||||
if (service == null)
|
||||
{
|
||||
throw new InvalidOperationException($"Test Razor language services not configured properly, missing language service '{typeof(TLanguageService).FullName}'.");
|
||||
}
|
||||
|
||||
return service;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Test.Common
|
||||
{
|
||||
public static class TestRazorCodeDocument
|
||||
{
|
||||
public static RazorCodeDocument CreateEmpty()
|
||||
{
|
||||
var source = TestRazorSourceDocument.Create(content: string.Empty);
|
||||
return new DefaultRazorCodeDocument(source, imports: null);
|
||||
}
|
||||
|
||||
public static RazorCodeDocument Create(string content)
|
||||
{
|
||||
var source = TestRazorSourceDocument.Create(content);
|
||||
return new DefaultRazorCodeDocument(source, imports: null);
|
||||
}
|
||||
|
||||
public static RazorCodeDocument Create(RazorSourceDocument source, IEnumerable<RazorSourceDocument> imports)
|
||||
{
|
||||
return new DefaultRazorCodeDocument(source, imports);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,195 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Test.Common
|
||||
{
|
||||
public static class TestRazorSourceDocument
|
||||
{
|
||||
public static RazorSourceDocument CreateResource(string resourcePath, Type type, Encoding encoding = null, bool normalizeNewLines = false)
|
||||
{
|
||||
return CreateResource(resourcePath, type.GetTypeInfo().Assembly, encoding, normalizeNewLines);
|
||||
}
|
||||
|
||||
public static RazorSourceDocument CreateResource(string resourcePath, Assembly assembly, Encoding encoding = null, bool normalizeNewLines = false)
|
||||
{
|
||||
var file = TestFile.Create(resourcePath, assembly);
|
||||
|
||||
using (var input = file.OpenRead())
|
||||
using (var reader = new StreamReader(input))
|
||||
{
|
||||
var content = reader.ReadToEnd();
|
||||
if (normalizeNewLines)
|
||||
{
|
||||
content = NormalizeNewLines(content);
|
||||
}
|
||||
|
||||
var properties = new RazorSourceDocumentProperties(resourcePath, resourcePath);
|
||||
return new StringSourceDocument(content, encoding ?? Encoding.UTF8, properties);
|
||||
}
|
||||
}
|
||||
|
||||
public static RazorSourceDocument CreateResource(
|
||||
string path,
|
||||
Assembly assembly,
|
||||
Encoding encoding,
|
||||
RazorSourceDocumentProperties properties,
|
||||
bool normalizeNewLines = false)
|
||||
{
|
||||
var file = TestFile.Create(path, assembly);
|
||||
|
||||
using (var input = file.OpenRead())
|
||||
using (var reader = new StreamReader(input))
|
||||
{
|
||||
var content = reader.ReadToEnd();
|
||||
if (normalizeNewLines)
|
||||
{
|
||||
content = NormalizeNewLines(content);
|
||||
}
|
||||
|
||||
return new StringSourceDocument(content, encoding ?? Encoding.UTF8, properties);
|
||||
}
|
||||
}
|
||||
|
||||
public static MemoryStream CreateStreamContent(string content = "Hello, World!", Encoding encoding = null, bool normalizeNewLines = false)
|
||||
{
|
||||
var stream = new MemoryStream();
|
||||
encoding = encoding ?? Encoding.UTF8;
|
||||
using (var writer = new StreamWriter(stream, encoding, bufferSize: 1024, leaveOpen: true))
|
||||
{
|
||||
if (normalizeNewLines)
|
||||
{
|
||||
content = NormalizeNewLines(content);
|
||||
}
|
||||
|
||||
writer.Write(content);
|
||||
}
|
||||
|
||||
stream.Seek(0L, SeekOrigin.Begin);
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
public static RazorSourceDocument Create(
|
||||
string content = "Hello, world!",
|
||||
Encoding encoding = null,
|
||||
bool normalizeNewLines = false,
|
||||
string filePath = "test.cshtml",
|
||||
string relativePath = "test.cshtml")
|
||||
{
|
||||
if (normalizeNewLines)
|
||||
{
|
||||
content = NormalizeNewLines(content);
|
||||
}
|
||||
|
||||
var properties = new RazorSourceDocumentProperties(filePath, relativePath);
|
||||
return new StringSourceDocument(content, encoding ?? Encoding.UTF8, properties);
|
||||
}
|
||||
|
||||
public static RazorSourceDocument Create(
|
||||
string content,
|
||||
RazorSourceDocumentProperties properties,
|
||||
Encoding encoding = null,
|
||||
bool normalizeNewLines = false)
|
||||
{
|
||||
if (normalizeNewLines)
|
||||
{
|
||||
content = NormalizeNewLines(content);
|
||||
}
|
||||
|
||||
return new StringSourceDocument(content, encoding ?? Encoding.UTF8, properties);
|
||||
}
|
||||
|
||||
private static string NormalizeNewLines(string content)
|
||||
{
|
||||
return Regex.Replace(content, "(?<!\r)\n", "\r\n", RegexOptions.None, TimeSpan.FromSeconds(10));
|
||||
}
|
||||
|
||||
|
||||
private class TestFile
|
||||
{
|
||||
private TestFile(string resourceName, Assembly assembly)
|
||||
{
|
||||
Assembly = assembly;
|
||||
ResourceName = Assembly.GetName().Name + "." + resourceName.Replace('/', '.');
|
||||
}
|
||||
|
||||
public Assembly Assembly { get; }
|
||||
|
||||
public string ResourceName { get; }
|
||||
|
||||
public static TestFile Create(string resourceName, Type type)
|
||||
{
|
||||
return new TestFile(resourceName, type.GetTypeInfo().Assembly);
|
||||
}
|
||||
|
||||
public static TestFile Create(string resourceName, Assembly assembly)
|
||||
{
|
||||
return new TestFile(resourceName, assembly);
|
||||
}
|
||||
|
||||
public Stream OpenRead()
|
||||
{
|
||||
var stream = Assembly.GetManifestResourceStream(ResourceName);
|
||||
if (stream == null)
|
||||
{
|
||||
Assert.True(false, string.Format("Manifest resource: {0} not found", ResourceName));
|
||||
}
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
public bool Exists()
|
||||
{
|
||||
var resourceNames = Assembly.GetManifestResourceNames();
|
||||
foreach (var resourceName in resourceNames)
|
||||
{
|
||||
// Resource names are case-sensitive.
|
||||
if (string.Equals(ResourceName, resourceName, StringComparison.Ordinal))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public string ReadAllText()
|
||||
{
|
||||
using (var reader = new StreamReader(OpenRead()))
|
||||
{
|
||||
// The .Replace() calls normalize line endings, in case you get \n instead of \r\n
|
||||
// since all the unit tests rely on the assumption that the files will have \r\n endings.
|
||||
return reader.ReadToEnd().Replace("\r", "").Replace("\n", "\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the file to the specified path.
|
||||
/// </summary>
|
||||
public void Save(string filePath)
|
||||
{
|
||||
var directory = Path.GetDirectoryName(filePath);
|
||||
if (!Directory.Exists(directory))
|
||||
{
|
||||
Directory.CreateDirectory(directory);
|
||||
}
|
||||
|
||||
using (var outStream = File.Create(filePath))
|
||||
{
|
||||
using (var inStream = OpenRead())
|
||||
{
|
||||
inStream.CopyTo(outStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.Host;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Test.Common
|
||||
{
|
||||
public class TestServices : HostServices
|
||||
{
|
||||
private readonly IEnumerable<IWorkspaceService> _workspaceServices;
|
||||
private readonly IEnumerable<ILanguageService> _razorLanguageServices;
|
||||
|
||||
private TestServices(IEnumerable<IWorkspaceService> workspaceServices, IEnumerable<ILanguageService> razorLanguageServices)
|
||||
{
|
||||
if (workspaceServices == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(workspaceServices));
|
||||
}
|
||||
|
||||
if (razorLanguageServices == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(razorLanguageServices));
|
||||
}
|
||||
|
||||
_workspaceServices = workspaceServices;
|
||||
_razorLanguageServices = razorLanguageServices;
|
||||
}
|
||||
|
||||
protected override HostWorkspaceServices CreateWorkspaceServices(Workspace workspace)
|
||||
{
|
||||
if (workspace == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(workspace));
|
||||
}
|
||||
|
||||
return new TestWorkspaceServices(this, _workspaceServices, _razorLanguageServices, workspace);
|
||||
}
|
||||
|
||||
public static HostServices Create(IEnumerable<ILanguageService> razorLanguageServices)
|
||||
=> Create(Enumerable.Empty<IWorkspaceService>(), razorLanguageServices);
|
||||
|
||||
public static HostServices Create(IEnumerable<IWorkspaceService> workspaceServices, IEnumerable<ILanguageService> razorLanguageServices)
|
||||
=> new TestServices(workspaceServices, razorLanguageServices);
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.Host;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Test.Common
|
||||
{
|
||||
public static class TestWorkspace
|
||||
{
|
||||
private static readonly object WorkspaceLock = new object();
|
||||
|
||||
public static Workspace Create(Action<AdhocWorkspace> configure = null) => Create(services: null, configure: configure);
|
||||
|
||||
public static Workspace Create(HostServices services, Action<AdhocWorkspace> configure = null)
|
||||
{
|
||||
lock (WorkspaceLock)
|
||||
{
|
||||
var workspace = services == null ? new AdhocWorkspace() : new AdhocWorkspace(services);
|
||||
configure?.Invoke(workspace);
|
||||
|
||||
return workspace;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,89 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.Host;
|
||||
using Microsoft.CodeAnalysis.Razor;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Test.Common
|
||||
{
|
||||
internal class TestWorkspaceServices : HostWorkspaceServices
|
||||
{
|
||||
private static readonly Workspace DefaultWorkspace = TestWorkspace.Create();
|
||||
|
||||
private readonly HostServices _hostServices;
|
||||
private readonly HostLanguageServices _razorLanguageServices;
|
||||
private readonly IEnumerable<IWorkspaceService> _workspaceServices;
|
||||
private readonly Workspace _workspace;
|
||||
|
||||
public TestWorkspaceServices(
|
||||
HostServices hostServices,
|
||||
IEnumerable<IWorkspaceService> workspaceServices,
|
||||
IEnumerable<ILanguageService> languageServices,
|
||||
Workspace workspace)
|
||||
{
|
||||
if (hostServices == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(hostServices));
|
||||
}
|
||||
|
||||
if (workspaceServices == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(workspaceServices));
|
||||
}
|
||||
|
||||
if (languageServices == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(languageServices));
|
||||
}
|
||||
|
||||
if (workspace == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(workspace));
|
||||
}
|
||||
|
||||
_hostServices = hostServices;
|
||||
_workspaceServices = workspaceServices;
|
||||
_workspace = workspace;
|
||||
|
||||
_razorLanguageServices = new TestLanguageServices(this, languageServices);
|
||||
}
|
||||
|
||||
public override HostServices HostServices => _hostServices;
|
||||
|
||||
public override Workspace Workspace => _workspace;
|
||||
|
||||
public override TWorkspaceService GetService<TWorkspaceService>()
|
||||
{
|
||||
var service = _workspaceServices.OfType<TWorkspaceService>().FirstOrDefault();
|
||||
|
||||
if (service == null)
|
||||
{
|
||||
// Fallback to default host services to resolve roslyn specific features.
|
||||
service = DefaultWorkspace.Services.GetService<TWorkspaceService>();
|
||||
}
|
||||
|
||||
return service;
|
||||
}
|
||||
|
||||
public override HostLanguageServices GetLanguageServices(string languageName)
|
||||
{
|
||||
if (languageName == RazorLanguage.Name)
|
||||
{
|
||||
return _razorLanguageServices;
|
||||
}
|
||||
|
||||
// Fallback to default host services to resolve roslyn specific features.
|
||||
return DefaultWorkspace.Services.GetLanguageServices(languageName);
|
||||
}
|
||||
|
||||
public override IEnumerable<string> SupportedLanguages => new[] { RazorLanguage.Name };
|
||||
|
||||
public override bool IsSupported(string languageName) => languageName == RazorLanguage.Name;
|
||||
|
||||
public override IEnumerable<TLanguageService> FindLanguageServices<TLanguageService>(MetadataFilter filter) => throw new NotImplementedException();
|
||||
}
|
||||
}
|
|
@ -86,9 +86,19 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.Mac.
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Test.ComponentShim", "test\Microsoft.AspNetCore.Razor.Test.ComponentShim\Microsoft.AspNetCore.Razor.Test.ComponentShim.csproj", "{5B232E77-F0D3-4298-9A5D-D965788D7A79}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.VisualStudio.LiveShare.Razor", "src\Microsoft.VisualStudio.LiveShare.Razor\Microsoft.VisualStudio.LiveShare.Razor.csproj", "{20193C6A-8981-447F-99B3-120DD3B06279}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.LiveShare.Razor", "src\Microsoft.VisualStudio.LiveShare.Razor\Microsoft.VisualStudio.LiveShare.Razor.csproj", "{20193C6A-8981-447F-99B3-120DD3B06279}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.VisualStudio.LiveShare.Razor.Test", "test\Microsoft.VisualStudio.LiveShare.Razor.Test\Microsoft.VisualStudio.LiveShare.Razor.Test.csproj", "{9A27DD55-E8CD-4C03-A89B-A7348B787660}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.LiveShare.Razor.Test", "test\Microsoft.VisualStudio.LiveShare.Razor.Test\Microsoft.VisualStudio.LiveShare.Razor.Test.csproj", "{9A27DD55-E8CD-4C03-A89B-A7348B787660}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.LanguageServer.Common", "src\Microsoft.AspNetCore.Razor.LanguageServer.Common\Microsoft.AspNetCore.Razor.LanguageServer.Common.csproj", "{F2B59848-345E-4ECB-ADDB-277F3C937B9C}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.LanguageServer", "src\Microsoft.AspNetCore.Razor.LanguageServer\Microsoft.AspNetCore.Razor.LanguageServer.csproj", "{1D15867E-E50F-4107-92A4-BBC2EE6B088C}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.LanguageServer.Common.Test", "test\Microsoft.AspNetCore.Razor.LanguageServer.Common.Test\Microsoft.AspNetCore.Razor.LanguageServer.Common.Test.csproj", "{6C8A42B5-B41C-4334-959F-684E647A24E1}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.LanguageServer.Test", "test\Microsoft.AspNetCore.Razor.LanguageServer.Test\Microsoft.AspNetCore.Razor.LanguageServer.Test.csproj", "{FBAE9975-77BE-411B-A1A3-4790C8A367EF}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.LanguageServer.Test.Common", "test\Microsoft.AspNetCore.Razor.LanguageServer.Test.Common\Microsoft.AspNetCore.Razor.LanguageServer.Test.Common.csproj", "{9D300F9A-1F78-45C9-B4BB-476EF12E40F8}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
@ -410,6 +420,46 @@ Global
|
|||
{9A27DD55-E8CD-4C03-A89B-A7348B787660}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9A27DD55-E8CD-4C03-A89B-A7348B787660}.ReleaseNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9A27DD55-E8CD-4C03-A89B-A7348B787660}.ReleaseNoVSIX|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F2B59848-345E-4ECB-ADDB-277F3C937B9C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F2B59848-345E-4ECB-ADDB-277F3C937B9C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F2B59848-345E-4ECB-ADDB-277F3C937B9C}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F2B59848-345E-4ECB-ADDB-277F3C937B9C}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F2B59848-345E-4ECB-ADDB-277F3C937B9C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F2B59848-345E-4ECB-ADDB-277F3C937B9C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F2B59848-345E-4ECB-ADDB-277F3C937B9C}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F2B59848-345E-4ECB-ADDB-277F3C937B9C}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU
|
||||
{1D15867E-E50F-4107-92A4-BBC2EE6B088C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1D15867E-E50F-4107-92A4-BBC2EE6B088C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1D15867E-E50F-4107-92A4-BBC2EE6B088C}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1D15867E-E50F-4107-92A4-BBC2EE6B088C}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1D15867E-E50F-4107-92A4-BBC2EE6B088C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1D15867E-E50F-4107-92A4-BBC2EE6B088C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1D15867E-E50F-4107-92A4-BBC2EE6B088C}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1D15867E-E50F-4107-92A4-BBC2EE6B088C}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU
|
||||
{6C8A42B5-B41C-4334-959F-684E647A24E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6C8A42B5-B41C-4334-959F-684E647A24E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6C8A42B5-B41C-4334-959F-684E647A24E1}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6C8A42B5-B41C-4334-959F-684E647A24E1}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6C8A42B5-B41C-4334-959F-684E647A24E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6C8A42B5-B41C-4334-959F-684E647A24E1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6C8A42B5-B41C-4334-959F-684E647A24E1}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6C8A42B5-B41C-4334-959F-684E647A24E1}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU
|
||||
{FBAE9975-77BE-411B-A1A3-4790C8A367EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FBAE9975-77BE-411B-A1A3-4790C8A367EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FBAE9975-77BE-411B-A1A3-4790C8A367EF}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FBAE9975-77BE-411B-A1A3-4790C8A367EF}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FBAE9975-77BE-411B-A1A3-4790C8A367EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FBAE9975-77BE-411B-A1A3-4790C8A367EF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FBAE9975-77BE-411B-A1A3-4790C8A367EF}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FBAE9975-77BE-411B-A1A3-4790C8A367EF}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU
|
||||
{9D300F9A-1F78-45C9-B4BB-476EF12E40F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9D300F9A-1F78-45C9-B4BB-476EF12E40F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9D300F9A-1F78-45C9-B4BB-476EF12E40F8}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9D300F9A-1F78-45C9-B4BB-476EF12E40F8}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9D300F9A-1F78-45C9-B4BB-476EF12E40F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9D300F9A-1F78-45C9-B4BB-476EF12E40F8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9D300F9A-1F78-45C9-B4BB-476EF12E40F8}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9D300F9A-1F78-45C9-B4BB-476EF12E40F8}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -454,6 +504,11 @@ Global
|
|||
{5B232E77-F0D3-4298-9A5D-D965788D7A79} = {92463391-81BE-462B-AC3C-78C6C760741F}
|
||||
{20193C6A-8981-447F-99B3-120DD3B06279} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED}
|
||||
{9A27DD55-E8CD-4C03-A89B-A7348B787660} = {92463391-81BE-462B-AC3C-78C6C760741F}
|
||||
{F2B59848-345E-4ECB-ADDB-277F3C937B9C} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED}
|
||||
{1D15867E-E50F-4107-92A4-BBC2EE6B088C} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED}
|
||||
{6C8A42B5-B41C-4334-959F-684E647A24E1} = {92463391-81BE-462B-AC3C-78C6C760741F}
|
||||
{FBAE9975-77BE-411B-A1A3-4790C8A367EF} = {92463391-81BE-462B-AC3C-78C6C760741F}
|
||||
{9D300F9A-1F78-45C9-B4BB-476EF12E40F8} = {92463391-81BE-462B-AC3C-78C6C760741F}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {0035341D-175A-4D05-95E6-F1C2785A1E26}
|
||||
|
|
|
@ -1099,8 +1099,6 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
|
||||
if (node.Source != null)
|
||||
{
|
||||
Debug.Assert(node.Source.Value.FilePath != null);
|
||||
|
||||
node.Source = new SourceSpan(
|
||||
node.Source.Value.FilePath,
|
||||
node.Source.Value.AbsoluteIndex,
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<Description>Razor is a markup syntax for adding server-side logic to web pages. This package contains common assets that are used in the Razor language server and other assemblies.</Description>
|
||||
<EnableApiCheck>false</EnableApiCheck>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X\Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X\Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.Razor.Extensions\Microsoft.AspNetCore.Mvc.Razor.Extensions.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.CodeAnalysis.Razor.Workspaces\Microsoft.CodeAnalysis.Razor.Workspaces.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,59 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
<OutputType>Exe</OutputType>
|
||||
<Description>Razor is a markup syntax for adding server-side logic to web pages. This package contains a Razor language server.</Description>
|
||||
<EnableApiCheck>false</EnableApiCheck>
|
||||
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;osx-x64;</RuntimeIdentifiers>
|
||||
<AssemblyName>rzls</AssemblyName>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="OmniSharp.Extensions.LanguageServer" Version="$(OmniSharpExtensionsLanguageServerPackageVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.LanguageServer.Common\Microsoft.AspNetCore.Razor.LanguageServer.Common.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<!--<Target Name="_IncludeOmniSharpPlugin" Condition="Exists('$(PublishDir)')">
|
||||
<PropertyGroup>
|
||||
<TargetPluginOutputPath>$(PublishDir)\OmniSharpPlugin</TargetPluginOutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<MSBuild Projects="..\Microsoft.AspNetCore.Razor.OmniSharpPlugin\Microsoft.AspNetCore.Razor.OmniSharpPlugin.csproj" Properties="PublishDir=$(TargetPluginOutputPath);RuntimeIdentifier=" Targets="Publish" />
|
||||
</Target>-->
|
||||
|
||||
<!--
|
||||
Technique for publishing multiple RIDs from
|
||||
https://github.com/dotnet/cli/issues/9221#issuecomment-387512008
|
||||
Example usage:
|
||||
dotnet msbuild -restore -t:PublishAllRids -p:Configuration=Release
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||
|
||||
<!-- Enable roll-forward to latest patch. This allows one restore operation
|
||||
to apply to all of the self-contained publish operations. -->
|
||||
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
|
||||
<RidsPublishDir>$(ArtifactsDir)LanguageServer\$(Configuration)\</RidsPublishDir>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="PublishAllRids">
|
||||
|
||||
<ItemGroup>
|
||||
<!-- Transform RuntimeIdentifiers property to item -->
|
||||
<RuntimeIdentifierForPublish Include="$(RuntimeIdentifiers)" />
|
||||
|
||||
<!-- Transform RuntimeIdentifierForPublish items to project items to pass to MSBuild task -->
|
||||
<ProjectToPublish Include="@(RuntimeIdentifierForPublish->'$(MSBuildProjectFullPath)')">
|
||||
<AdditionalProperties>RuntimeIdentifier=%(RuntimeIdentifierForPublish.Identity);PublishDir=$(RidsPublishDir)%(RuntimeIdentifierForPublish.Identity)\</AdditionalProperties>
|
||||
</ProjectToPublish>
|
||||
</ItemGroup>
|
||||
|
||||
<MSBuild Projects="@(ProjectToPublish)"
|
||||
Targets="Publish;"
|
||||
BuildInParallel="false" />
|
||||
</Target>
|
||||
</Project>
|
|
@ -5,6 +5,7 @@ using System;
|
|||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
|
||||
using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.LanguageServer
|
||||
{
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче