This commit is contained in:
David Wengier 2023-09-12 20:54:06 +10:00
Родитель c01e4d8b90
Коммит 87614ae8c6
85 изменённых файлов: 2 добавлений и 4971 удалений

Просмотреть файл

@ -9,7 +9,6 @@
</PropertyGroup>
<Import Project="Sdk.props" Sdk="Microsoft.DotNet.Arcade.Sdk" />
<Import Project="eng\MPack.props" />
<Import Project="eng\targets\Npm.Common.props" Condition="'$(MSBuildProjectExtension)' == '.npmproj'" />
<Import

Просмотреть файл

@ -6,7 +6,6 @@
<PackageVersion Condition=" '$(PackageVersion)' == '' ">$(Version)</PackageVersion>
</PropertyGroup>
<Import Project="eng\MPack.targets" />
<Import Project="eng\targets\Packaging.targets" />
<Import Project="eng\targets\Npm.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.npmproj' and '$(_SuppressAllTargets)' != 'true'" />

Просмотреть файл

@ -6520,27 +6520,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
---------------------------------------------------------
---------------------------------------------------------
Mono.Addins 1.3.8 - MIT
(c) Microsoft Corporation.
Copyright (c) 2007 Novell, Inc (http://www.novell.com)
6Copyright (c) 2007 Novell, Inc (http://www.novell.com)
MIT License
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
---------------------------------------------------------
---------------------------------------------------------

Просмотреть файл

@ -19,7 +19,6 @@
<add key="vssdk-archived" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/vssdk-archived/nuget/v3/index.json" />
<add key="vs-impl" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/vs-impl/nuget/v3/index.json" />
<add key="vs-impl-archived" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/vs-impl-archived/nuget/v3/index.json" />
<add key="myget-legacy" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/myget-legacy/nuget/v3/index.json" />
<!-- Used for the Rich Navigation indexing task -->
<add key="richnav" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/vs-buildservices/nuget/v3/index.json" />
<!-- Used for BenchmarkDotNet prerelease packages -->
@ -96,8 +95,6 @@
<package pattern="microbuild.core" />
<package pattern="microsoft.*" />
<package pattern="microsoft.ilverification" />
<package pattern="mono.addins" />
<package pattern="mono.posix.netstandard" />
<package pattern="moq" />
<package pattern="mstest.testadapter" />
<package pattern="mstest.testframework" />
@ -158,9 +155,6 @@
<package pattern="microsoft.*" />
<package pattern="microsoft.commonlanguageserverProtocol.*" />
</packageSource>
<packageSource key="myget-legacy">
<package pattern="monodevelop.sdk" />
</packageSource>
<packageSource key="benchmark-dotnet-prerelease">
<package pattern="benchmarkdotnet" />
<package pattern="benchmarkdotnet.annotations" />

Просмотреть файл

@ -1,6 +1,6 @@
# ASP.NET Core Razor
This repository is the open-source implementation for the [Razor](https://docs.microsoft.com/en-us/aspnet/core/razor-pages) experience in ASP.NET Core. It contains the compiler and IDE tools for working on Razor ASP.NET Core apps using [Visual Studio](https://visualstudio.com), [Visual Studio for Mac](https://visualstudio.microsoft.com/vs/mac/), and [Visual Studio Code](https://code.visualstudio.com/).
This repository is the open-source implementation for the [Razor](https://docs.microsoft.com/en-us/aspnet/core/razor-pages) experience in ASP.NET Core. It contains the compiler and IDE tools for working on Razor ASP.NET Core apps using [Visual Studio](https://visualstudio.com) and [Visual Studio Code](https://code.visualstudio.com/).
## Contributing
@ -25,7 +25,7 @@ Also check out the [.NET Homepage](https://www.microsoft.com/net) for released v
Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) secure@microsoft.com. You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the MSRC PGP key, can be found in the [Security TechCenter](https://technet.microsoft.com/en-us/security/ff852094.aspx).
## Status
## Status
[![Build Status](https://dev.azure.com/dnceng-public/public/_apis/build/status/dotnet/razor-tooling/razor-tooling-ci?branchName=main)](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=103&branchName=main)
## Related projects

Просмотреть файл

@ -29,8 +29,6 @@
"src\\Razor\\src\\Microsoft.VisualStudio.LanguageServer.ContainedLanguage\\Microsoft.VisualStudio.LanguageServer.ContainedLanguage.csproj",
"src\\Razor\\src\\Microsoft.VisualStudio.LanguageServices.Razor\\Microsoft.VisualStudio.LanguageServices.Razor.csproj",
"src\\Razor\\src\\Microsoft.VisualStudio.LiveShare.Razor\\Microsoft.VisualStudio.LiveShare.Razor.csproj",
"src\\Razor\\src\\Microsoft.VisualStudio.Mac.LanguageServices.Razor\\Microsoft.VisualStudio.Mac.LanguageServices.Razor.csproj",
"src\\Razor\\src\\Microsoft.VisualStudio.Mac.RazorAddin\\Microsoft.VisualStudio.Mac.RazorAddin.csproj",
"src\\Razor\\test\\Microsoft.AspNetCore.Razor.Test.Common\\Microsoft.AspNetCore.Razor.Test.Common.csproj",
"src\\Razor\\test\\Microsoft.AspNetCore.Razor.Test.ComponentShim\\Microsoft.AspNetCore.Razor.Test.ComponentShim.csproj",
"src\\Razor\\test\\Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib\\Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib.csproj",
@ -46,7 +44,6 @@
"src\\Razor\\test\\Microsoft.VisualStudio.LanguageServer.ContainedLanguage.Test\\Microsoft.VisualStudio.LanguageServer.ContainedLanguage.Test.csproj",
"src\\Razor\\test\\Microsoft.VisualStudio.LanguageServices.Razor.Test\\Microsoft.VisualStudio.LanguageServices.Razor.Test.csproj",
"src\\Razor\\test\\Microsoft.VisualStudio.LiveShare.Razor.Test\\Microsoft.VisualStudio.LiveShare.Razor.Test.csproj",
"src\\Razor\\test\\Microsoft.VisualStudio.Mac.LanguageServices.Razor.Test\\Microsoft.VisualStudio.Mac.LanguageServices.Razor.Test.csproj",
"src\\Shared\\Microsoft.AspNetCore.Razor.Utilities.Shared\\Microsoft.AspNetCore.Razor.Utilities.Shared.csproj"
]
}

Просмотреть файл

@ -32,10 +32,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.Edit
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.Editor.Razor.Test.Common", "src\Razor\test\Microsoft.VisualStudio.Editor.Razor.Test.Common\Microsoft.VisualStudio.Editor.Razor.Test.Common.csproj", "{FC684D4F-D23C-407C-9C68-E10EF3B38560}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.Mac.LanguageServices.Razor", "src\Razor\src\Microsoft.VisualStudio.Mac.LanguageServices.Razor\Microsoft.VisualStudio.Mac.LanguageServices.Razor.csproj", "{95B18DEE-8B45-4CF0-B9F8-CCBAF3B5251A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.Mac.LanguageServices.Razor.Test", "src\Razor\test\Microsoft.VisualStudio.Mac.LanguageServices.Razor.Test\Microsoft.VisualStudio.Mac.LanguageServices.Razor.Test.csproj", "{B8A3E4CA-D54A-441F-A3BF-E00F060CA042}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Microbenchmarks", "src\Razor\benchmarks\Microsoft.AspNetCore.Razor.Microbenchmarks\Microsoft.AspNetCore.Razor.Microbenchmarks.csproj", "{6205467F-E381-4C42-AEEC-763BD62B3D5E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "benchmarks", "benchmarks", "{C2C98051-0F39-47F2-80B6-E72B29159F2C}"
@ -48,8 +44,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.RazorExtension", "src\Razor\src\Microsoft.VisualStudio.RazorExtension\Microsoft.VisualStudio.RazorExtension.csproj", "{BCF712D4-329A-4C7A-8292-9EFC864B2ABA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.Mac.RazorAddin", "src\Razor\src\Microsoft.VisualStudio.Mac.RazorAddin\Microsoft.VisualStudio.Mac.RazorAddin.csproj", "{A34CCC12-687B-4D12-AA0E-F5BE800DE19C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Test.ComponentShim", "src\Razor\test\Microsoft.AspNetCore.Razor.Test.ComponentShim\Microsoft.AspNetCore.Razor.Test.ComponentShim.csproj", "{5B232E77-F0D3-4298-9A5D-D965788D7A79}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.LiveShare.Razor", "src\Razor\src\Microsoft.VisualStudio.LiveShare.Razor\Microsoft.VisualStudio.LiveShare.Razor.csproj", "{20193C6A-8981-447F-99B3-120DD3B06279}"
@ -273,22 +267,6 @@ Global
{FC684D4F-D23C-407C-9C68-E10EF3B38560}.Release|Any CPU.Build.0 = Release|Any CPU
{FC684D4F-D23C-407C-9C68-E10EF3B38560}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU
{FC684D4F-D23C-407C-9C68-E10EF3B38560}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU
{95B18DEE-8B45-4CF0-B9F8-CCBAF3B5251A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{95B18DEE-8B45-4CF0-B9F8-CCBAF3B5251A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{95B18DEE-8B45-4CF0-B9F8-CCBAF3B5251A}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU
{95B18DEE-8B45-4CF0-B9F8-CCBAF3B5251A}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU
{95B18DEE-8B45-4CF0-B9F8-CCBAF3B5251A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{95B18DEE-8B45-4CF0-B9F8-CCBAF3B5251A}.Release|Any CPU.Build.0 = Release|Any CPU
{95B18DEE-8B45-4CF0-B9F8-CCBAF3B5251A}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU
{95B18DEE-8B45-4CF0-B9F8-CCBAF3B5251A}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU
{B8A3E4CA-D54A-441F-A3BF-E00F060CA042}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B8A3E4CA-D54A-441F-A3BF-E00F060CA042}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B8A3E4CA-D54A-441F-A3BF-E00F060CA042}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU
{B8A3E4CA-D54A-441F-A3BF-E00F060CA042}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU
{B8A3E4CA-D54A-441F-A3BF-E00F060CA042}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B8A3E4CA-D54A-441F-A3BF-E00F060CA042}.Release|Any CPU.Build.0 = Release|Any CPU
{B8A3E4CA-D54A-441F-A3BF-E00F060CA042}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU
{B8A3E4CA-D54A-441F-A3BF-E00F060CA042}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU
{6205467F-E381-4C42-AEEC-763BD62B3D5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6205467F-E381-4C42-AEEC-763BD62B3D5E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6205467F-E381-4C42-AEEC-763BD62B3D5E}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU
@ -329,14 +307,6 @@ Global
{BCF712D4-329A-4C7A-8292-9EFC864B2ABA}.Release|Any CPU.Build.0 = Release|Any CPU
{BCF712D4-329A-4C7A-8292-9EFC864B2ABA}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU
{BCF712D4-329A-4C7A-8292-9EFC864B2ABA}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU
{A34CCC12-687B-4D12-AA0E-F5BE800DE19C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A34CCC12-687B-4D12-AA0E-F5BE800DE19C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A34CCC12-687B-4D12-AA0E-F5BE800DE19C}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU
{A34CCC12-687B-4D12-AA0E-F5BE800DE19C}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU
{A34CCC12-687B-4D12-AA0E-F5BE800DE19C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A34CCC12-687B-4D12-AA0E-F5BE800DE19C}.Release|Any CPU.Build.0 = Release|Any CPU
{A34CCC12-687B-4D12-AA0E-F5BE800DE19C}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU
{A34CCC12-687B-4D12-AA0E-F5BE800DE19C}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU
{5B232E77-F0D3-4298-9A5D-D965788D7A79}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5B232E77-F0D3-4298-9A5D-D965788D7A79}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5B232E77-F0D3-4298-9A5D-D965788D7A79}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU
@ -753,14 +723,11 @@ Global
{0BCDE75A-A438-46C7-95E9-391F029D07C5} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED}
{AA888DB9-340E-4E06-A2A4-25BFEE1AC2B7} = {92463391-81BE-462B-AC3C-78C6C760741F}
{FC684D4F-D23C-407C-9C68-E10EF3B38560} = {92463391-81BE-462B-AC3C-78C6C760741F}
{95B18DEE-8B45-4CF0-B9F8-CCBAF3B5251A} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED}
{B8A3E4CA-D54A-441F-A3BF-E00F060CA042} = {92463391-81BE-462B-AC3C-78C6C760741F}
{6205467F-E381-4C42-AEEC-763BD62B3D5E} = {C2C98051-0F39-47F2-80B6-E72B29159F2C}
{933101DA-C4CC-401A-AA01-2784E1025B7F} = {92463391-81BE-462B-AC3C-78C6C760741F}
{72E89155-86C7-454E-BDD9-39F497F2F61B} = {92463391-81BE-462B-AC3C-78C6C760741F}
{D87E5501-B832-46B6-ACD3-EC989E3D14ED} = {92463391-81BE-462B-AC3C-78C6C760741F}
{BCF712D4-329A-4C7A-8292-9EFC864B2ABA} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED}
{A34CCC12-687B-4D12-AA0E-F5BE800DE19C} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED}
{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}

Просмотреть файл

@ -273,11 +273,6 @@ stages:
displayName: Publish VSSetup
condition: and(succeeded(), eq(variables['system.pullrequest.isfork'], false), eq(variables['_BuildConfig'], 'Release'))
- publish: artifacts\MPack\$(_BuildConfig)
artifact: MPack_$(Agent.Os)_$(_BuildConfig)
displayName: Publish VS for Mac Artifacts
condition: and(succeeded(), eq(variables['system.pullrequest.isfork'], false), eq(variables['_BuildConfig'], 'Release'))
- publish: artifacts\packages\$(_BuildConfig)
artifact: Packages_$(Agent.Os)_$(_BuildConfig)
displayName: Publish package artifacts

Просмотреть файл

@ -106,13 +106,6 @@ target the broadest set of frameworks.
- Microsoft.VisualStudio.RazorExtension.Dependencies
- RazorDeployment
### Visual Studio (Mac)
- Target Framework: `net472`
- Projects:
- Microsoft.VisualStudio.Mac.LanguageServices.Razor
- Microsoft.VisualStudio.Mac.RazorAddin
### Miscellaneous / Test hosting
- Target Framework: net7.0
@ -158,7 +151,3 @@ target the broadest set of frameworks.
- Microsoft.VisualStudio.LanguageServices.Razor.Test (`net472`)
- Microsoft.VisualStudio.LiveShare.Razor.Test (`net472`)
- Microsoft.VisualStudio.Razor.IntegrationTests (`net472`)
### Visual Studio (Mac) Tests
- Microsoft.VisualStudio.Mac.LanguageServices.Razor.Test (`net472`)

Просмотреть файл

@ -1,5 +0,0 @@
<Project>
<PropertyGroup>
<ArtifactsMPackDir>$(ArtifactsDir)MPack\$(Configuration)\</ArtifactsMPackDir>
</PropertyGroup>
</Project>

Просмотреть файл

@ -1,80 +0,0 @@
<Project>
<Target
Name="GenerateMPack"
AfterTargets="Build"
DependsOnTargets="_MPackWriteAddinInfo"
Condition="'$(IsMPackProject)'=='true' and '$(TargetFramework)'!='' and ('$(DotNetBuildFromSource)' != 'true' or '$(ExcludeFromSourceBuild)' != 'true')">
<!--
In our case the mpack archive requires the following:
1. An addin.info
2. An addin binary (Microsoft.VisualStudio.Mac.RazorAddin.dll)
a. _Manifest.addin.xml embedded
3. All language service binaries
-->
<PropertyGroup>
<MPackVersion Condition="'$(MPackVersion)' == '' And '$(TF_BUILD)' == 'true'">-$(BUILD_BUILDNUMBER)-$(BUILD_SOURCEVERSION.Substring(0, 8))-$(BUILD_SOURCEBRANCHNAME)</MPackVersion>
<MPackName>Razor$(MPackVersion)</MPackName>
<MPackFileName>$(MPackName).mpack</MPackFileName>
<MPackOutputPath>$(ArtifactsMPackDir)$(MPackFileName)</MPackOutputPath>
</PropertyGroup>
<ItemGroup>
<MPackFile Include="$(ArtifactsBinDir)$(TargetName)\$(Configuration)\$(TargetFramework)\$(TargetName).dll" />
<MPackFile Include="$(ArtifactsBinDir)$(TargetName)\$(Configuration)\$(TargetFramework)\$(TargetName).pdb" Condition="Exists('$(ArtifactsBinDir)$(TargetName)\$(Configuration)\$(TargetFramework)\$(TargetName).pdb')" />
</ItemGroup>
<RemoveDir Directories="$(IntermediateOutputPath)MPack\" />
<MakeDir Directories="$(IntermediateOutputPath);$(IntermediateOutputPath)MPack\" />
<Copy SourceFiles="@(MPackFile)" DestinationFolder="$(IntermediateOutputPath)MPack" Condition="%(MPackFile.Folder) == ''" />
<Copy SourceFiles="@(MPackFile)" DestinationFolder="$(IntermediateOutputPath)MPack\%(MPackFile.Folder)" Condition="%(MPackFile.Folder) != ''" />
<MakeDir Directories="$(ArtifactsMPackDir)" />
<ZipDirectory
SourceDirectory="$(IntermediateOutputPath)MPack\"
DestinationFile="$(MPackOutputPath)"
Overwrite="true" />
<ItemGroup>
<FileWrites Include="$(MPackOutputPath)" />
</ItemGroup>
</Target>
<Target Name="_MPackWriteAddinInfo">
<PropertyGroup>
<MPackManifest>$(AddinDirectory)Properties\_Manifest.addin.xml</MPackManifest>
<AddinInfoFilePath>$(IntermediateOutputPath)addin.info</AddinInfoFilePath>
</PropertyGroup>
<!-- We need to resolve the language service assemblies to generate an addin.info for the mpack -->
<XmlPeek XmlInputPath="$(MPackManifest)" Query="/ExtensionModel/Runtime/Import/@assembly">
<Output TaskParameter="Result" ItemName="MPackAssemblyNames" />
</XmlPeek>
<!-- We need to resolve the addin dependencies to generate an addin.info for the mpack -->
<XmlPeek XmlInputPath="$(MPackManifest)" Query="/ExtensionModel/Dependencies/Addin">
<Output TaskParameter="Result" ItemName="AddinDependencies" />
</XmlPeek>
<ItemGroup>
<AddinInfoLine Include="&lt;Addin id=&quot;$(AddinId)&quot; namespace=&quot;$(AddinNamespace)&quot; version=&quot;$(AddinMajorVersion)&quot; name=&quot;$(AddinDetailedName)&quot; author=&quot;$(Authors)&quot; description=&quot;$(Description)&quot; category=&quot;$(AddinCategory)&quot;&gt;" />
<AddinInfoLine Include=" &lt;Runtime&gt;" />
<AddinInfoLine Include=" &lt;Import assembly=&quot;%(MPackAssemblyNames.Identity)&quot; /&gt;" />
<AddinInfoLine Include=" &lt;Import assembly=&quot;$(AddinName).dll&quot; /&gt;" />
<AddinInfoLine Include=" &lt;/Runtime&gt;" />
<AddinInfoLine Include=" &lt;Dependencies&gt;" />
<AddinInfoLine Include=" %(AddinDependencies.Identity)" />
<AddinInfoLine Include=" &lt;/Dependencies&gt;" />
<AddinInfoLine Include="&lt;/Addin&gt;" />
</ItemGroup>
<WriteLinesToFile File="$(AddinInfoFilePath)" Lines="@(AddinInfoLine)" Overwrite="true" />
<ItemGroup>
<FileWrites Include="$(AddinInfoFilePath)" />
<MPackFile Include="$(AddinInfoFilePath)" />
</ItemGroup>
</Target>
</Project>

Просмотреть файл

@ -1,13 +1,5 @@
<Project>
<!--
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:
https://github.com/dotnet/arcade/issues/2371
-->
<Import Project="MPack.props" Condition="Exists('MPack.props')" />
<!--
These are third party libraries that we use in this repo. We need to sign them even if they
are already signed. However, they must be signed with a 3rd party certificate.
@ -24,12 +16,4 @@
<FileSignInfo Include="MessagePack.dll" CertificateName="3PartySHA2" />
</ItemGroup>
<ItemGroup>
<ItemsToSign Include="$(ArtifactsMPackDir)**\*.mpack" />
<!--
The .mpack itself is not signed, only the contents.
-->
<FileExtensionSignInfo Include=".mpack" CertificateName="None" />
</ItemGroup>
</Project>

Просмотреть файл

@ -144,8 +144,6 @@
<MicrosoftWebToolsLanguagesSharedPackageVersion>$(Tooling_HtmlEditorPackageVersion)</MicrosoftWebToolsLanguagesSharedPackageVersion>
<MicrosoftWebToolsLanguagesSharedEditorPackageVersion>$(Tooling_HtmlEditorPackageVersion)</MicrosoftWebToolsLanguagesSharedEditorPackageVersion>
<MicrosoftWebToolsSharedPackageVersion>$(Tooling_HtmlEditorPackageVersion)</MicrosoftWebToolsSharedPackageVersion>
<MonoAddinsPackageVersion>1.3.8</MonoAddinsPackageVersion>
<MonoDevelopSdkPackageVersion>1.0.15</MonoDevelopSdkPackageVersion>
<MoqPackageVersion>4.16.0</MoqPackageVersion>
<MessagePackPackageVersion>2.5.108</MessagePackPackageVersion>
<NewtonsoftJsonPackageVersion>13.0.3</NewtonsoftJsonPackageVersion>

Просмотреть файл

@ -22,6 +22,5 @@ using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Remote.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Editor.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LanguageServices.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Mac.LanguageServices.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]
[assembly: InternalsVisibleTo("Microsoft.NET.Sdk.Razor.SourceGenerators, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]

Просмотреть файл

@ -22,6 +22,5 @@ using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LanguageServices.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LiveShare.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LiveShare.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Mac.LanguageServices.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Editor.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("rzls, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]

Просмотреть файл

@ -13,7 +13,6 @@ using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LiveShare.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LiveShare.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.Microbenchmarks, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Mac.RazorAddin, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Razor.Workspaces.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Remote.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
@ -23,8 +22,6 @@ using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Editor.Razor.Test.Common, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LanguageServerClient.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LanguageServerClient.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Mac.LanguageServices.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Mac.LanguageServices.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LanguageServices.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LanguageServices.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Razor.IntegrationTests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]

Просмотреть файл

@ -1,42 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using System.Composition;
using System.IO;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Workspaces;
namespace Microsoft.VisualStudio.Editor.Razor;
/// <summary>
/// This class is VisualStudio for Mac specific to enable creating an empty document info without having IVT access to Roslyn's types.
/// </summary>
[Shared]
[Export(typeof(VisualStudioMacDocumentInfoFactory))]
internal class DefaultVisualStudioMacDocumentInfoFactory : VisualStudioMacDocumentInfoFactory
{
private readonly FilePathService _filePathService;
[ImportingConstructor]
public DefaultVisualStudioMacDocumentInfoFactory(FilePathService filePathService)
{
_filePathService = filePathService;
}
public override DocumentInfo CreateEmpty(string razorFilePath, ProjectId projectId, ProjectKey projectKey)
{
var filename = _filePathService.GetRazorCSharpFilePath(projectKey, razorFilePath);
var textLoader = new EmptyTextLoader(filename);
var docId = DocumentId.CreateNewId(projectId, debugName: filename);
return DocumentInfo.Create(
id: docId,
name: Path.GetFileName(filename),
folders: Array.Empty<string>(),
sourceCodeKind: SourceCodeKind.Regular,
filePath: filename,
loader: textLoader,
isGenerated: true);
}
}

Просмотреть файл

@ -12,8 +12,6 @@ using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LiveShare.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LiveShare.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Editor.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Mac.LanguageServices.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Mac.LanguageServices.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LanguageServices.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LanguageServices.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Razor.IntegrationTests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]

Просмотреть файл

@ -1,15 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
namespace Microsoft.VisualStudio.Editor.Razor;
/// <summary>
/// This class is VisualStudio for Mac specific to enable creating an empty document info without having IVT access to Roslyn's types.
/// </summary>
internal abstract class VisualStudioMacDocumentInfoFactory
{
public abstract DocumentInfo CreateEmpty(string razorFilePath, ProjectId projectId, ProjectKey projectKey);
}

Просмотреть файл

@ -1,86 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using System.ComponentModel.Composition;
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.Editor.Razor;
using Microsoft.VisualStudio.Text;
using MonoDevelop.Ide;
using MonoDevelop.Projects;
using Workspace = Microsoft.CodeAnalysis.Workspace;
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor;
[System.Composition.Shared]
[Export(typeof(VisualStudioWorkspaceAccessor))]
[Export(typeof(VisualStudioMacWorkspaceAccessor))]
internal class DefaultVisualStudioMacWorkspaceAccessor : VisualStudioMacWorkspaceAccessor
{
private readonly TextBufferProjectService _projectService;
[ImportingConstructor]
public DefaultVisualStudioMacWorkspaceAccessor(TextBufferProjectService projectService)
{
if (projectService is null)
{
throw new ArgumentNullException(nameof(projectService));
}
_projectService = projectService;
}
public override bool TryGetWorkspace(ITextBuffer textBuffer, [NotNullWhen(returnValue: true)] out Workspace? workspace)
{
if (textBuffer is null)
{
throw new ArgumentNullException(nameof(textBuffer));
}
// We do a best effort approach in this method to get the workspace that belongs to the TextBuffer.
// Below we try and find the project and then the solution that contains the given text buffer. If
// we're able to find both the project and solution then we use the solution to look up the corresponding
// Workspace using MonoDevelops TypeSystemService.
var hostProject = (DotNetProject?)_projectService.GetHostProject(textBuffer);
if (hostProject is null)
{
// Does not have a host project.
workspace = null;
return false;
}
var hostSolution = hostProject.ParentSolution;
if (hostSolution is null)
{
// Project does not have a solution
workspace = null;
return false;
}
return TryGetWorkspace(hostSolution, out workspace);
}
public override bool TryGetWorkspace(Solution solution, [NotNullWhen(returnValue: true)] out Workspace? workspace)
{
if (solution is null)
{
throw new ArgumentNullException(nameof(solution));
}
workspace = IdeServices.TypeSystemService.GetWorkspace(solution);
// Workspace cannot be null at this point. If TypeSystemService.GetWorkspace isn't able to find a corresponding
// workspace it returns an empty workspace. Therefore, in order to see if we have a valid workspace we need to
// cross-check it against the list of active non-empty workspaces.
if (!IdeServices.TypeSystemService.AllWorkspaces.Contains(workspace))
{
// We were returned the empty workspace which is equivalent to us not finding a valid workspace for our text buffer.
workspace = null;
return false;
}
return true;
}
}

Просмотреть файл

@ -1,109 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Editor.Razor;
using Microsoft.VisualStudio.Text;
using MonoDevelop.Ide;
using MonoDevelop.Projects;
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.Editor;
/// <summary>
/// Infrastructure methods to find project information from an <see cref="ITextBuffer"/>.
/// </summary>
[System.Composition.Shared]
[Export(typeof(TextBufferProjectService))]
internal class DefaultTextBufferProjectService : TextBufferProjectService
{
private const string DotNetCoreRazorCapability = "DotNetCoreRazor | AspNetCore";
private readonly ITextDocumentFactoryService _documentFactory;
private readonly AggregateProjectCapabilityResolver _projectCapabilityResolver;
[ImportingConstructor]
public DefaultTextBufferProjectService(
ITextDocumentFactoryService documentFactory,
AggregateProjectCapabilityResolver projectCapabilityResolver)
{
if (documentFactory is null)
{
throw new ArgumentNullException(nameof(documentFactory));
}
if (projectCapabilityResolver is null)
{
throw new ArgumentNullException(nameof(projectCapabilityResolver));
}
_documentFactory = documentFactory;
_projectCapabilityResolver = projectCapabilityResolver;
}
public override object? GetHostProject(ITextBuffer textBuffer)
{
if (textBuffer is null)
{
throw new ArgumentNullException(nameof(textBuffer));
}
// If there's no document we can't find the FileName, or look for an associated project.
if (!_documentFactory.TryGetTextDocument(textBuffer, out var textDocument))
{
return null;
}
var hostProject = GetHostProject(textDocument.FilePath);
return hostProject;
}
public override object? GetHostProject(string documentFilePath)
{
var projectsContainingFilePath = IdeApp.Workspace.GetProjectsContainingFile(documentFilePath);
foreach (var project in projectsContainingFilePath)
{
if (project is not DotNetProject)
{
continue;
}
var projectFile = project.GetProjectFile(documentFilePath);
if (!projectFile.IsHidden)
{
return project;
}
}
return null;
}
public override string GetProjectPath(object project)
{
if (project is null)
{
throw new ArgumentNullException(nameof(project));
}
var dotnetProject = (DotNetProject)project;
return dotnetProject.FileName.FullPath;
}
// VisualStudio for Mac only supports ASP.NET Core Razor.
public override bool IsSupportedProject(object project)
{
var capabilitySupported = _projectCapabilityResolver.HasCapability(project, DotNetCoreRazorCapability);
return capabilitySupported;
}
public override string GetProjectName(object project)
{
if (project is null)
{
throw new ArgumentNullException(nameof(project));
}
var dotnetProject = (DotNetProject)project;
return dotnetProject.Name;
}
}

Просмотреть файл

@ -1,34 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using Microsoft.VisualStudio.Editor.Razor;
using Microsoft.VisualStudio.Text.Editor;
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.Editor;
internal class DefaultVisualStudioCompletionBroker : VisualStudioCompletionBroker
{
private const string IsCompletionActiveKey = "RoslynCompletionPresenterSession.IsCompletionActive";
public override bool IsCompletionActive(ITextView textView)
{
if (textView is null)
{
throw new ArgumentNullException(nameof(textView));
}
if (!textView.HasAggregateFocus)
{
// Text view does not have focus, if the completion window is visible it's for a different text view.
return false;
}
if (textView.Properties.TryGetProperty<bool>(IsCompletionActiveKey, out var visible))
{
return visible;
}
return false;
}
}

Просмотреть файл

@ -1,26 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using System.Composition;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.VisualStudio.Editor.Razor;
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.Editor;
[Shared]
[ExportLanguageServiceFactory(typeof(VisualStudioCompletionBroker), RazorLanguage.Name, ServiceLayer.Default)]
internal class DefaultVisualStudioCompletionBrokerFactory : ILanguageServiceFactory
{
public ILanguageService CreateLanguageService(HostLanguageServices languageServices)
{
if (languageServices is null)
{
throw new ArgumentNullException(nameof(languageServices));
}
return new DefaultVisualStudioCompletionBroker();
}
}

Просмотреть файл

@ -1,21 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Composition;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.VisualStudio.Editor.Razor.Logging;
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.Logging;
[Shared]
[Export(typeof(RazorLogHubTraceProvider))]
internal class VisualStudioMacLogHubTraceProvider : RazorLogHubTraceProvider
{
public override Task<TraceSource?> InitializeTraceAsync(string logIdentifier, int logHubSessionId, CancellationToken cancellationToken)
{
// VS4Mac doesn't really support trace source logging today well. For now we'll generate a dummy trace source to ensure dependencies don't fall over.
return Task.FromResult<TraceSource?>(new TraceSource(logIdentifier));
}
}

Просмотреть файл

@ -1,31 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>$(DefaultNetFxTargetFramework)</TargetFramework>
<Description>Razor is a markup syntax for adding server-side logic to web pages. This package contains the Razor design-time infrastructure for Visual Studio for Mac.</Description>
<EnableApiCheck>false</EnableApiCheck>
<NoWarn>$(NoWarn);MSB3277</NoWarn>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<ExcludeFromSourceBuild>true</ExcludeFromSourceBuild>
<IsShippingPackage>false</IsShippingPackage>
<IsPackable Condition="'$(OS)' != 'Windows_NT'">false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MonoDevelop.Sdk" Version="$(MonoDevelopSdkPackageVersion)" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.VisualStudio.Editor.Razor\Microsoft.VisualStudio.Editor.Razor.csproj" />
</ItemGroup>
<ItemGroup Label="String Resources">
<EmbeddedResource Update="Resources\SR.resx">
<GenerateSource>true</GenerateSource>
<Namespace>$(ProjectName).Resources</Namespace>
</EmbeddedResource>
<Using Include="$(ProjectName).Resources" />
</ItemGroup>
</Project>

Просмотреть файл

@ -1,145 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using System.ComponentModel.Composition;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.VisualStudio.Editor.Razor;
using MonoDevelop.Ide;
using MonoDevelop.Projects;
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor;
[Export(typeof(IProjectSnapshotChangeTrigger))]
internal class ProjectBuildChangeTrigger : IProjectSnapshotChangeTrigger
{
private readonly TextBufferProjectService _projectService;
private readonly ProjectWorkspaceStateGenerator _workspaceStateGenerator;
private readonly ProjectSnapshotManagerDispatcher _projectSnapshotManagerDispatcher;
private ProjectSnapshotManagerBase? _projectManager;
[ImportingConstructor]
public ProjectBuildChangeTrigger(
ProjectSnapshotManagerDispatcher projectSnapshotManagerDispatcher,
TextBufferProjectService projectService,
ProjectWorkspaceStateGenerator workspaceStateGenerator)
{
if (projectSnapshotManagerDispatcher is null)
{
throw new ArgumentNullException(nameof(projectSnapshotManagerDispatcher));
}
if (projectService is null)
{
throw new ArgumentNullException(nameof(projectService));
}
if (workspaceStateGenerator is null)
{
throw new ArgumentNullException(nameof(workspaceStateGenerator));
}
_projectSnapshotManagerDispatcher = projectSnapshotManagerDispatcher;
_projectService = projectService;
_workspaceStateGenerator = workspaceStateGenerator;
}
// Internal for testing
internal ProjectBuildChangeTrigger(
ProjectSnapshotManagerDispatcher projectSnapshotManagerDispatcher,
TextBufferProjectService projectService,
ProjectWorkspaceStateGenerator workspaceStateGenerator,
ProjectSnapshotManagerBase projectManager)
{
if (projectSnapshotManagerDispatcher is null)
{
throw new ArgumentNullException(nameof(projectSnapshotManagerDispatcher));
}
if (projectService is null)
{
throw new ArgumentNullException(nameof(projectService));
}
if (workspaceStateGenerator is null)
{
throw new ArgumentNullException(nameof(workspaceStateGenerator));
}
if (projectManager is null)
{
throw new ArgumentNullException(nameof(projectManager));
}
_projectSnapshotManagerDispatcher = projectSnapshotManagerDispatcher;
_projectService = projectService;
_projectManager = projectManager;
_workspaceStateGenerator = workspaceStateGenerator;
}
public void Initialize(ProjectSnapshotManagerBase projectManager)
{
_projectManager = projectManager;
if (IdeApp.ProjectOperations is not null)
{
IdeApp.ProjectOperations.EndBuild += ProjectOperations_EndBuild;
}
}
private void ProjectOperations_EndBuild(object sender, BuildEventArgs args)
{
if (args is null)
{
throw new ArgumentNullException(nameof(args));
}
_ = HandleEndBuildAsync(args);
}
// Internal for testing
internal Task HandleEndBuildAsync(BuildEventArgs args)
{
if (!args.Success)
{
// Build failed
return Task.CompletedTask;
}
return _projectSnapshotManagerDispatcher.RunOnDispatcherThreadAsync((projectItem, ct) =>
{
if (!_projectService.IsSupportedProject(projectItem))
{
// We're hooked into all build events, it's possible to get called with an unsupported project item type.
return;
}
var projectPath = _projectService.GetProjectPath(projectItem);
if (_projectManager is null)
{
return;
}
var projectKeys = _projectManager.GetAllProjectKeys(projectPath);
foreach (var projectKey in projectKeys)
{
var projectSnapshot = _projectManager?.GetLoadedProject(projectKey);
if (projectSnapshot is not null)
{
var workspaceProject = _projectManager?.Workspace.CurrentSolution.Projects.FirstOrDefault(wp => ProjectKey.From(wp) == projectSnapshot.Key);
if (workspaceProject is not null)
{
// Trigger a tag helper update by forcing the project manager to see the workspace Project
// from the current solution.
_workspaceStateGenerator.Update(workspaceProject, projectSnapshot, CancellationToken.None);
}
}
}
}, args.SolutionItem, CancellationToken.None);
}
}

Просмотреть файл

@ -1,186 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.VisualStudio.Editor.Razor;
using MonoDevelop.Projects;
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.ProjectSystem;
internal class DefaultDotNetProjectHost : DotNetProjectHost
{
private const string ExplicitRazorConfigurationCapability = "DotNetCoreRazorConfiguration";
private readonly DotNetProject _project;
private readonly ProjectSnapshotManagerDispatcher _projectSnapshotManagerDispatcher;
private readonly VisualStudioMacWorkspaceAccessor _workspaceAccessor;
private readonly TextBufferProjectService _projectService;
private readonly ProjectConfigurationFilePathStore _projectConfigurationFilePathStore;
private readonly LanguageServerFeatureOptions _languageServerFeatureOptions;
private MacRazorProjectHostBase? _razorProjectHost;
public DefaultDotNetProjectHost(
DotNetProject project,
ProjectSnapshotManagerDispatcher projectSnapshotManagerDispatcher,
VisualStudioMacWorkspaceAccessor workspaceAccessor,
TextBufferProjectService projectService,
ProjectConfigurationFilePathStore projectConfigurationFilePathStore,
LanguageServerFeatureOptions languageServerFeatureOptions)
{
if (project is null)
{
throw new ArgumentNullException(nameof(project));
}
if (projectSnapshotManagerDispatcher is null)
{
throw new ArgumentNullException(nameof(projectSnapshotManagerDispatcher));
}
if (workspaceAccessor is null)
{
throw new ArgumentNullException(nameof(workspaceAccessor));
}
if (projectService is null)
{
throw new ArgumentNullException(nameof(projectService));
}
if (projectConfigurationFilePathStore is null)
{
throw new ArgumentNullException(nameof(projectConfigurationFilePathStore));
}
if (languageServerFeatureOptions is null)
{
throw new ArgumentNullException(nameof(languageServerFeatureOptions));
}
_project = project;
_projectSnapshotManagerDispatcher = projectSnapshotManagerDispatcher;
_workspaceAccessor = workspaceAccessor;
_projectService = projectService;
_projectConfigurationFilePathStore = projectConfigurationFilePathStore;
_languageServerFeatureOptions = languageServerFeatureOptions;
}
// Internal for testing
#pragma warning disable CS8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable.
internal DefaultDotNetProjectHost(
#pragma warning restore CS8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable.
ProjectSnapshotManagerDispatcher projectSnapshotManagerDispatcher,
VisualStudioMacWorkspaceAccessor workspaceAccessor,
TextBufferProjectService projectService,
ProjectConfigurationFilePathStore projectConfigurationFilePathStore,
LanguageServerFeatureOptions languageServerFeatureOptions)
{
if (projectSnapshotManagerDispatcher is null)
{
throw new ArgumentNullException(nameof(projectSnapshotManagerDispatcher));
}
if (workspaceAccessor is null)
{
throw new ArgumentNullException(nameof(workspaceAccessor));
}
if (projectService is null)
{
throw new ArgumentNullException(nameof(projectService));
}
if (projectConfigurationFilePathStore is null)
{
throw new ArgumentNullException(nameof(projectConfigurationFilePathStore));
}
if (languageServerFeatureOptions is null)
{
throw new ArgumentNullException(nameof(languageServerFeatureOptions));
}
_projectSnapshotManagerDispatcher = projectSnapshotManagerDispatcher;
_workspaceAccessor = workspaceAccessor;
_projectService = projectService;
_projectConfigurationFilePathStore = projectConfigurationFilePathStore;
_languageServerFeatureOptions = languageServerFeatureOptions;
}
public override DotNetProject Project => _project;
public override void Subscribe()
{
UpdateRazorHostProject();
_project.ProjectCapabilitiesChanged += Project_ProjectCapabilitiesChanged;
_project.Disposing += Project_Disposing;
}
private void Project_Disposing(object sender, EventArgs e)
{
_project.ProjectCapabilitiesChanged -= Project_ProjectCapabilitiesChanged;
_project.Disposing -= Project_Disposing;
_ = _projectSnapshotManagerDispatcher.RunOnDispatcherThreadAsync(() => DetachCurrentRazorProjectHost(), CancellationToken.None);
}
private void Project_ProjectCapabilitiesChanged(object sender, EventArgs e) => UpdateRazorHostProject();
// Internal for testing
internal void UpdateRazorHostProject()
{
_ = _projectSnapshotManagerDispatcher.RunOnDispatcherThreadAsync(() =>
{
DetachCurrentRazorProjectHost();
if (!_projectService.IsSupportedProject(_project))
{
// Not a Razor compatible project.
return;
}
if (!TryGetProjectSnapshotManager(out var projectSnapshotManager))
{
// Could not get a ProjectSnapshotManager for the current project.
return;
}
if (_project.IsCapabilityMatch(ExplicitRazorConfigurationCapability))
{
// SDK >= 2.1
_razorProjectHost = new DefaultMacRazorProjectHost(_project, _projectSnapshotManagerDispatcher, projectSnapshotManager, _projectConfigurationFilePathStore, _languageServerFeatureOptions);
return;
}
// We're an older version of Razor at this point, SDK < 2.1
_razorProjectHost = new FallbackMacRazorProjectHost(_project, _projectSnapshotManagerDispatcher, projectSnapshotManager, _projectConfigurationFilePathStore, _languageServerFeatureOptions);
}, CancellationToken.None);
}
private bool TryGetProjectSnapshotManager([NotNullWhen(returnValue: true)] out ProjectSnapshotManagerBase? projectSnapshotManagerBase)
{
if (!_workspaceAccessor.TryGetWorkspace(_project.ParentSolution, out var workspace))
{
// Could not locate workspace for razor project. Project is most likely tearing down.
projectSnapshotManagerBase = null;
return false;
}
var languageService = workspace.Services.GetLanguageServices(RazorLanguage.Name);
projectSnapshotManagerBase = (ProjectSnapshotManagerBase)languageService.GetRequiredService<ProjectSnapshotManager>();
return true;
}
private void DetachCurrentRazorProjectHost()
{
_razorProjectHost?.Detach();
_razorProjectHost = null;
}
}

Просмотреть файл

@ -1,273 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using MonoDevelop.Projects;
using MonoDevelop.Projects.MSBuild;
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.ProjectSystem;
internal class DefaultMacRazorProjectHost : MacRazorProjectHostBase
{
private const string RazorLangVersionProperty = "RazorLangVersion";
private const string RazorDefaultConfigurationProperty = "RazorDefaultConfiguration";
private const string RazorExtensionItemType = "RazorExtension";
private const string RazorConfigurationItemType = "RazorConfiguration";
private const string RazorConfigurationItemTypeExtensionsProperty = "Extensions";
private const string RootNamespaceProperty = "RootNamespace";
private readonly LanguageServerFeatureOptions _languageServerFeatureOptions;
private IReadOnlyList<string> _currentRazorFilePaths = Array.Empty<string>();
public DefaultMacRazorProjectHost(
DotNetProject project,
ProjectSnapshotManagerDispatcher projectSnapshotManagerDispatcher,
ProjectSnapshotManagerBase projectSnapshotManager,
ProjectConfigurationFilePathStore projectConfigurationFilePathStore,
LanguageServerFeatureOptions languageServerFeatureOptions)
: base(project, projectSnapshotManagerDispatcher, projectSnapshotManager, projectConfigurationFilePathStore)
{
_languageServerFeatureOptions = languageServerFeatureOptions;
}
protected override async Task OnProjectChangedAsync()
{
await ExecuteWithLockAsync(async () =>
{
var projectProperties = DotNetProject.MSBuildProject.EvaluatedProperties;
var projectItems = DotNetProject.MSBuildProject.EvaluatedItems;
if (TryGetIntermediateOutputPath(projectProperties, out var intermediatePath) &&
TryGetConfiguration(projectProperties, projectItems, out var configuration))
{
TryGetRootNamespace(projectProperties, out var rootNamespace);
var hostProject = new HostProject(DotNetProject.FileName.FullPath, intermediatePath, configuration, rootNamespace);
var projectConfigurationFile = Path.Combine(intermediatePath, _languageServerFeatureOptions.ProjectConfigurationFileName);
ProjectConfigurationFilePathStore.Set(hostProject.Key, projectConfigurationFile);
await UpdateHostProjectUnsafeAsync(hostProject).ConfigureAwait(false);
UpdateDocuments(hostProject, projectItems);
}
else
{
// Ok we can't find a configuration. Let's assume this project isn't using Razor then.
await UpdateHostProjectUnsafeAsync(null).ConfigureAwait(false);
}
});
}
internal IReadOnlyList<string> GetRazorDocuments(string projectDirectory, IEnumerable<IMSBuildItemEvaluated> projectItems)
{
var documentFilePaths = projectItems
.Where(IsRazorDocumentItem)
.Select(item => GetAbsolutePath(projectDirectory, item.Include))
.ToList();
return documentFilePaths;
}
private void UpdateDocuments(HostProject hostProject, IEnumerable<IMSBuildItemEvaluated> projectItems)
{
var projectDirectory = Path.GetDirectoryName(hostProject.FilePath);
var documentFilePaths = GetRazorDocuments(projectDirectory, projectItems);
var oldFiles = _currentRazorFilePaths;
var newFiles = documentFilePaths.ToImmutableHashSet();
var addedFiles = newFiles.Except(oldFiles);
var removedFiles = oldFiles.Except(newFiles);
_currentRazorFilePaths = documentFilePaths;
_ = ProjectSnapshotManagerDispatcher.RunOnDispatcherThreadAsync(() =>
{
foreach (var document in removedFiles)
{
RemoveDocument(hostProject, document);
}
foreach (var document in addedFiles)
{
var relativeFilePath = document[(projectDirectory.Length + 1)..];
AddDocument(hostProject, document, relativeFilePath);
}
},
CancellationToken.None);
}
// Internal for testing
internal static bool IsRazorDocumentItem(IMSBuildItemEvaluated item)
{
if (item is null)
{
throw new ArgumentNullException(nameof(item));
}
if (item.Include is null)
{
return false;
}
if (!item.Include.EndsWith(".razor", StringComparison.OrdinalIgnoreCase) && !item.Include.EndsWith(".cshtml", StringComparison.OrdinalIgnoreCase))
{
// Doesn't have a Razor looking file extension
return false;
}
return true;
}
private static string GetAbsolutePath(string projectDirectory, string relativePath)
{
if (!Path.IsPathRooted(relativePath))
{
relativePath = Path.Combine(projectDirectory, relativePath);
}
// Normalize the path separator characters in case they're mixed
relativePath = relativePath.Replace('\\', Path.DirectorySeparatorChar);
return relativePath;
}
// Internal for testing
internal static bool TryGetConfiguration(
IMSBuildEvaluatedPropertyCollection projectProperties,
IEnumerable<IMSBuildItemEvaluated> projectItems,
[NotNullWhen(returnValue: true)] out RazorConfiguration? configuration)
{
if (!TryGetDefaultConfiguration(projectProperties, out var defaultConfiguration))
{
configuration = null;
return false;
}
if (!TryGetLanguageVersion(projectProperties, out var languageVersion))
{
configuration = null;
return false;
}
if (!TryGetConfigurationItem(defaultConfiguration, projectItems, out var configurationItem))
{
configuration = null;
return false;
}
var extensionNames = GetExtensionNames(configurationItem);
var extensions = GetExtensions(extensionNames, projectItems);
configuration = new ProjectSystemRazorConfiguration(languageVersion, configurationItem.Include, extensions);
return true;
}
// Internal for testing
internal static bool TryGetDefaultConfiguration(IMSBuildEvaluatedPropertyCollection projectProperties, [NotNullWhen(returnValue: true)] out string? defaultConfiguration)
{
defaultConfiguration = projectProperties.GetValue(RazorDefaultConfigurationProperty);
if (string.IsNullOrEmpty(defaultConfiguration))
{
defaultConfiguration = null;
return false;
}
return true;
}
// Internal for testing
internal static bool TryGetLanguageVersion(IMSBuildEvaluatedPropertyCollection projectProperties, [NotNullWhen(returnValue: true)] out RazorLanguageVersion? languageVersion)
{
var languageVersionValue = projectProperties.GetValue(RazorLangVersionProperty);
if (string.IsNullOrEmpty(languageVersionValue))
{
languageVersion = null;
return false;
}
if (!RazorLanguageVersion.TryParse(languageVersionValue, out languageVersion))
{
languageVersion = RazorLanguageVersion.Latest;
}
return true;
}
// Internal for testing
internal static bool TryGetConfigurationItem(
string configuration,
IEnumerable<IMSBuildItemEvaluated> projectItems,
[NotNullWhen(returnValue: true)] out IMSBuildItemEvaluated? configurationItem)
{
foreach (var item in projectItems)
{
if (item.Name == RazorConfigurationItemType && item.Include == configuration)
{
configurationItem = item;
return true;
}
}
configurationItem = null;
return false;
}
// Internal for testing
internal static string[] GetExtensionNames(IMSBuildItemEvaluated configurationItem)
{
var extensionNamesValue = configurationItem.Metadata.GetValue(RazorConfigurationItemTypeExtensionsProperty);
if (string.IsNullOrEmpty(extensionNamesValue))
{
return Array.Empty<string>();
}
return extensionNamesValue.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
}
// Internal for testing
internal static ProjectSystemRazorExtension[] GetExtensions(
string[] configuredExtensionNames,
IEnumerable<IMSBuildItemEvaluated> projectItems)
{
var extensions = new List<ProjectSystemRazorExtension>();
foreach (var item in projectItems)
{
if (item.Name != RazorExtensionItemType)
{
// Not a RazorExtension
continue;
}
var extensionName = item.Include;
if (configuredExtensionNames.Contains(extensionName))
{
extensions.Add(new ProjectSystemRazorExtension(extensionName));
}
}
return extensions.ToArray();
}
// Internal for testing
internal static bool TryGetRootNamespace(IMSBuildEvaluatedPropertyCollection projectProperties, [NotNullWhen(returnValue: true)] out string? rootNamespace)
{
rootNamespace = projectProperties.GetValue(RootNamespaceProperty);
if (string.IsNullOrEmpty(rootNamespace))
{
rootNamespace = null;
return false;
}
return true;
}
}

Просмотреть файл

@ -1,13 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using MonoDevelop.Projects;
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.ProjectSystem;
internal abstract class DotNetProjectHost
{
public abstract DotNetProject Project { get; }
public abstract void Subscribe();
}

Просмотреть файл

@ -1,74 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using System.ComponentModel.Composition;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.VisualStudio.Editor.Razor;
using MonoDevelop.Projects;
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.ProjectSystem;
[System.Composition.Shared]
[Export(typeof(DotNetProjectHostFactory))]
internal class DotNetProjectHostFactory
{
private readonly ProjectSnapshotManagerDispatcher _projectSnapshotManagerDispatcher;
private readonly VisualStudioMacWorkspaceAccessor _workspaceAccessor;
private readonly TextBufferProjectService _projectService;
private readonly ProjectConfigurationFilePathStore _projectConfigurationFilePathStore;
private readonly LanguageServerFeatureOptions _languageServerFeatureOptions;
[ImportingConstructor]
public DotNetProjectHostFactory(
ProjectSnapshotManagerDispatcher projectSnapshotManagerDispatcher,
VisualStudioMacWorkspaceAccessor workspaceAccessor,
TextBufferProjectService projectService,
ProjectConfigurationFilePathStore projectConfigurationFilePathStore,
LanguageServerFeatureOptions languageServerFeatureOptions)
{
if (projectSnapshotManagerDispatcher is null)
{
throw new ArgumentNullException(nameof(projectSnapshotManagerDispatcher));
}
if (workspaceAccessor is null)
{
throw new ArgumentNullException(nameof(workspaceAccessor));
}
if (projectService is null)
{
throw new ArgumentNullException(nameof(projectService));
}
if (projectConfigurationFilePathStore is null)
{
throw new ArgumentNullException(nameof(projectConfigurationFilePathStore));
}
if (languageServerFeatureOptions is null)
{
throw new ArgumentNullException(nameof(languageServerFeatureOptions));
}
_projectSnapshotManagerDispatcher = projectSnapshotManagerDispatcher;
_workspaceAccessor = workspaceAccessor;
_projectService = projectService;
_projectConfigurationFilePathStore = projectConfigurationFilePathStore;
_languageServerFeatureOptions = languageServerFeatureOptions;
}
public DotNetProjectHost Create(DotNetProject project)
{
if (project is null)
{
throw new ArgumentNullException(nameof(project));
}
var projectHost = new DefaultDotNetProjectHost(project, _projectSnapshotManagerDispatcher, _workspaceAccessor, _projectService, _projectConfigurationFilePathStore, _languageServerFeatureOptions);
return projectHost;
}
}

Просмотреть файл

@ -1,108 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using System.IO;
using System.Linq;
using System.Reflection.Metadata;
using System.Reflection.PortableExecutable;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using MonoDevelop.Projects;
using AssemblyReference = MonoDevelop.Projects.AssemblyReference;
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.ProjectSystem;
internal class FallbackMacRazorProjectHost : MacRazorProjectHostBase
{
private const string MvcAssemblyFileName = "Microsoft.AspNetCore.Mvc.Razor.dll";
private readonly LanguageServerFeatureOptions _languageServerFeatureOptions;
public FallbackMacRazorProjectHost(
DotNetProject project,
ProjectSnapshotManagerDispatcher projectSnapshotManagerDispatcher,
ProjectSnapshotManagerBase projectSnapshotManager,
ProjectConfigurationFilePathStore projectConfigurationFilePathStore,
LanguageServerFeatureOptions languageServerFeatureOptions)
: base(project, projectSnapshotManagerDispatcher, projectSnapshotManager, projectConfigurationFilePathStore)
{
_languageServerFeatureOptions = languageServerFeatureOptions;
}
protected override async Task OnProjectChangedAsync()
{
await ExecuteWithLockAsync(async () =>
{
var referencedAssemblies = await DotNetProject.GetReferencedAssemblies(ConfigurationSelector.Default);
var mvcReference = referencedAssemblies.FirstOrDefault(IsMvcAssembly);
var projectProperties = DotNetProject.MSBuildProject.EvaluatedProperties;
if (!TryGetIntermediateOutputPath(projectProperties, out var intermediatePath))
{
return;
}
if (mvcReference is null)
{
// Ok we can't find an MVC version. Let's assume this project isn't using Razor then.
await UpdateHostProjectUnsafeAsync(null).ConfigureAwait(false);
return;
}
var version = GetAssemblyVersion(mvcReference.FilePath);
if (version is null)
{
// Ok we can't find an MVC version. Let's assume this project isn't using Razor then.
await UpdateHostProjectUnsafeAsync(null).ConfigureAwait(false);
return;
}
var configuration = FallbackRazorConfiguration.SelectConfiguration(version);
var hostProject = new HostProject(DotNetProject.FileName.FullPath, intermediatePath, configuration, rootNamespace: null);
var projectConfigurationFile = Path.Combine(intermediatePath, _languageServerFeatureOptions.ProjectConfigurationFileName);
ProjectConfigurationFilePathStore.Set(hostProject.Key, projectConfigurationFile);
await UpdateHostProjectUnsafeAsync(hostProject).ConfigureAwait(false);
});
}
// Internal for testing
internal static bool IsMvcAssembly(AssemblyReference reference)
{
var fileName = reference?.FilePath.FileName;
if (string.IsNullOrEmpty(fileName))
{
return false;
}
if (string.Equals(reference!.FilePath.FileName, MvcAssemblyFileName, StringComparison.OrdinalIgnoreCase))
{
// Mvc assembly
return true;
}
return false;
}
private static Version? GetAssemblyVersion(string filePath)
{
try
{
using var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
using var reader = new PEReader(stream);
var metadataReader = reader.GetMetadataReader();
var assemblyDefinition = metadataReader.GetAssemblyDefinition();
return assemblyDefinition.Version;
}
catch
{
// We're purposely silencing any kinds of I/O exceptions here, just in case something wacky is going on.
return null;
}
}
}

Просмотреть файл

@ -1,283 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.VisualStudio.Threading;
using MonoDevelop.Projects;
using MonoDevelop.Projects.MSBuild;
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.ProjectSystem;
internal abstract class MacRazorProjectHostBase
{
// References changes are always triggered when project changes happen.
private const string ProjectChangedHint = "References";
private const string IntermediateOutputPathPropertyName = "IntermediateOutputPath";
private const string MSBuildProjectDirectoryPropertyName = "MSBuildProjectDirectory";
private bool _batchingProjectChanges;
protected readonly ProjectConfigurationFilePathStore ProjectConfigurationFilePathStore;
private readonly ProjectSnapshotManagerBase _projectSnapshotManager;
private readonly AsyncSemaphore _onProjectChangedInnerSemaphore;
private readonly AsyncSemaphore _projectChangedSemaphore;
private readonly Dictionary<string, HostDocument> _currentDocuments;
public MacRazorProjectHostBase(
DotNetProject project,
ProjectSnapshotManagerDispatcher projectSnapshotManagerDispatcher,
ProjectSnapshotManagerBase projectSnapshotManager,
ProjectConfigurationFilePathStore projectConfigurationFilePathStore)
{
if (project is null)
{
throw new ArgumentNullException(nameof(project));
}
if (projectSnapshotManagerDispatcher is null)
{
throw new ArgumentNullException(nameof(projectSnapshotManagerDispatcher));
}
if (projectSnapshotManager is null)
{
throw new ArgumentNullException(nameof(projectSnapshotManager));
}
if (projectConfigurationFilePathStore is null)
{
throw new ArgumentNullException(nameof(projectConfigurationFilePathStore));
}
DotNetProject = project;
ProjectSnapshotManagerDispatcher = projectSnapshotManagerDispatcher;
_projectSnapshotManager = projectSnapshotManager;
ProjectConfigurationFilePathStore = projectConfigurationFilePathStore;
_onProjectChangedInnerSemaphore = new AsyncSemaphore(initialCount: 1);
_projectChangedSemaphore = new AsyncSemaphore(initialCount: 1);
_currentDocuments = new Dictionary<string, HostDocument>(FilePathComparer.Instance);
AttachToProject();
}
public DotNetProject DotNetProject { get; }
public HostProject? HostProject { get; private set; }
protected ProjectSnapshotManagerDispatcher ProjectSnapshotManagerDispatcher { get; }
public void Detach()
{
ProjectSnapshotManagerDispatcher.AssertDispatcherThread();
DotNetProject.Modified -= DotNetProject_Modified;
UpdateHostProjectProjectSnapshotManagerDispatcher(null);
}
protected abstract Task OnProjectChangedAsync();
// Protected virtual for testing
protected virtual void AttachToProject()
{
ProjectSnapshotManagerDispatcher.AssertDispatcherThread();
DotNetProject.Modified += DotNetProject_Modified;
// Trigger the initial update to the project.
_batchingProjectChanges = true;
_ = Task.Factory.StartNew(ProjectChangedBackgroundAsync, null, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default);
}
// Must be called inside the lock.
protected async Task UpdateHostProjectUnsafeAsync(HostProject? newHostProject)
{
await ProjectSnapshotManagerDispatcher.RunOnDispatcherThreadAsync(
() => UpdateHostProjectProjectSnapshotManagerDispatcher(newHostProject), CancellationToken.None).ConfigureAwait(false);
}
protected async Task ExecuteWithLockAsync(Func<Task> func)
{
using (await _projectChangedSemaphore.EnterAsync().ConfigureAwait(false))
{
await func().ConfigureAwait(false);
}
}
private async Task ProjectChangedBackgroundAsync(object state)
{
_batchingProjectChanges = false;
// Ensure ordering, typically we'll only have 1 background thread in flight at a time. However,
// between this line and the one prior another background thread could have also entered this
// method. This is here to protect against us changing the order of project changed events.
using (await _onProjectChangedInnerSemaphore.EnterAsync().ConfigureAwait(false))
{
await OnProjectChangedAsync();
}
}
private void DotNetProject_Modified(object sender, SolutionItemModifiedEventArgs args)
{
if (args is null)
{
throw new ArgumentNullException(nameof(args));
}
_ = ProjectSnapshotManagerDispatcher.RunOnDispatcherThreadAsync((args, ct) =>
{
if (_batchingProjectChanges)
{
// Already waiting to recompute host project, no need to do any more work to determine if we're dirty.
return;
}
var projectChanged = args.Any(arg => string.Equals(arg.Hint, ProjectChangedHint, StringComparison.Ordinal));
if (projectChanged)
{
// This method can be spammed for tons of project change events but all we really care about is "are we dirty?".
// Therefore, we re-dispatch here to allow any remaining project change events to fire and to then only have 1 host
// project change trigger; this way we don't spam our own system with re-configure calls.
_batchingProjectChanges = true;
_ = Task.Factory.StartNew(ProjectChangedBackgroundAsync, null, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default);
}
}, args, CancellationToken.None);
}
private void UpdateHostProjectProjectSnapshotManagerDispatcher(object? state)
{
ProjectSnapshotManagerDispatcher.AssertDispatcherThread();
var newHostProject = (HostProject?)state;
if (HostProject is null && newHostProject is null)
{
// This is a no-op. This project isn't using Razor.
}
else if (HostProject is null && newHostProject != null)
{
_projectSnapshotManager.ProjectAdded(newHostProject);
}
else if (HostProject != null && newHostProject is null)
{
_projectSnapshotManager.ProjectRemoved(HostProject.Key);
ProjectConfigurationFilePathStore.Remove(HostProject.Key);
}
else
{
_projectSnapshotManager.ProjectConfigurationChanged(newHostProject.AssumeNotNull());
}
HostProject = newHostProject;
}
protected void AddDocument(HostProject hostProject, string filePath, string relativeFilePath)
{
ProjectSnapshotManagerDispatcher.AssertDispatcherThread();
if (_currentDocuments.ContainsKey(filePath))
{
return;
}
var hostDocument = new HostDocument(filePath, relativeFilePath);
_projectSnapshotManager.DocumentAdded(hostProject.Key, hostDocument, new FileTextLoader(filePath, defaultEncoding: null));
_currentDocuments[filePath] = hostDocument;
}
protected void RemoveDocument(HostProject hostProject, string filePath)
{
if (_currentDocuments.TryGetValue(filePath, out var hostDocument))
{
_projectSnapshotManager.DocumentRemoved(hostProject.Key, hostDocument);
_currentDocuments.Remove(filePath);
}
}
protected bool TryGetIntermediateOutputPath(
IMSBuildEvaluatedPropertyCollection projectProperties,
[NotNullWhen(returnValue: true)] out string? path)
{
if (!projectProperties.HasProperty(IntermediateOutputPathPropertyName))
{
path = null;
return false;
}
var baseIntermediateOutputPathValue = DotNetProject.BaseIntermediateOutputPath.ToString();
if (string.IsNullOrEmpty(baseIntermediateOutputPathValue))
{
path = null;
return false;
}
var intermediateOutputPathValue = projectProperties.GetValue(IntermediateOutputPathPropertyName);
if (string.IsNullOrEmpty(intermediateOutputPathValue))
{
path = null;
return false;
}
var normalizedBaseIntermediateOutputPath = ToMacFilePath(baseIntermediateOutputPathValue);
var basePath = new DirectoryInfo(normalizedBaseIntermediateOutputPath).Parent;
var normalizedIntermediateOutputPathValue = ToMacFilePath(intermediateOutputPathValue);
var joinedPath = Path.Combine(basePath.FullName, normalizedIntermediateOutputPathValue);
if (!Directory.Exists(joinedPath))
{
// The directory doesn't exist for the currently executing application.
// This can occur in Razor class library scenarios because:
// 1. Razor class libraries base intermediate path is not absolute. Meaning instead of C:/project/obj it returns /obj.
// 2. Our `new DirectoryInfo(...).Parent` call above is forgiving so if the path passed to it isn't absolute (Razor class library scenario) it utilizes Directory.GetCurrentDirectory where
// in this case would be the C:/Windows/System path
// Because of the above two issues the joinedPath ends up looking like "C:\WINDOWS\system32\obj\Debug\netstandard2.0\" which doesn't actually exist and of course isn't writeable. The end-user effect of this
// quirk means that you don't get any component completions for Razor class libraries because we're unable to capture their project state information.
//
// To workaround these inconsistencies with Razor class libraries we fall back to the MSBuildProjectDirectory and build what we think is the intermediate output path.
joinedPath = ResolveFallbackIntermediateOutputPath(projectProperties, normalizedIntermediateOutputPathValue);
if (joinedPath is null)
{
// Still couldn't resolve a valid directory.
path = null;
return false;
}
}
path = joinedPath;
return true;
}
private string? ResolveFallbackIntermediateOutputPath(IMSBuildEvaluatedPropertyCollection projectProperties, string intermediateOutputPathValue)
{
var projectDirectory = projectProperties.HasProperty(MSBuildProjectDirectoryPropertyName)
? projectProperties.GetValue(MSBuildProjectDirectoryPropertyName)
: DotNetProject.BaseDirectory.ToString();
var normalizedProjectDirectory = ToMacFilePath(projectDirectory);
var joinedPath = Path.Combine(normalizedProjectDirectory, intermediateOutputPathValue);
if (!Directory.Exists(joinedPath))
{
return null;
}
return joinedPath;
}
/// <summary>
/// Project system file paths get returned in windows based foramts. Meaning they typically have `\` as their path separator. Because of this in order to
/// interoperate with local file system APIs (all of the Path / Directory etc. APIs) we need to convert the paths to use `/` as the path separator.
/// </summary>
/// <param name="filePath">A project system based file path.</param>
/// <returns>A file path that can be used with File system APIs</returns>
private static string ToMacFilePath(string filePath) => filePath.Replace('\\', Path.DirectorySeparatorChar);
}

Просмотреть файл

@ -1,203 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using System.Collections.Concurrent;
using System.ComponentModel.Composition;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.VisualStudio.Editor.Razor;
using MonoDevelop.Ide.TypeSystem;
namespace Microsoft.CodeAnalysis.Razor.ProjectSystem;
// Unlike Visual Studio windows this class is not used to enable Find All References in VS4Mac. It's used to take
// the output of generated C# and push that content into the VS4Mac's workspace. This way in Blazor scenarios we
// can introspect over the solution to find Components that should be turned into TagHelperDescriptors.
[System.Composition.Shared]
[ExportMetadata("Extensions", new string[] { "cshtml", "razor", })]
[Export(typeof(IDynamicDocumentInfoProvider))]
[Export(typeof(IProjectSnapshotChangeTrigger))]
internal class RazorDynamicDocumentInfoProvider : IProjectSnapshotChangeTrigger, IDynamicDocumentInfoProvider
{
private readonly ConcurrentDictionary<Key, Entry> _entries;
private readonly VisualStudioMacDocumentInfoFactory _documentInfoFactory;
private readonly IRazorDynamicFileInfoProvider _dynamicFileInfoProvider;
[ImportingConstructor]
public RazorDynamicDocumentInfoProvider(
VisualStudioMacDocumentInfoFactory documentInfoFactory,
IRazorDynamicFileInfoProvider dynamicFileInfoProvider)
{
_entries = new ConcurrentDictionary<Key, Entry>();
_documentInfoFactory = documentInfoFactory;
_dynamicFileInfoProvider = dynamicFileInfoProvider;
_dynamicFileInfoProvider.Updated += InnerUpdated;
}
public event Action<DocumentInfo>? Updated;
public void Initialize(ProjectSnapshotManagerBase projectManager)
{
((IProjectSnapshotChangeTrigger)_dynamicFileInfoProvider).Initialize(projectManager);
}
public DocumentInfo GetDynamicDocumentInfo(ProjectId projectId, string projectFilePath, string filePath)
{
if (projectFilePath is null)
{
throw new ArgumentNullException(nameof(projectFilePath));
}
if (filePath is null)
{
throw new ArgumentNullException(nameof(filePath));
}
var razorProjectKey = ((DefaultRazorDynamicFileInfoProvider)_dynamicFileInfoProvider).TryFindProjectKeyForProjectId(projectId);
if (razorProjectKey is not ProjectKey projectKey)
{
Debug.Fail("Could not find project key for project id.");
// The class that calls this method in VS Mac handles null just fine.
return null!;
}
// The underlying method doesn't actually do anything truly asynchronous which allows us to synchronously call it.
#pragma warning disable VSTHRD002 // Avoid problematic synchronous waits
_ = _dynamicFileInfoProvider.GetDynamicFileInfoAsync(projectId, projectFilePath, filePath, CancellationToken.None).Result;
#pragma warning restore VSTHRD002 // Avoid problematic synchronous waits
var key = new Key(projectId, projectFilePath, filePath);
var entry = _entries.GetOrAdd(key, k => new Entry(_documentInfoFactory.CreateEmpty(k.FilePath, projectId, projectKey)));
return entry.Current;
}
public void RemoveDynamicDocumentInfo(ProjectId projectId, string projectFilePath, string filePath)
{
if (projectFilePath is null)
{
throw new ArgumentNullException(nameof(projectFilePath));
}
if (filePath is null)
{
throw new ArgumentNullException(nameof(filePath));
}
// The underlying method doesn't actually do anything truly asynchronous which allows us to synchronously call and wait on it.
#pragma warning disable VSTHRD002 // Avoid problematic synchronous waits
_dynamicFileInfoProvider.RemoveDynamicFileInfoAsync(projectId, projectFilePath, filePath, CancellationToken.None).Wait();
#pragma warning restore VSTHRD002 // Avoid problematic synchronous waits
var key = new Key(projectId, projectFilePath, filePath);
_entries.TryRemove(key, out _);
}
private void InnerUpdated(object sender, string path)
{
// A filepath could be shared among more than one project which would result in us having multiple document infos present.
// To address this we capture all the document infos that apply to the "updated" filepath
var impactedEntries = _entries.Where(kvp => string.Equals(kvp.Key.FilePath, path, FilePathComparison.Instance)).ToList();
for (var i = 0; i < impactedEntries.Count; i++)
{
var impactedEntry = impactedEntries[i];
lock (impactedEntry.Value.Lock)
{
// The underlying method doesn't actually do anything truly asynchronous which allows us to synchronously call it.
#pragma warning disable VSTHRD002 // Avoid problematic synchronous waits
var innerDynamicFileInfo = _dynamicFileInfoProvider.GetDynamicFileInfoAsync(impactedEntry.Key.ProjectId, impactedEntry.Key.ProjectFilePath, impactedEntry.Key.FilePath, CancellationToken.None).Result;
#pragma warning restore VSTHRD002 // Avoid problematic synchronous waits
// Update our DocumentInfo with the text loader and document services from the dynamic file
var newDocumentInfo = innerDynamicFileInfo.ToUpdatedDocumentInfo(impactedEntry.Value.Current);
impactedEntry.Value.Current = newDocumentInfo;
Updated?.Invoke(newDocumentInfo);
}
}
}
// Using a separate handle to the 'current' file info so that can allow Roslyn to send
// us the add/remove operations, while we process the update operations.
public class Entry
{
// Can't ever be null for thread-safety reasons
private DocumentInfo _current;
public Entry(DocumentInfo current)
{
if (current is null)
{
throw new ArgumentNullException(nameof(current));
}
_current = current;
Lock = new object();
}
public DocumentInfo Current
{
get => _current;
set
{
if (value is null)
{
throw new ArgumentNullException(nameof(value));
}
_current = value;
}
}
public object Lock { get; }
public override string ToString()
{
lock (Lock)
{
return $"{Current.FilePath} - {(Current.TextLoader is null ? "null" : Current.TextLoader.GetType())}";
}
}
}
private readonly struct Key : IEquatable<Key>
{
public readonly ProjectId ProjectId;
public readonly string ProjectFilePath;
public readonly string FilePath;
public Key(ProjectId projectId, string projectFilePath, string filePath)
{
ProjectId = projectId;
ProjectFilePath = projectFilePath;
FilePath = filePath;
}
public bool Equals(Key other)
{
return
ProjectId == other.ProjectId &&
FilePathComparer.Instance.Equals(ProjectFilePath, other.ProjectFilePath) &&
FilePathComparer.Instance.Equals(FilePath, other.FilePath);
}
public override bool Equals(object obj)
{
return obj is Key other && Equals(other);
}
public override int GetHashCode()
{
return (
ProjectId?.GetHashCode(),
FilePathComparer.Instance.GetHashCode(ProjectFilePath),
FilePathComparer.Instance.GetHashCode(FilePath)).GetHashCode();
}
}
}

Просмотреть файл

@ -1,8 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Mac.RazorAddin, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Mac.LanguageServices.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]

Просмотреть файл

@ -1,72 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Threading.Tasks;
using Microsoft.VisualStudio.Editor.Razor;
using Microsoft.VisualStudio.Editor.Razor.Documents;
using Microsoft.VisualStudio.Text;
using MonoDevelop.Core;
using MonoDevelop.Ide.Composition;
using MonoDevelop.Ide.Gui.Documents;
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor;
/// <summary>
/// This is a way to notify the VisualStudioMacEditorDocumentManager when Razor documents are
/// opened or closed.
/// </summary>
[ExportDocumentControllerExtension(MimeType = "text/x-cshtml-web")]
internal class RazorDocumentControllerExtension : DocumentControllerExtension
{
private readonly VisualStudioWorkspaceAccessor _workspaceAccessor;
private VisualStudioMacEditorDocumentManager? _editorDocumentManager;
public RazorDocumentControllerExtension()
{
_workspaceAccessor = CompositionManager.Instance.GetExportedValue<VisualStudioMacWorkspaceAccessor>();
}
public override Task Initialize(Properties status)
{
var controller = (FileDocumentController)Controller;
var filePath = controller.FilePath.ToString();
var textBuffer = controller.GetContent<ITextBuffer>();
if (!_workspaceAccessor.TryGetWorkspace(textBuffer, out var workspace))
{
return Task.CompletedTask;
}
_editorDocumentManager = workspace.Services.GetRequiredService<EditorDocumentManager>() as VisualStudioMacEditorDocumentManager;
Assumes.NotNull(_editorDocumentManager);
_editorDocumentManager.HandleDocumentOpened(filePath, textBuffer);
return Task.CompletedTask;
}
protected internal override void OnClosed()
{
if (_editorDocumentManager is null)
{
return;
}
var controller = (FileDocumentController)Controller;
var filePath = controller.FilePath.ToString();
_editorDocumentManager.HandleDocumentClosed(filePath);
}
public override Task<bool> SupportsController(DocumentController controller)
{
if (controller.GetContent<ITextBuffer>() is null || controller is not FileDocumentController)
{
return Task.FromResult(false);
}
var supportsController = base.SupportsController(controller);
return supportsController;
}
}

Просмотреть файл

@ -1,133 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="ArgumentCannotBeNullOrEmpty" xml:space="preserve">
<value>Value cannot be null or an empty string.</value>
</data>
<data name="RazorLanguageServiceGeneralError" xml:space="preserve">
<value>Razor Language Service error encountered.</value>
</data>
<data name="RazorLanguageServiceProjectError" xml:space="preserve">
<value>Razor Language Service error encountered from project '{0}'.</value>
</data>
<data name="RazorLanguageServiceProjectSnapshotError" xml:space="preserve">
<value>Error encountered from project '{0}':
{1}</value>
</data>
</root>

Просмотреть файл

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="cs" original="../SR.resx">
<body>
<trans-unit id="ArgumentCannotBeNullOrEmpty">
<source>Value cannot be null or an empty string.</source>
<target state="translated">Hodnota nesmí být null ani prázdný řetězec.</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceGeneralError">
<source>Razor Language Service error encountered.</source>
<target state="translated">Došlo k chybě služby jazyka Razor.</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceProjectError">
<source>Razor Language Service error encountered from project '{0}'.</source>
<target state="translated">Došlo k chybě služby jazyka Razor v projektu {0}.</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceProjectSnapshotError">
<source>Error encountered from project '{0}':
{1}</source>
<target state="translated">Došlo k chybě v projektu {0}:
{1}</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="de" original="../SR.resx">
<body>
<trans-unit id="ArgumentCannotBeNullOrEmpty">
<source>Value cannot be null or an empty string.</source>
<target state="translated">Der Wert darf nicht NULL oder eine leere Zeichenfolge sein.</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceGeneralError">
<source>Razor Language Service error encountered.</source>
<target state="translated">Razor-Sprachdienstfehler.</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceProjectError">
<source>Razor Language Service error encountered from project '{0}'.</source>
<target state="translated">Razor-Sprachdienstfehler im Projekt "{0}".</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceProjectSnapshotError">
<source>Error encountered from project '{0}':
{1}</source>
<target state="translated">Fehler beim Projekt "{0}":
{1}</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="es" original="../SR.resx">
<body>
<trans-unit id="ArgumentCannotBeNullOrEmpty">
<source>Value cannot be null or an empty string.</source>
<target state="translated">El valor no puede ser nulo ni una cadena vacía.</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceGeneralError">
<source>Razor Language Service error encountered.</source>
<target state="translated">Se ha encontrado un error en el servicio de lenguaje Razor.</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceProjectError">
<source>Razor Language Service error encountered from project '{0}'.</source>
<target state="translated">Se ha encontrado un error del servicio de lenguaje Razor en el proyecto '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceProjectSnapshotError">
<source>Error encountered from project '{0}':
{1}</source>
<target state="translated">Se ha encontrado un error en el proyecto '{0}':
{1}</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="fr" original="../SR.resx">
<body>
<trans-unit id="ArgumentCannotBeNullOrEmpty">
<source>Value cannot be null or an empty string.</source>
<target state="translated">La valeur ne peut pas être Null ni être une chaîne vide.</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceGeneralError">
<source>Razor Language Service error encountered.</source>
<target state="translated">Erreur du service de langage Razor rencontrée.</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceProjectError">
<source>Razor Language Service error encountered from project '{0}'.</source>
<target state="translated">Erreur Razor Language Service rencontrée à partir du projet «{0}».</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceProjectSnapshotError">
<source>Error encountered from project '{0}':
{1}</source>
<target state="translated">Erreur rencontrée à partir du projet «{0}» :
{1}</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="it" original="../SR.resx">
<body>
<trans-unit id="ArgumentCannotBeNullOrEmpty">
<source>Value cannot be null or an empty string.</source>
<target state="translated">Il valore non può essere null o una stringa vuota.</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceGeneralError">
<source>Razor Language Service error encountered.</source>
<target state="translated">Si è verificato un errore del servizio di linguaggio Razor.</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceProjectError">
<source>Razor Language Service error encountered from project '{0}'.</source>
<target state="translated">Si è verificato un errore del servizio di linguaggio Razor restituito dal progetto '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceProjectSnapshotError">
<source>Error encountered from project '{0}':
{1}</source>
<target state="translated">Si è verificato un errore restituito dal progetto '{0}':
{1}</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="ja" original="../SR.resx">
<body>
<trans-unit id="ArgumentCannotBeNullOrEmpty">
<source>Value cannot be null or an empty string.</source>
<target state="translated">値を null または空の文字列にすることはできません。</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceGeneralError">
<source>Razor Language Service error encountered.</source>
<target state="translated">Razor 言語サービス エラーが発生しました。</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceProjectError">
<source>Razor Language Service error encountered from project '{0}'.</source>
<target state="translated">プロジェクト '{0}' から Razor 言語サービス エラーが発生しました。</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceProjectSnapshotError">
<source>Error encountered from project '{0}':
{1}</source>
<target state="translated">プロジェクト '{0}' でエラーが発生しました:
{1}</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="ko" original="../SR.resx">
<body>
<trans-unit id="ArgumentCannotBeNullOrEmpty">
<source>Value cannot be null or an empty string.</source>
<target state="translated">값은 null이거나 빈 문자열일 수 없습니다.</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceGeneralError">
<source>Razor Language Service error encountered.</source>
<target state="translated">Razor 언어 서비스 오류가 발생 했습니다.</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceProjectError">
<source>Razor Language Service error encountered from project '{0}'.</source>
<target state="translated">'{0}' 프로젝트에서 Razor 언어 서비스 오류가 발생했습니다.</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceProjectSnapshotError">
<source>Error encountered from project '{0}':
{1}</source>
<target state="translated">'{0}' 프로젝트에서 오류가 발생 했습니다.
{1}</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="pl" original="../SR.resx">
<body>
<trans-unit id="ArgumentCannotBeNullOrEmpty">
<source>Value cannot be null or an empty string.</source>
<target state="translated">Wartość nie może być wartością null ani pustym ciągiem.</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceGeneralError">
<source>Razor Language Service error encountered.</source>
<target state="translated">Napotkano błąd usługi języka dla składni Razor.</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceProjectError">
<source>Razor Language Service error encountered from project '{0}'.</source>
<target state="translated">Napotkano błąd usługi języka dla składni Razor z projektu: „{0}”.</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceProjectSnapshotError">
<source>Error encountered from project '{0}':
{1}</source>
<target state="translated">Napotkano błąd z projektu "{0}":
{1}</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="pt-BR" original="../SR.resx">
<body>
<trans-unit id="ArgumentCannotBeNullOrEmpty">
<source>Value cannot be null or an empty string.</source>
<target state="translated">O valor não pode ser nulo ou uma cadeia de caracteres vazia.</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceGeneralError">
<source>Razor Language Service error encountered.</source>
<target state="translated">Foi encontrado um erro no Serviço de Linguagem Razor.</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceProjectError">
<source>Razor Language Service error encountered from project '{0}'.</source>
<target state="translated">Erro do Serviço de Linguagem Razor encontrado no projeto '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceProjectSnapshotError">
<source>Error encountered from project '{0}':
{1}</source>
<target state="translated">Erro encontrado no projeto '{0}':
{1}</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="ru" original="../SR.resx">
<body>
<trans-unit id="ArgumentCannotBeNullOrEmpty">
<source>Value cannot be null or an empty string.</source>
<target state="translated">Значение не может быть NULL или пустой строкой.</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceGeneralError">
<source>Razor Language Service error encountered.</source>
<target state="translated">Произошла ошибка языковой службы Razor.</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceProjectError">
<source>Razor Language Service error encountered from project '{0}'.</source>
<target state="translated">Произошла ошибка языковой службы Razor в проекте "{0}".</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceProjectSnapshotError">
<source>Error encountered from project '{0}':
{1}</source>
<target state="translated">Произошла ошибка в проекте "{0}":
{1}</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="tr" original="../SR.resx">
<body>
<trans-unit id="ArgumentCannotBeNullOrEmpty">
<source>Value cannot be null or an empty string.</source>
<target state="translated">Değer null veya boş bir dize olamaz.</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceGeneralError">
<source>Razor Language Service error encountered.</source>
<target state="translated">Razor Dil Hizmeti hatasıyla karşılaşıldı.</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceProjectError">
<source>Razor Language Service error encountered from project '{0}'.</source>
<target state="translated">'{0}' projesinde Razor Dil Hizmeti hatasıyla karşılaşıldı.</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceProjectSnapshotError">
<source>Error encountered from project '{0}':
{1}</source>
<target state="translated">'{0}' projesinde hatayla karşılaşıldı:
{1}</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="zh-Hans" original="../SR.resx">
<body>
<trans-unit id="ArgumentCannotBeNullOrEmpty">
<source>Value cannot be null or an empty string.</source>
<target state="translated">值不能为 null 或空字符串。</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceGeneralError">
<source>Razor Language Service error encountered.</source>
<target state="translated">遇到了 Razor 语言服务错误。</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceProjectError">
<source>Razor Language Service error encountered from project '{0}'.</source>
<target state="translated">在项目 "{0}" 中遇到了 Razor 语言服务错误。</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceProjectSnapshotError">
<source>Error encountered from project '{0}':
{1}</source>
<target state="translated">在项目 "{0}" 中遇到了错误:
{1}</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="zh-Hant" original="../SR.resx">
<body>
<trans-unit id="ArgumentCannotBeNullOrEmpty">
<source>Value cannot be null or an empty string.</source>
<target state="translated">值不能為 Null 或空字串。</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceGeneralError">
<source>Razor Language Service error encountered.</source>
<target state="translated">發生 Razor 語言服務錯誤。</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceProjectError">
<source>Razor Language Service error encountered from project '{0}'.</source>
<target state="translated">從專案 '{0}' 遇到 Razor 語言服務錯誤。</target>
<note />
</trans-unit>
<trans-unit id="RazorLanguageServiceProjectSnapshotError">
<source>Error encountered from project '{0}':
{1}</source>
<target state="translated">從專案 '{0}' 遇到錯誤:
{1}</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -1,55 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using System.ComponentModel.Composition;
using System.Diagnostics;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using MonoDevelop.Core;
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor;
[Export(typeof(IErrorReporter))]
internal class VisualStudioErrorReporter : IErrorReporter
{
public void ReportError(Exception exception)
{
if (exception is null)
{
Debug.Fail("Null exceptions should not be reported.");
return;
}
LoggingService.LogError(
SR.RazorLanguageServiceGeneralError,
exception);
}
public void ReportError(Exception exception, Project project)
{
if (exception is null)
{
Debug.Fail("Null exceptions should not be reported.");
return;
}
LoggingService.LogError(
SR.FormatRazorLanguageServiceProjectError(project?.Name),
exception);
}
public void ReportError(Exception exception, IProjectSnapshot? project)
{
if (exception is null)
{
Debug.Fail("Null exceptions should not be reported.");
return;
}
LoggingService.LogError(
SR.FormatRazorLanguageServiceProjectSnapshotError(project?.FilePath, exception),
exception);
}
}

Просмотреть файл

@ -1,19 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Composition;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Razor;
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor;
[Shared]
[ExportWorkspaceServiceFactory(typeof(IErrorReporter), ServiceLayer.Host)]
internal class VisualStudioErrorReporterFactory : IWorkspaceServiceFactory
{
public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices)
{
return new VisualStudioErrorReporter();
}
}

Просмотреть файл

@ -1,22 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.VisualStudio.Editor.Razor;
using MonoDevelop.Core;
using MonoDevelop.Ide;
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor;
[Shared]
[Export(typeof(DocumentInteractionManager))]
internal class VisualStudioMacDocumentInteractionManager : DocumentInteractionManager
{
public override async Task OpenDocumentAsync(string filePath, CancellationToken cancellationToken)
{
var filePathKey = new FilePath(filePath);
await IdeApp.Workbench.OpenDocument(filePathKey, project: null, bringToFront: true).ConfigureAwait(false);
}
}

Просмотреть файл

@ -1,118 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.VisualStudio.Editor.Razor;
using Microsoft.VisualStudio.Editor.Razor.Documents;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Threading;
using MonoDevelop.Ide;
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor;
internal class VisualStudioMacEditorDocumentManager : EditorDocumentManagerBase
{
public VisualStudioMacEditorDocumentManager(
ProjectSnapshotManagerDispatcher projectSnapshotManagerDispatcher,
JoinableTaskContext joinableTaskContext,
FileChangeTrackerFactory fileChangeTrackerFactory)
: base(projectSnapshotManagerDispatcher, joinableTaskContext, fileChangeTrackerFactory)
{
}
protected override ITextBuffer? GetTextBufferForOpenDocument(string filePath)
{
if (filePath is null)
{
throw new ArgumentNullException(nameof(filePath));
}
var document = IdeApp.Workbench.GetDocument(filePath);
return document?.GetContent<ITextBuffer>();
}
protected override void OnDocumentOpened(EditorDocument document)
{
}
protected override void OnDocumentClosed(EditorDocument document)
{
}
public void HandleDocumentOpened(string filePath, ITextBuffer textBuffer)
{
JoinableTaskContext.AssertUIThread();
lock (Lock)
{
if (!TryGetMatchingDocuments(filePath, out var documents))
{
// This isn't a document that we're interesting in.
return;
}
BufferLoaded(textBuffer, filePath, documents);
}
}
public void HandleDocumentClosed(string filePath)
{
JoinableTaskContext.AssertUIThread();
lock (Lock)
{
if (!TryGetMatchingDocuments(filePath, out var documents))
{
return;
}
// We have to deal with some complications here due to renames and event ordering and such.
// We might see multiple documents open for a cookie (due to linked files), but only one of them
// has been renamed. In that case, we just process the change that we know about.
var matchingFilePaths = documents.Select(d => d.DocumentFilePath);
var filePaths = new HashSet<string>(matchingFilePaths, FilePathComparer.Instance);
foreach (var file in filePaths)
{
DocumentClosed(file);
}
}
}
public void HandleDocumentRenamed(string fromFilePath, string toFilePath, ITextBuffer textBuffer)
{
JoinableTaskContext.AssertUIThread();
if (string.Equals(fromFilePath, toFilePath, FilePathComparison.Instance))
{
return;
}
lock (Lock)
{
// Treat a rename as a close + reopen.
//
// Due to ordering issues, we could see a partial rename. This is why we need to pass the new
// file path here.
DocumentClosed(fromFilePath);
}
DocumentOpened(toFilePath, textBuffer);
}
public void BufferLoaded(ITextBuffer textBuffer, string filePath, EditorDocument[] documents)
{
JoinableTaskContext.AssertUIThread();
lock (Lock)
{
for (var i = 0; i < documents.Length; i++)
{
DocumentOpened(filePath, textBuffer);
}
}
}
}

Просмотреть файл

@ -1,46 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using System.Composition;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.VisualStudio.Editor.Razor.Documents;
using Microsoft.VisualStudio.Threading;
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor;
[Shared]
[ExportWorkspaceServiceFactory(typeof(EditorDocumentManager), ServiceLayer.Host)]
internal class VisualStudioMacEditorDocumentManagerFactory : IWorkspaceServiceFactory
{
private readonly ProjectSnapshotManagerDispatcher _projectSnapshotManagerDispatcher;
private readonly JoinableTaskContext _joinableTaskContext;
[ImportingConstructor]
public VisualStudioMacEditorDocumentManagerFactory(
ProjectSnapshotManagerDispatcher projectSnapshotManagerDispatcher,
JoinableTaskContext joinableTaskContext)
{
if (projectSnapshotManagerDispatcher is null)
{
throw new ArgumentNullException(nameof(projectSnapshotManagerDispatcher));
}
_projectSnapshotManagerDispatcher = projectSnapshotManagerDispatcher;
_joinableTaskContext = joinableTaskContext;
}
public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices)
{
if (workspaceServices is null)
{
throw new ArgumentNullException(nameof(workspaceServices));
}
var fileChangeTrackerFactory = workspaceServices.GetRequiredService<FileChangeTrackerFactory>();
var editorDocumentManager = new VisualStudioMacEditorDocumentManager(_projectSnapshotManagerDispatcher, _joinableTaskContext, fileChangeTrackerFactory);
return editorDocumentManager;
}
}

Просмотреть файл

@ -1,128 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using System.Threading;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.VisualStudio.Editor.Razor.Documents;
using MonoDevelop.Core;
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor;
internal class VisualStudioMacFileChangeTracker : FileChangeTracker
{
private readonly ProjectSnapshotManagerDispatcher _projectSnapshotManagerDispatcher;
private readonly string _normalizedFilePath;
private bool _listening;
public override event EventHandler<FileChangeEventArgs>? Changed;
public VisualStudioMacFileChangeTracker(
string filePath,
ProjectSnapshotManagerDispatcher projectSnapshotManagerDispatcher)
{
if (string.IsNullOrEmpty(filePath))
{
throw new ArgumentException(SR.ArgumentCannotBeNullOrEmpty, nameof(filePath));
}
if (projectSnapshotManagerDispatcher is null)
{
throw new ArgumentNullException(nameof(projectSnapshotManagerDispatcher));
}
FilePath = filePath;
_normalizedFilePath = NormalizePath(FilePath);
_projectSnapshotManagerDispatcher = projectSnapshotManagerDispatcher;
}
public override string FilePath { get; }
public override void StartListening()
{
_projectSnapshotManagerDispatcher.AssertDispatcherThread();
if (_listening)
{
return;
}
AttachToFileServiceEvents();
_listening = true;
}
public override void StopListening()
{
_projectSnapshotManagerDispatcher.AssertDispatcherThread();
if (!_listening)
{
return;
}
DetachFromFileServiceEvents();
_listening = false;
}
// Virtual for testing
protected virtual void AttachToFileServiceEvents()
{
FileService.FileChanged += FileService_FileChanged;
FileService.FileCreated += FileService_FileCreated;
FileService.FileRemoved += FileService_FileRemoved;
}
// Virtual for testing
protected virtual void DetachFromFileServiceEvents()
{
FileService.FileChanged -= FileService_FileChanged;
FileService.FileCreated -= FileService_FileCreated;
FileService.FileRemoved -= FileService_FileRemoved;
}
private void FileService_FileChanged(object sender, FileEventArgs args) => HandleFileChangeEvent(FileChangeKind.Changed, args);
private void FileService_FileCreated(object sender, FileEventArgs args) => HandleFileChangeEvent(FileChangeKind.Added, args);
private void FileService_FileRemoved(object sender, FileEventArgs args) => HandleFileChangeEvent(FileChangeKind.Removed, args);
private void HandleFileChangeEvent(FileChangeKind changeKind, FileEventArgs args)
{
if (Changed is null)
{
return;
}
foreach (var fileEvent in args)
{
if (fileEvent.IsDirectory)
{
continue;
}
var normalizedEventPath = NormalizePath(fileEvent.FileName.FullPath);
if (string.Equals(_normalizedFilePath, normalizedEventPath, StringComparison.OrdinalIgnoreCase))
{
_ = _projectSnapshotManagerDispatcher.RunOnDispatcherThreadAsync((changeKind, ct) => OnChanged(changeKind), changeKind, CancellationToken.None);
return;
}
}
}
private void OnChanged(FileChangeKind changeKind)
{
_projectSnapshotManagerDispatcher.AssertDispatcherThread();
var args = new FileChangeEventArgs(FilePath, changeKind);
Changed?.Invoke(this, args);
}
private static string NormalizePath(string path)
{
path = path.Replace('\\', '/');
return path;
}
}

Просмотреть файл

@ -1,33 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.VisualStudio.Editor.Razor.Documents;
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor;
internal class VisualStudioMacFileChangeTrackerFactory : FileChangeTrackerFactory
{
private readonly ProjectSnapshotManagerDispatcher _projectSnapshotManagerDispatcher;
public VisualStudioMacFileChangeTrackerFactory(ProjectSnapshotManagerDispatcher projectSnapshotManagerDispatcher)
{
if (projectSnapshotManagerDispatcher is null)
{
throw new ArgumentNullException(nameof(projectSnapshotManagerDispatcher));
}
_projectSnapshotManagerDispatcher = projectSnapshotManagerDispatcher;
}
public override FileChangeTracker Create(string filePath)
{
if (string.IsNullOrEmpty(filePath))
{
throw new ArgumentException(SR.ArgumentCannotBeNullOrEmpty, nameof(filePath));
}
return new VisualStudioMacFileChangeTracker(filePath, _projectSnapshotManagerDispatcher);
}
}

Просмотреть файл

@ -1,39 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using System.Composition;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.VisualStudio.Editor.Razor.Documents;
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor;
[Shared]
[ExportWorkspaceServiceFactory(typeof(FileChangeTrackerFactory), ServiceLayer.Host)]
internal class VisualStudioMacFileChangeTrackerFactoryFactory : IWorkspaceServiceFactory
{
private readonly ProjectSnapshotManagerDispatcher _projectSnapshotManagerDispatcher;
[ImportingConstructor]
public VisualStudioMacFileChangeTrackerFactoryFactory(ProjectSnapshotManagerDispatcher projectSnapshotManagerDispatcher)
{
if (projectSnapshotManagerDispatcher is null)
{
throw new ArgumentNullException(nameof(projectSnapshotManagerDispatcher));
}
_projectSnapshotManagerDispatcher = projectSnapshotManagerDispatcher;
}
public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices)
{
if (workspaceServices is null)
{
throw new ArgumentNullException(nameof(workspaceServices));
}
return new VisualStudioMacFileChangeTrackerFactory(_projectSnapshotManagerDispatcher);
}
}

Просмотреть файл

@ -1,114 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using System.Composition;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.VisualStudio.Editor.Razor;
using MonoDevelop.Core.FeatureConfiguration;
using MonoDevelop.Projects;
namespace Microsoft.VisualStudio.LanguageServices.Razor;
[Shared]
[Export(typeof(LSPEditorFeatureDetector))]
internal class VisualStudioMacLSPEditorFeatureDetector : LSPEditorFeatureDetector
{
private const string RazorLSPEditorFeatureFlag = "Razor.LSP.Editor";
private const string DotNetCoreCSharpProjectCapability = "DotNetCoreRazor | AspNetCore";
private const string LegacyRazorEditorProjectCapability = "LegacyRazorEditor";
private readonly AggregateProjectCapabilityResolver _projectCapabilityResolver;
private readonly TextBufferProjectService _textBufferProjectService;
private readonly Lazy<bool> _useLegacyEditor;
[ImportingConstructor]
public VisualStudioMacLSPEditorFeatureDetector(
AggregateProjectCapabilityResolver projectCapabilityResolver,
TextBufferProjectService textBufferProjectService)
{
_projectCapabilityResolver = projectCapabilityResolver;
_textBufferProjectService = textBufferProjectService;
_useLegacyEditor = new Lazy<bool>(() =>
{
// TODO: Pull from preview features collection
if (FeatureSwitchService.IsFeatureEnabled(RazorLSPEditorFeatureFlag) == true)
{
return false;
}
return true;
});
}
[Obsolete("Test constructor")]
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
internal VisualStudioMacLSPEditorFeatureDetector()
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
{
}
public override bool IsLSPEditorAvailable(string? documentFilePath, object? hierarchy)
{
if (documentFilePath is null)
{
return false;
}
if (!IsLSPEditorAvailable())
{
return false;
}
var dotnetProject = hierarchy as DotNetProject;
if (!ProjectSupportsLSPEditor(documentFilePath, dotnetProject))
{
// Current project hierarchy doesn't support the LSP Razor editor
return false;
}
return true;
}
public override bool IsLSPEditorAvailable() => !_useLegacyEditor.Value;
// LiveShare / CodeSpaces is not supported in VS4Mac
public override bool IsRemoteClient() => false;
// LiveShare / CodeSpaces is not supported in VS4Mac
public override bool IsLiveShareHost() => false;
// Private protected virtual for testing
private protected virtual bool ProjectSupportsLSPEditor(string documentFilePath, DotNetProject? project)
{
if (project is null)
{
project = _textBufferProjectService.GetHostProject(documentFilePath) as DotNetProject;
if (project is null)
{
return false;
}
}
// We alow projects to specifically opt-out of the legacy Razor editor because there are legacy scenarios which would rely on behind-the-scenes
// opt-out mechanics to enable the .NET Core editor in non-.NET Core scenarios. Therefore, we need a similar mechanic to continue supporting
// those types of scenarios for the new .NET Core Razor editor.
if (_projectCapabilityResolver.HasCapability(documentFilePath, project, LegacyRazorEditorProjectCapability))
{
// CPS project that requires the legacy editor
return false;
}
if (_projectCapabilityResolver.HasCapability(documentFilePath, project, DotNetCoreCSharpProjectCapability))
{
// .NET Core project that supports C#
return true;
}
// Not a C# .NET Core project. This typically happens for legacy Razor scenarios
return false;
}
}

Просмотреть файл

@ -1,54 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using System.ComponentModel.Composition;
using Microsoft.CodeAnalysis.Razor.Workspaces;
namespace Microsoft.VisualStudio.Editor.Razor;
[Export(typeof(LanguageServerFeatureOptions))]
internal class VisualStudioMacLanguageServerFeatureOptions : LanguageServerFeatureOptions
{
private readonly LSPEditorFeatureDetector _lspEditorFeatureDetector;
[ImportingConstructor]
public VisualStudioMacLanguageServerFeatureOptions(LSPEditorFeatureDetector lspEditorFeatureDetector)
{
if (lspEditorFeatureDetector is null)
{
throw new ArgumentNullException(nameof(lspEditorFeatureDetector));
}
_lspEditorFeatureDetector = lspEditorFeatureDetector;
}
// We don't currently support file creation operations on VS Codespaces or VS Liveshare
public override bool SupportsFileManipulation => !IsCodespacesOrLiveshare;
// In VS we override the project configuration file name because we don't want our serialized state to clash with other platforms (VSCode)
public override string ProjectConfigurationFileName => "project.razor.vs.bin";
public override string CSharpVirtualDocumentSuffix => ".ide.g.cs";
public override string HtmlVirtualDocumentSuffix => "__virtual.html";
public override bool SingleServerCompletionSupport => true;
public override bool SingleServerSupport => true;
public override bool DelegateToCSharpOnDiagnosticPublish => false;
public override bool ShowAllCSharpCodeActions => false;
public override bool UsePreciseSemanticTokenRanges => true;
public override bool ReturnCodeActionAndRenamePathsWithPrefixedSlash => false;
public override bool UpdateBuffersForClosedDocuments => false;
public override bool IncludeProjectKeyInGeneratedFilePath => false;
private bool IsCodespacesOrLiveshare => _lspEditorFeatureDetector.IsRemoteClient() || _lspEditorFeatureDetector.IsLiveShareHost();
}

Просмотреть файл

@ -1,30 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.ComponentModel.Composition;
using Microsoft.CodeAnalysis.Razor;
using MonoDevelop.Core;
using MonoDevelop.Core.Logging;
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor;
[Export(typeof(RazorLogger))]
internal class VisualStudioMacLogger : RazorLogger
{
public override void LogError(string message)
{
LoggingService.LogError(
SR.RazorLanguageServiceGeneralError,
message);
}
public override void LogVerbose(string message)
{
LoggingService.Log(LogLevel.Debug, message);
}
public override void LogWarning(string message)
{
LoggingService.LogWarning(message);
}
}

Просмотреть файл

@ -1,51 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using System.ComponentModel.Composition;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.VisualStudio.Editor.Razor;
using MonoDevelop.Projects;
namespace Microsoft.VisualStudio.LanguageServices.Razor;
[Export(typeof(ProjectCapabilityResolver))]
internal class VisualStudioMacProjectCapabilityResolver : ProjectCapabilityResolver
{
private readonly RazorLogger _razorLogger;
[ImportingConstructor]
public VisualStudioMacProjectCapabilityResolver(RazorLogger razorLogger)
{
_razorLogger = razorLogger;
}
public override bool HasCapability(object project, string capability)
{
if (project is not DotNetProject dotnetProject)
{
return false;
}
try
{
var hasCapability = dotnetProject.IsCapabilityMatch(capability);
return hasCapability;
}
catch (NotSupportedException)
{
// IsCapabilityMatch throws a NotSupportedException if it can't create a
// BooleanSymbolExpressionEvaluator COM object
_razorLogger.LogWarning("Could not resolve project capability for hierarchy due to NotSupportedException.");
return false;
}
catch (ObjectDisposedException)
{
// IsCapabilityMatch throws an ObjectDisposedException if the underlying hierarchy has been disposed
_razorLogger.LogWarning("Could not resolve project capability for hierarchy due to hierarchy being disposed.");
return false;
}
}
public override bool HasCapability(string documentFilePath, object project, string capability) => HasCapability(project, capability);
}

Просмотреть файл

@ -1,35 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.ComponentModel.Composition;
using System.Diagnostics.CodeAnalysis;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using MonoDevelop.Ide;
namespace Microsoft.VisualStudio.LanguageServices.Razor;
[System.Composition.Shared]
[Export(typeof(ProjectSnapshotManagerAccessor))]
[method: ImportingConstructor]
internal class VisualStudioMacProjectSnapshotManagerAccessor() : ProjectSnapshotManagerAccessor
{
private ProjectSnapshotManagerBase? _projectManager;
public override ProjectSnapshotManagerBase Instance
{
get
{
EnsureInitialized();
return _projectManager;
}
}
[MemberNotNull(nameof(_projectManager))]
private void EnsureInitialized()
{
_projectManager ??= (ProjectSnapshotManagerBase)IdeServices.TypeSystemService.Workspace.Services.GetLanguageServices(RazorLanguage.Name).GetRequiredService<ProjectSnapshotManager>();
}
}

Просмотреть файл

@ -1,14 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.Editor.Razor;
using MonoDevelop.Projects;
using Workspace = Microsoft.CodeAnalysis.Workspace;
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor;
internal abstract class VisualStudioMacWorkspaceAccessor : VisualStudioWorkspaceAccessor
{
public abstract bool TryGetWorkspace(Solution solution, [NotNullWhen(returnValue: true)] out Workspace? workspace);
}

Просмотреть файл

@ -1,24 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using System.ComponentModel.Composition;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.CodeAnalysis.Razor.Workspaces;
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor;
[Export(typeof(ProjectSnapshotManagerDispatcher))]
internal class VisualStudioProjectSnapshotManagerDispatcher : ProjectSnapshotManagerDispatcherBase
{
private const string ThreadName = "Razor." + nameof(VisualStudioProjectSnapshotManagerDispatcher);
private readonly IErrorReporter _errorReporter;
[ImportingConstructor]
public VisualStudioProjectSnapshotManagerDispatcher(IErrorReporter errorReporter) : base(ThreadName)
{
_errorReporter = errorReporter;
}
public override void LogException(Exception ex) => _errorReporter.ReportError(ex);
}

Просмотреть файл

@ -1,9 +0,0 @@
<Project>
<PropertyGroup>
<AddinId>RazorAddin</AddinId>
<AddinNamespace>Microsoft.VisualStudio.Mac</AddinNamespace>
<AddinDetailedName>Razor Language Services</AddinDetailedName>
<AddinCategory>Web Development</AddinCategory>
<Description>Language services for ASP.NET Core Razor</Description>
</PropertyGroup>
</Project>

Просмотреть файл

@ -1,140 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="AddinMetadata.props" />
<PropertyGroup>
<TargetFramework>$(DefaultNetFxTargetFramework)</TargetFramework>
<IsMPackProject>true</IsMPackProject>
<AddinName>Microsoft.VisualStudio.Mac.RazorAddin</AddinName>
<ExcludeFromSourceBuild>true</ExcludeFromSourceBuild>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<AssemblyAttribute Include="Mono.Addins.AddinAttribute">
<_Parameter1>$(AddinId)</_Parameter1>
<Namespace>$(AddinNamespace)</Namespace>
<Version>$(AddinMajorVersion)</Version>
</AssemblyAttribute>
<AssemblyAttribute Include="Mono.Addins.AddinNameAttribute">
<_Parameter1>$(AddinDetailedName)</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="Mono.Addins.AddinCategoryAttribute">
<_Parameter1>$(AddinCategory)</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="Mono.Addins.AddinDescriptionAttribute">
<_Parameter1>$(Description)</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="Mono.Addins.AddinAuthorAttribute">
<_Parameter1>$(Authors)</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="Mono.Addins.AddinDependencyAttribute">
<_Parameter1>::MonoDevelop.Core</_Parameter1>
<_Parameter2>17.5</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="Mono.Addins.AddinDependencyAttribute">
<_Parameter1>::MonoDevelop.Ide</_Parameter1>
<_Parameter2>17.5</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="Mono.Addins.AddinDependencyAttribute">
<_Parameter1>::MonoDevelop.TextEditor</_Parameter1>
<_Parameter2>17.5</_Parameter2>
</AssemblyAttribute>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\_Manifest.addin.xml" LogicalName="_Manifest.addin.xml" />
</ItemGroup>
<ItemGroup>
<Content Include="$(RepositoryRoot)NOTICE.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Mono.Addins" Version="$(MonoAddinsPackageVersion)" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Compiler\Microsoft.AspNetCore.Razor.Language\src\Microsoft.AspNetCore.Razor.Language.csproj" />
<ProjectReference Include="..\..\..\Compiler\Microsoft.CodeAnalysis.Razor\src\Microsoft.CodeAnalysis.Razor.csproj" />
</ItemGroup>
<ItemGroup>
<!-- Shared Dependencies -->
<MPackFile Include="$(ArtifactsBinDir)Microsoft.AspNetCore.Razor.Utilities.Shared\$(Configuration)\netstandard2.0\Microsoft.AspNetCore.Razor.Utilities.Shared.dll" />
<!-- Compiler Dependencies -->
<MPackFile Include="$(ArtifactsBinDir)Microsoft.AspNetCore.Mvc.Razor.Extensions\$(Configuration)\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.Extensions.dll" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X\$(Configuration)\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.dll" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X\$(Configuration)\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.dll" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.AspNetCore.Razor.Language\$(Configuration)\netstandard2.0\Microsoft.AspNetCore.Razor.Language.dll" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.Razor\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.Razor.dll" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.Razor.Workspaces\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.Razor.Workspaces.dll" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.VisualStudio.Editor.Razor\$(Configuration)\net472\Microsoft.VisualStudio.Editor.Razor.dll" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.VisualStudio.Mac.LanguageServices.Razor\$(Configuration)\net472\Microsoft.VisualStudio.Mac.LanguageServices.Razor.dll" />
<!-- Language Server Dependencies -->
<MPackFile Include="$(ArtifactsBinDir)Microsoft.VisualStudio.LanguageServerClient.Razor\$(Configuration)\net472\Microsoft.VisualStudio.LanguageServerClient.Razor.dll" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.VisualStudio.LanguageServer.ContainedLanguage\$(Configuration)\net472\Microsoft.VisualStudio.LanguageServer.ContainedLanguage.dll" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.AspNetCore.Razor.LanguageServer.Protocol\$(Configuration)\net472\Microsoft.AspNetCore.Razor.LanguageServer.Protocol.dll" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.AspNetCore.Razor.LanguageServer\$(Configuration)\net472\Microsoft.AspNetCore.Razor.LanguageServer.dll" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.AspNetCore.Razor.ProjectEngineHost\$(Configuration)\net472\Microsoft.AspNetCore.Razor.ProjectEngineHost.dll" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.VisualStudio.Mac.RazorAddin\$(Configuration)\net472\Microsoft.Extensions.Options.dll" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.VisualStudio.Mac.RazorAddin\$(Configuration)\net472\Microsoft.Extensions.Primitives.dll" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.VisualStudio.Mac.RazorAddin\$(Configuration)\net472\Microsoft.Extensions.DependencyInjection.dll" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.VisualStudio.Mac.RazorAddin\$(Configuration)\net472\Microsoft.Extensions.DependencyInjection.Abstractions.dll" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.VisualStudio.Mac.RazorAddin\$(Configuration)\net472\Microsoft.Extensions.Configuration.dll" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.VisualStudio.Mac.RazorAddin\$(Configuration)\net472\Microsoft.Extensions.Configuration.Abstractions.dll" />
<!-- Third Party Notices -->
<MPackFile Include="$(ArtifactsBinDir)Microsoft.VisualStudio.Mac.RazorAddin\$(Configuration)\net472\NOTICE.txt" />
<!-- Embedded Grammars -->
<MPackFile Include="..\Microsoft.VisualStudio.RazorExtension\EmbeddedGrammars\*">
<Folder>Grammars</Folder>
</MPackFile>
<!-- Embedded Language Configuration Files -->
<MPackFile Include="$(RepositoryRoot)src\Razor\src\Microsoft.VisualStudio.RazorExtension\language-configuration.json" />
<MPackFile Include="$(RepositoryRoot)src\Razor\src\Microsoft.VisualStudio.RazorExtension\javascript-language-configuration.json" />
<MPackFile Include="$(RepositoryRoot)src\Razor\src\Microsoft.VisualStudio.RazorExtension\css-language-configuration.json" />
<MPackFile Include="$(RepositoryRoot)src\Razor\src\Microsoft.VisualStudio.RazorExtension\csharp-language-configuration.json" />
<MPackFile Include="$(RepositoryRoot)src\Razor\src\Microsoft.VisualStudio.RazorExtension\razordirective-language-configuration.json" />
</ItemGroup>
<ItemGroup Condition="$(DebugType) != 'embedded'">
<MPackFile Include="$(ArtifactsBinDir)Microsoft.AspNetCore.Mvc.Razor.Extensions\$(Configuration)\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.Extensions.pdb" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X\$(Configuration)\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.pdb" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X\$(Configuration)\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.pdb" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.AspNetCore.Razor.Language\$(Configuration)\netstandard2.0\Microsoft.AspNetCore.Razor.Language.pdb" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.Razor\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.Razor.pdb" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.CodeAnalysis.Razor.Workspaces\$(Configuration)\netstandard2.0\Microsoft.CodeAnalysis.Razor.Workspaces.pdb" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.VisualStudio.Editor.Razor\$(Configuration)\net472\Microsoft.VisualStudio.Editor.Razor.pdb" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.VisualStudio.Mac.LanguageServices.Razor\$(Configuration)\net472\Microsoft.VisualStudio.Mac.LanguageServices.Razor.pdb" />
<!-- Language Server Dependencies-->
<MPackFile Include="$(ArtifactsBinDir)Microsoft.VisualStudio.LanguageServerClient.Razor\$(Configuration)\net472\Microsoft.VisualStudio.LanguageServerClient.Razor.pdb" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.VisualStudio.LanguageServer.ContainedLanguage\$(Configuration)\net472\Microsoft.VisualStudio.LanguageServer.ContainedLanguage.pdb" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.AspNetCore.Razor.LanguageServer.Protocol\$(Configuration)\net472\Microsoft.AspNetCore.Razor.LanguageServer.Protocol.pdb" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.AspNetCore.Razor.LanguageServer\$(Configuration)\net472\Microsoft.AspNetCore.Razor.LanguageServer.pdb" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.VisualStudio.Mac.LanguageServices.Razor\Microsoft.VisualStudio.Mac.LanguageServices.Razor.csproj" />
<ProjectReference Include="..\Microsoft.VisualStudio.LanguageServerClient.Razor\Microsoft.VisualStudio.LanguageServerClient.Razor.csproj" />
</ItemGroup>
<Target Name="_BuildRazorGrammar">
<MSBuild Projects="..\Microsoft.AspNetCore.Razor.VSCode.Extension\Microsoft.AspNetCore.Razor.VSCode.Extension.npmproj" Targets="Build" />
</Target>
<Target Name="_IncludeRazorGrammar" DependsOnTargets="PrepareForBuild;_BuildRazorGrammar" BeforeTargets="CoreCompile">
<ItemGroup>
<MPackFile Include="..\Microsoft.AspNetCore.Razor.VSCode.Extension\syntaxes\aspnetcorerazor.tmLanguage.json">
<Folder>Grammars</Folder>
</MPackFile>
</ItemGroup>
</Target>
</Project>

Просмотреть файл

@ -1,73 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ExtensionModel>
<Runtime>
<Import assembly="Microsoft.VisualStudio.Editor.Razor.dll" />
<Import assembly="Microsoft.CodeAnalysis.Razor.Workspaces.dll" />
<Import assembly="Microsoft.AspNetCore.Razor.Language.dll" />
<Import assembly="Microsoft.AspNetCore.Razor.Utilities.Shared.dll" />
<Import assembly="Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.dll" />
<Import assembly="Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.dll" />
<Import assembly="Microsoft.AspNetCore.Mvc.Razor.Extensions.dll" />
<Import assembly="Microsoft.CodeAnalysis.Razor.dll" />
<Import assembly="Microsoft.VisualStudio.Mac.LanguageServices.Razor.dll" />
<Import assembly="Microsoft.VisualStudio.LanguageServerClient.Razor.dll" />
<Import assembly="Microsoft.VisualStudio.LanguageServer.ContainedLanguage.dll" />
<Import assembly="Microsoft.AspNetCore.Razor.LanguageServer.dll" />
<Import assembly="Microsoft.AspNetCore.Razor.LanguageServer.Protocol.dll" />
<Import assembly="Microsoft.AspNetCore.Razor.ProjectEngineHost.dll" />
<Import assembly="Microsoft.Extensions.Options.dll" />
<Import assembly="Microsoft.Extensions.Primitives.dll" />
<Import assembly="Microsoft.Extensions.DependencyInjection.dll" />
<Import assembly="Microsoft.Extensions.DependencyInjection.Abstractions.dll" />
<Import assembly="Microsoft.Extensions.Configuration.dll" />
<Import assembly="Microsoft.Extensions.Configuration.Abstractions.dll" />
<!--
Purposefully not including these actual dependencies because VS4Mac ships them for us on our behalf. This differs from VisualStudio windows.
<Import assembly="Microsoft.Extensions.ObjectPool.dll" />
<Import assembly="Microsoft.Extensions.Logging.dll" />
<Import assembly="Microsoft.Extensions.Logging.Abstractions.dll" />
<Import assembly="System.IO.Pipelines.dll" />
<Import assembly="System.Runtime.CompilerServices.Unsafe.dll" />
<Import assembly="System.Threading.Channels.dll" />
-->
</Runtime>
<Dependencies>
<Addin id="::MonoDevelop.Core" version="17.5" />
<Addin id="::MonoDevelop.Ide" version="17.5" />
</Dependencies>
<!-- MEF catalog -->
<Extension path="/MonoDevelop/Ide/Composition">
<Assembly file="Microsoft.VisualStudio.Editor.Razor.dll" />
<Assembly file="Microsoft.CodeAnalysis.Razor.Workspaces.dll" />
<Assembly file="Microsoft.VisualStudio.LanguageServerClient.Razor.dll" />
<Assembly file="Microsoft.VisualStudio.LanguageServer.ContainedLanguage.dll" />
<Assembly file="Microsoft.VisualStudio.Mac.LanguageServices.Razor.dll" />
</Extension>
<!-- Project Extensions -->
<Extension path = "/MonoDevelop/ProjectModel/ProjectModelExtensions">
<Class class="Microsoft.VisualStudio.Mac.RazorAddin.RazorProjectExtension" insertafter="FinalStep" />
</Extension>
<!-- Feature Switches -->
<Extension path="/MonoDevelop/Core/FeatureSwitches">
<FeatureSwitch id="Razor.LSP.Editor" _description="Enables the Razor LSP editor for ASP.NET Core scenarios" defaultValue="false" />
</Extension>
<!-- TextMate -->
<Extension path="/MonoDevelop/Ide/Editor/TextMate">
<Repository folderPath="Grammars"/>
</Extension>
<Extension path="/MonoDevelop/Ide/Editor/LanguageConfiguration">
<LanguageConfiguration contentTypeName="Razor" scopeName="text.aspnetcorerazor" languageConfigurationFilePath="language-configuration.json" />
<LanguageConfiguration scopeName="source.js" languageConfigurationFilePath="javascript-language-configuration.json" />
<LanguageConfiguration scopeName="source.css" languageConfigurationFilePath="css-language-configuration.json" />
<LanguageConfiguration scopeName="source.cs" languageConfigurationFilePath="csharp-language-configuration.json" />
<LanguageConfiguration scopeName="meta.directive" languageConfigurationFilePath="razordirective-language-configuration.json" />
</Extension>
</ExtensionModel>

Просмотреть файл

@ -1,17 +0,0 @@
# Debugging VS4Mac
1. [Install latest VS4Mac](https://visualstudio.microsoft.com/vs/mac/). Can upgrade installed version to the [preview channel](https://docs.microsoft.com/en-us/visualstudio/mac/install-preview?view=vsmac-2019) if needed.
2. Open the Razor.sln
3. Under `Visual Studio -> Preferences -> SDK Locations -> .NET Core` update the Location to point to your local aspnetcore-tooling dotnet:
![image](https://user-images.githubusercontent.com/2008729/89470183-ff9aef00-d72f-11ea-9465-e57c46512e50.png)
4. Double-click on the `Microsoft.VisualStudio.Mac.RazorAddin` project and update the `Run Configuration: Default` section (`Start External Program` & `Environment Variables`):
![image](https://user-images.githubusercontent.com/2008729/89469594-98306f80-d72e-11ea-8ae3-4e652f9e75c6.png)
5. Right click the `Microsoft.VisualStudio.Mac.RazorAddin` project and `Set As Startup Project`.
6. Open the `~/Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/bin/VisualStudio.exe.config` and update the binding redirects of the following to 42.42.42.42. This ensures WebTools can load our locally built assemblies so we need to update binding redirects.
- Microsoft.VisualStudio.Editor.Razor
- Microsoft.CodeAnalysis.Razor.Workspaces
Example:
![image](https://user-images.githubusercontent.com/2008729/89469968-7be10280-d72f-11ea-98af-d731c20167dd.png)
7. Go back to your Razor.sln and click run. You should now be able to hit breakpoints with your locally built code.
![image](https://user-images.githubusercontent.com/2008729/89470234-2bb67000-d730-11ea-924c-2ec9588b0af6.png)

Просмотреть файл

@ -1,67 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.VisualStudio.Mac.LanguageServices.Razor.ProjectSystem;
using MonoDevelop.Ide;
using MonoDevelop.Ide.Composition;
using MonoDevelop.Projects;
namespace Microsoft.VisualStudio.Mac.RazorAddin;
internal class RazorProjectExtension : ProjectExtension
{
private readonly object _lock = new();
private readonly ProjectSnapshotManagerDispatcher _projectSnapshotManagerDispatcher;
private CancellationTokenSource? _cancellationTokenSource;
public RazorProjectExtension()
{
_projectSnapshotManagerDispatcher = CompositionManager.Instance.GetExportedValue<ProjectSnapshotManagerDispatcher>();
}
protected override void OnBoundToSolution()
{
if (Project is not DotNetProject dotNetProject)
{
return;
}
DotNetProjectHost projectHost;
lock (_lock)
{
if (Project.ExtendedProperties.Contains(typeof(DotNetProjectHost)))
{
// Already have a project host.
return;
}
var projectHostFactory = CompositionManager.Instance.GetExportedValue<DotNetProjectHostFactory>();
projectHost = projectHostFactory.Create(dotNetProject);
Project.ExtendedProperties[typeof(DotNetProjectHost)] = projectHost;
}
// Once a workspace is created for the solution we'll setup our project host for the current project. The Razor world
// shares a lifetime with the workspace (as Roslyn services) so we need to ensure it exists prior to wiring the host
// world to the Roslyn world.
_cancellationTokenSource = new CancellationTokenSource();
var token = _cancellationTokenSource.Token;
_ = IdeApp.TypeSystemService.GetWorkspaceAsync(Project.ParentSolution, token).ContinueWith(task => projectHost.Subscribe(),
token,
TaskContinuationOptions.OnlyOnRanToCompletion, // We only want to act if we could properly retrieve the workspace.
_projectSnapshotManagerDispatcher.DispatcherScheduler);
}
protected override void OnUnboundFromSolution()
{
if (_cancellationTokenSource != null)
{
_cancellationTokenSource.Cancel();
_cancellationTokenSource.Dispose();
_cancellationTokenSource = null;
}
}
}

Просмотреть файл

@ -1,42 +0,0 @@
<Addin id="RazorAddin" namespace="Microsoft.VisualStudio.Mac" version="17.5" name="Razor Language Services" author="Microsoft" description="Language services for ASP.NET Core Razor" category="Web Development">
<Runtime>
<Import assembly="Microsoft.VisualStudio.Editor.Razor.dll" />
<Import assembly="Microsoft.CodeAnalysis.Razor.Workspaces.dll" />
<Import assembly="Microsoft.AspNetCore.Razor.Language.dll" />
<Import assembly="Microsoft.AspNetCore.Razor.Utilities.Shared.dll" />
<Import assembly="Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.dll" />
<Import assembly="Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.dll" />
<Import assembly="Microsoft.AspNetCore.Mvc.Razor.Extensions.dll" />
<Import assembly="Microsoft.CodeAnalysis.Razor.dll" />
<Import assembly="Microsoft.VisualStudio.Mac.LanguageServices.Razor.dll" />
<Import assembly="Microsoft.VisualStudio.Mac.RazorAddin.dll" />
<Import assembly="Microsoft.VisualStudio.LanguageServerClient.Razor.dll" />
<Import assembly="Microsoft.VisualStudio.LanguageServer.ContainedLanguage.dll" />
<Import assembly="Microsoft.AspNetCore.Razor.LanguageServer.dll" />
<Import assembly="Microsoft.AspNetCore.Razor.LanguageServer.Protocol.dll" />
<Import assembly="Microsoft.AspNetCore.Razor.ProjectEngineHost.dll" />
<Import assembly="Microsoft.Extensions.Options.dll" />
<Import assembly="Microsoft.Extensions.Primitives.dll" />
<Import assembly="Microsoft.Extensions.DependencyInjection.dll" />
<Import assembly="Microsoft.Extensions.DependencyInjection.Abstractions.dll" />
<Import assembly="Microsoft.Extensions.Configuration.dll" />
<Import assembly="Microsoft.Extensions.Configuration.Abstractions.dll" />
<!--
Purposefully not including these actual dependencies because VS4Mac ships them for us on our behalf. This differs from VisualStudio windows.
<Import assembly="Microsoft.Extensions.ObjectPool.dll" />
<Import assembly="Microsoft.Extensions.Logging.dll" />
<Import assembly="Microsoft.Extensions.Logging.Abstractions.dll" />
<Import assembly="System.IO.Pipelines.dll" />
<Import assembly="System.Runtime.CompilerServices.Unsafe.dll" />
<Import assembly="System.Threading.Channels.dll" />
-->
</Runtime>
<Dependencies>
<Addin id="::MonoDevelop.Core" version="17.5" />
<Addin id="::MonoDevelop.Ide" version="17.5" />
<Addin id="::MonoDevelop.TextEditor" version="17.5" />
</Dependencies>
</Addin>

Просмотреть файл

@ -11,5 +11,4 @@ using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Remote.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LanguageServerClient.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LanguageServices.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Mac.LanguageServices.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]

Просмотреть файл

@ -9,5 +9,4 @@ using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Razor.Workspaces.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Editor.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LanguageServices.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Mac.LanguageServices.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]

Просмотреть файл

@ -1,43 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using Microsoft.VisualStudio.Editor.Razor;
using Moq;
using Xunit;
using Xunit.Abstractions;
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.ProjectSystem;
public class DefaultDotNetProjectHostTest : ProjectSnapshotManagerDispatcherTestBase
{
public DefaultDotNetProjectHostTest(ITestOutputHelper testOutput)
: base(testOutput)
{
}
[Fact]
public void UpdateRazorHostProject_UnsupportedProjectNoops()
{
// Arrange
var projectService = new Mock<TextBufferProjectService>(MockBehavior.Strict);
projectService.Setup(p => p.IsSupportedProject(It.IsAny<object>()))
.Returns(false);
var dotNetProjectHost = new DefaultDotNetProjectHost(
Dispatcher,
Mock.Of<VisualStudioMacWorkspaceAccessor>(MockBehavior.Strict),
projectService.Object,
TestProjectConfigurationFilePathStore.Instance,
TestVSLanguageServerFeatureOptions.Instance);
// Act & Assert
dotNetProjectHost.UpdateRazorHostProject();
}
// -------------------------------------------------------------------------------------------
// Purposefully do not have any more tests here because that would involve mocking MonoDevelop
// types. The default constructors for the Solution / DotNetProject MonoDevelop types change
// static classes (they assume they're being created in an IDE).
// -------------------------------------------------------------------------------------------
}

Просмотреть файл

@ -1,43 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using Microsoft.AspNetCore.Razor.Test.Common;
using Microsoft.VisualStudio.Editor.Razor;
using Microsoft.VisualStudio.Text;
using Moq;
using Xunit;
using Xunit.Abstractions;
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor;
public class DefaultVisualStudioMacWorkspaceAccessorTest : TestBase
{
public DefaultVisualStudioMacWorkspaceAccessorTest(ITestOutputHelper testOutput)
: base(testOutput)
{
}
[Fact]
public void TryGetWorkspace_NoHostProject_ReturnsFalse()
{
// Arrange
var textBufferProjectService = new Mock<TextBufferProjectService>(MockBehavior.Strict);
textBufferProjectService.Setup(s => s.GetHostProject(It.IsAny<ITextBuffer>())).Returns(value: null);
var workspaceAccessor = new DefaultVisualStudioMacWorkspaceAccessor(textBufferProjectService.Object);
var textBuffer = Mock.Of<ITextBuffer>(MockBehavior.Strict);
// Act
var result = workspaceAccessor.TryGetWorkspace(textBuffer, out var workspace);
// Assert
Assert.False(result);
}
// -------------------------------------------------------------------------------------------
// Purposefully do not have any more tests here because that would involve mocking MonoDevelop
// types. The default constructors for the Solution / DotNetProject MonoDevelop types change
// static classes (they assume they're being created in an IDE).
// -------------------------------------------------------------------------------------------
}

Просмотреть файл

@ -1,93 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using Microsoft.CodeAnalysis.Razor;
using Xunit;
using Xunit.Abstractions;
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor;
public class VisualStudioMacFileChangeTrackerTest : ProjectSnapshotManagerDispatcherTestBase
{
public VisualStudioMacFileChangeTrackerTest(ITestOutputHelper testOutput)
: base(testOutput)
{
}
[UIFact]
public void StartListening_AdvisesForFileChange()
{
// Arrange
var tracker = new TestFileChangeTracker("C:/_ViewImports.cshtml", Dispatcher);
// Act
tracker.StartListening();
// Assert
Assert.Equal(1, tracker.AttachToFileServiceEventsCount);
}
[UIFact]
public void StartListening_AlreadyListening_DoesNothing()
{
// Arrange
var tracker = new TestFileChangeTracker("C:/_ViewImports.cshtml", Dispatcher);
tracker.StartListening();
// Act
tracker.StartListening();
// Assert
Assert.Equal(1, tracker.AttachToFileServiceEventsCount);
}
[UIFact]
public void StopListening_UnadvisesForFileChange()
{
// Arrange
var tracker = new TestFileChangeTracker("C:/_ViewImports.cshtml", Dispatcher);
tracker.StartListening(); // Start listening for changes.
// Act
tracker.StopListening();
// Assert
Assert.Equal(1, tracker.AttachToFileServiceEventsCount);
Assert.Equal(1, tracker.DetachFromFileServiceEventsCount);
}
[UIFact]
public void StopListening_NotListening_DoesNothing()
{
// Arrange
var tracker = new TestFileChangeTracker("C:/_ViewImports.cshtml", Dispatcher);
// Act
tracker.StopListening();
// Assert
Assert.Equal(0, tracker.AttachToFileServiceEventsCount);
Assert.Equal(0, tracker.DetachFromFileServiceEventsCount);
}
private class TestFileChangeTracker : VisualStudioMacFileChangeTracker
{
public TestFileChangeTracker(
string filePath,
ProjectSnapshotManagerDispatcher projectSnapshotManagerDispatcher)
: base(filePath, projectSnapshotManagerDispatcher)
{
}
public int AttachToFileServiceEventsCount { get; private set; }
public int DetachFromFileServiceEventsCount { get; private set; }
protected override void AttachToFileServiceEvents() => AttachToFileServiceEventsCount++;
protected override void DetachFromFileServiceEvents() => DetachFromFileServiceEventsCount++;
}
}

Просмотреть файл

@ -1,29 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>$(DefaultNetFxTargetFramework)</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\Microsoft.CodeAnalysis.Razor.Workspaces.Test\Shared\**\*.cs">
<Link>Shared\%(RecursiveDir)%(FileName)%(Extension)</Link>
</Compile>
<Compile Include="..\Microsoft.VisualStudio.Editor.Razor.Test\Shared\**\*.cs">
<Link>Shared\%(RecursiveDir)%(FileName)%(Extension)</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.VisualStudio.Mac.LanguageServices.Razor\Microsoft.VisualStudio.Mac.LanguageServices.Razor.csproj" />
<ProjectReference Include="..\Microsoft.VisualStudio.Editor.Razor.Test.Common\Microsoft.VisualStudio.Editor.Razor.Test.Common.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Moq" Version="$(MoqPackageVersion)" />
</ItemGroup>
</Project>

Просмотреть файл

@ -1,183 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using System.Collections.Immutable;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.VisualStudio.Editor.Razor;
using Microsoft.VisualStudio.Editor.Razor.Test;
using MonoDevelop.Projects;
using Moq;
using Xunit;
using Xunit.Abstractions;
using Project = Microsoft.CodeAnalysis.Project;
using Workspace = Microsoft.CodeAnalysis.Workspace;
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor;
public class ProjectBuildChangeTriggerTest : ProjectSnapshotManagerDispatcherTestBase
{
private readonly HostProject _someProject;
private readonly HostProject _someOtherProject;
private Project _someWorkspaceProject;
private readonly Workspace _workspace;
public ProjectBuildChangeTriggerTest(ITestOutputHelper testOutput)
: base(testOutput)
{
_someProject = new HostProject("c:\\SomeProject\\SomeProject.csproj", "c:\\SomeProject\\obj", FallbackRazorConfiguration.MVC_1_0, "SomeProject");
_someOtherProject = new HostProject("c:\\SomeOtherProject\\SomeOtherProject.csproj", "c:\\SomeOtherProject\\obj", FallbackRazorConfiguration.MVC_2_0, "SomeOtherProject");
_workspace = TestWorkspace.Create(w => _someWorkspaceProject = w.AddProject(
ProjectInfo.Create(
ProjectId.CreateNewId(),
VersionStamp.Create(),
"SomeProject",
"SomeProject",
LanguageNames.CSharp,
filePath: _someProject.FilePath).WithCompilationOutputInfo(new CompilationOutputInfo().WithAssemblyPath(Path.Combine(_someProject.IntermediateOutputPath, "SomeProject.dll")))));
AddDisposable(_workspace);
}
[UIFact]
public async Task ProjectOperations_EndBuild_EnqueuesProjectStateUpdate()
{
// Arrange
var expectedProjectPath = _someProject.FilePath;
var projectService = CreateProjectService(expectedProjectPath);
var args = new BuildEventArgs(monitor: null, success: true);
var projectSnapshot = new ProjectSnapshot(ProjectState.Create(_workspace.Services, _someProject));
var projectManager = new Mock<ProjectSnapshotManagerBase>(MockBehavior.Strict);
projectManager.SetupGet(p => p.Workspace).Returns(_workspace);
projectManager
.Setup(p => p.GetAllProjectKeys(expectedProjectPath))
.Returns(ImmutableArray.Create(_someProject.Key));
projectManager
.Setup(p => p.GetLoadedProject(_someProject.Key))
.Returns(projectSnapshot);
var workspaceStateGenerator = new TestProjectWorkspaceStateGenerator();
var trigger = new ProjectBuildChangeTrigger(Dispatcher, projectService, workspaceStateGenerator, projectManager.Object);
// Act
await trigger.HandleEndBuildAsync(args);
Thread.Sleep(500);
// Assert
var update = Assert.Single(workspaceStateGenerator.UpdateQueue);
Assert.Equal(_someWorkspaceProject, update.workspaceProject);
}
[UIFact]
public async Task ProjectOperations_EndBuild_ProjectWithoutWorkspaceProject_Noops()
{
// Arrange
var expectedPath = "Path/To/Project.csproj";
var projectService = CreateProjectService(expectedPath);
var args = new BuildEventArgs(monitor: null, success: true);
var hostProject = new HostProject(expectedPath, "Path/To/obj", RazorConfiguration.Default, "Project");
var projectSnapshot = new ProjectSnapshot(
ProjectState.Create(
_workspace.Services,
hostProject));
var projectManager = new Mock<ProjectSnapshotManagerBase>(MockBehavior.Strict);
projectManager.SetupGet(p => p.Workspace).Returns(_workspace);
projectManager
.Setup(p => p.GetAllProjectKeys(expectedPath))
.Returns(ImmutableArray.Create(hostProject.Key));
projectManager
.Setup(p => p.GetLoadedProject(hostProject.Key))
.Returns(projectSnapshot);
var workspaceStateGenerator = new TestProjectWorkspaceStateGenerator();
var trigger = new ProjectBuildChangeTrigger(Dispatcher, projectService, workspaceStateGenerator, projectManager.Object);
// Act
await trigger.HandleEndBuildAsync(args);
// Assert
Assert.Empty(workspaceStateGenerator.UpdateQueue);
}
[UIFact]
public async Task ProjectOperations_EndBuild_UntrackedProject_NoopsAsync()
{
// Arrange
var projectService = CreateProjectService(_someProject.FilePath);
var args = new BuildEventArgs(monitor: null, success: true);
var projectManager = new Mock<ProjectSnapshotManagerBase>(MockBehavior.Strict);
projectManager.SetupGet(p => p.Workspace).Returns(_workspace);
projectManager
.Setup(p => p.GetAllProjectKeys(_someProject.FilePath))
.Returns(ImmutableArray.Create(_someProject.Key));
projectManager
.Setup(p => p.GetLoadedProject(_someProject.Key))
.Returns<IProjectSnapshot>(null);
var workspaceStateGenerator = new TestProjectWorkspaceStateGenerator();
var trigger = new ProjectBuildChangeTrigger(Dispatcher, projectService, workspaceStateGenerator, projectManager.Object);
// Act
await trigger.HandleEndBuildAsync(args);
// Assert
Assert.Empty(workspaceStateGenerator.UpdateQueue);
}
[UIFact]
public async Task ProjectOperations_EndBuild_BuildFailed_Noops()
{
// Arrange
var args = new BuildEventArgs(monitor: null, success: false);
var projectService = new Mock<TextBufferProjectService>(MockBehavior.Strict);
projectService.Setup(p => p.IsSupportedProject(null)).Throws<InvalidOperationException>();
var projectManager = new Mock<ProjectSnapshotManagerBase>(MockBehavior.Strict);
projectManager.SetupGet(p => p.Workspace).Throws<InvalidOperationException>();
var workspaceStateGenerator = new TestProjectWorkspaceStateGenerator();
var trigger = new ProjectBuildChangeTrigger(Dispatcher, projectService.Object, workspaceStateGenerator, projectManager.Object);
// Act
await trigger.HandleEndBuildAsync(args);
// Assert
Assert.Empty(workspaceStateGenerator.UpdateQueue);
}
[UIFact]
public async Task ProjectOperations_EndBuild_UnsupportedProject_Noops()
{
// Arrange
var args = new BuildEventArgs(monitor: null, success: true);
var projectService = new Mock<TextBufferProjectService>(MockBehavior.Strict);
projectService.Setup(p => p.IsSupportedProject(null)).Returns(false);
var projectManager = new Mock<ProjectSnapshotManagerBase>(MockBehavior.Strict);
projectManager.SetupGet(p => p.Workspace).Throws<InvalidOperationException>();
var workspaceStateGenerator = new TestProjectWorkspaceStateGenerator();
var trigger = new ProjectBuildChangeTrigger(Dispatcher, projectService.Object, workspaceStateGenerator, projectManager.Object);
// Act
await trigger.HandleEndBuildAsync(args);
// Assert
Assert.Empty(workspaceStateGenerator.UpdateQueue);
}
private static TextBufferProjectService CreateProjectService(string projectPath)
{
var projectService = new Mock<TextBufferProjectService>(MockBehavior.Strict);
projectService.Setup(p => p.GetProjectPath(null)).Returns(projectPath);
projectService.Setup(p => p.IsSupportedProject(null)).Returns(true);
return projectService.Object;
}
}

Просмотреть файл

@ -1,559 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Test.Common;
using MonoDevelop.Projects.MSBuild;
using Xunit;
using Xunit.Abstractions;
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.ProjectSystem;
public class DefaultMacRazorProjectHostTest : TestBase
{
public DefaultMacRazorProjectHostTest(ITestOutputHelper testOutput)
: base(testOutput)
{
}
[Fact]
public void IsRazorDocumentItem_UpperCaseExtension_ReturnsTrue()
{
// Arrange
var item = new TestMSBuildItem("NonContent")
{
Include = "\\Path\\To\\File.RAZOR",
};
// Act
var result = DefaultMacRazorProjectHost.IsRazorDocumentItem(item);
// Assert
Assert.True(result);
}
[Fact]
public void IsRazorDocumentItem_NonContentItem_ReturnsTrue()
{
// Arrange
var item = new TestMSBuildItem("NonContent")
{
Include = "\\Path\\To\\File.razor",
};
// Act
var result = DefaultMacRazorProjectHost.IsRazorDocumentItem(item);
// Assert
Assert.True(result);
}
[Fact]
public void IsRazorDocumentItem_NoInclude_ReturnsFalse()
{
// Arrange
var item = new TestMSBuildItem("Content");
// Act
var result = DefaultMacRazorProjectHost.IsRazorDocumentItem(item);
// Assert
Assert.False(result);
}
[Fact]
public void IsRazorDocumentItem_NonRazorFile_ReturnsFalse()
{
// Arrange
var item = new TestMSBuildItem("Content")
{
Include = "\\Path\\To\\File.notrazor",
};
// Act
var result = DefaultMacRazorProjectHost.IsRazorDocumentItem(item);
// Assert
Assert.False(result);
}
[Fact]
public void IsRazorDocumentItem_RazorFile_ReturnsTrue()
{
// Arrange
var item = new TestMSBuildItem("Content")
{
Include = "\\Path\\To\\File.razor",
};
// Act
var result = DefaultMacRazorProjectHost.IsRazorDocumentItem(item);
// Assert
Assert.True(result);
}
[Fact]
public void IsRazorDocumentItem_CSHTMLFile_ReturnsTrue()
{
// Arrange
var item = new TestMSBuildItem("Content")
{
Include = "\\Path\\To\\File.cshtml",
};
// Act
var result = DefaultMacRazorProjectHost.IsRazorDocumentItem(item);
// Assert
Assert.True(result);
}
[Fact]
public void TryGetDefaultConfiguration_FailsIfNoConfiguration()
{
// Arrange
var projectProperties = new MSBuildPropertyGroup();
// Act
var result = DefaultMacRazorProjectHost.TryGetDefaultConfiguration(projectProperties, out var defaultConfiguration);
// Assert
Assert.False(result);
Assert.Null(defaultConfiguration);
}
[Fact]
public void TryGetDefaultConfiguration_FailsIfEmptyConfiguration()
{
// Arrange
var projectProperties = new MSBuildPropertyGroup();
projectProperties.SetValue("RazorDefaultConfiguration", string.Empty);
// Act
var result = DefaultMacRazorProjectHost.TryGetDefaultConfiguration(projectProperties, out var defaultConfiguration);
// Assert
Assert.False(result);
Assert.Null(defaultConfiguration);
}
[Fact]
public void TryGetDefaultConfiguration_SucceedsWithValidConfiguration()
{
// Arrange
var expectedConfiguration = "Razor-13.37";
var projectProperties = new MSBuildPropertyGroup();
projectProperties.SetValue("RazorDefaultConfiguration", expectedConfiguration);
// Act
var result = DefaultMacRazorProjectHost.TryGetDefaultConfiguration(projectProperties, out var defaultConfiguration);
// Assert
Assert.True(result);
Assert.Equal(expectedConfiguration, defaultConfiguration);
}
[Fact]
public void TryGetLanguageVersion_FailsIfNoLanguageVersion()
{
// Arrange
var projectProperties = new MSBuildPropertyGroup();
// Act
var result = DefaultMacRazorProjectHost.TryGetLanguageVersion(projectProperties, out var languageVersion);
// Assert
Assert.False(result);
Assert.Null(languageVersion);
}
[Fact]
public void TryGetLanguageVersion_FailsIfEmptyLanguageVersion()
{
// Arrange
var projectProperties = new MSBuildPropertyGroup();
projectProperties.SetValue("RazorLangVersion", string.Empty);
// Act
var result = DefaultMacRazorProjectHost.TryGetLanguageVersion(projectProperties, out var languageVersion);
// Assert
Assert.False(result);
Assert.Null(languageVersion);
}
[Fact]
public void TryGetLanguageVersion_SucceedsWithValidLanguageVersion()
{
// Arrange
var projectProperties = new MSBuildPropertyGroup();
projectProperties.SetValue("RazorLangVersion", "1.0");
// Act
var result = DefaultMacRazorProjectHost.TryGetLanguageVersion(projectProperties, out var languageVersion);
// Assert
Assert.True(result);
Assert.Same(RazorLanguageVersion.Version_1_0, languageVersion);
}
[Fact]
public void TryGetLanguageVersion_SucceedsWithUnknownLanguageVersion_DefaultsToLatest()
{
// Arrange
var projectProperties = new MSBuildPropertyGroup();
projectProperties.SetValue("RazorLangVersion", "13.37");
// Act
var result = DefaultMacRazorProjectHost.TryGetLanguageVersion(projectProperties, out var languageVersion);
// Assert
Assert.True(result);
Assert.Same(RazorLanguageVersion.Latest, languageVersion);
}
[Fact]
public void TryGetConfigurationItem_FailsNoRazorConfigurationItems()
{
// Arrange
var projectItems = Enumerable.Empty<IMSBuildItemEvaluated>();
// Act
var result = DefaultMacRazorProjectHost.TryGetConfigurationItem("Razor-13.37", projectItems, out var configurationItem);
// Assert
Assert.False(result);
Assert.Null(configurationItem);
}
[Fact]
public void TryGetConfigurationItem_FailsNoMatchingRazorConfigurationItems()
{
// Arrange
var projectItems = new IMSBuildItemEvaluated[]
{
new TestMSBuildItem("RazorConfiguration")
{
Include = "Razor-10.0",
}
};
// Act
var result = DefaultMacRazorProjectHost.TryGetConfigurationItem("Razor-13.37", projectItems, out var configurationItem);
// Assert
Assert.False(result);
Assert.Null(configurationItem);
}
[Fact]
public void TryGetConfigurationItem_SucceedsForMatchingConfigurationItem()
{
// Arrange
var expectedConfiguration = "Razor-13.37";
var expectedConfigurationItem = new TestMSBuildItem("RazorConfiguration")
{
Include = expectedConfiguration,
};
var projectItems = new IMSBuildItemEvaluated[]
{
new TestMSBuildItem("RazorConfiguration")
{
Include = "Razor-10.0-DoesNotMatch",
},
expectedConfigurationItem
};
// Act
var result = DefaultMacRazorProjectHost.TryGetConfigurationItem(expectedConfiguration, projectItems, out var configurationItem);
// Assert
Assert.True(result);
Assert.Same(expectedConfigurationItem, configurationItem);
}
[Fact]
public void GetExtensionNames_FailsIfNoExtensions()
{
// Arrange
var configurationItem = new TestMSBuildItem("RazorConfiguration");
// Act
var extensionNames = DefaultMacRazorProjectHost.GetExtensionNames(configurationItem);
// Assert
Assert.Empty(extensionNames);
}
[Fact]
public void GetExtensionNames_FailsIfEmptyExtensions()
{
// Arrange
var configurationItem = new TestMSBuildItem("RazorConfiguration");
configurationItem.TestMetadata.SetValue("Extensions", string.Empty);
// Act
var extensionNames = DefaultMacRazorProjectHost.GetExtensionNames(configurationItem);
// Assert
Assert.Empty(extensionNames);
}
[Fact]
public void GetExtensionNames_SucceedsIfSingleExtension()
{
// Arrange
var expectedExtensionName = "SomeExtensionName";
var configurationItem = new TestMSBuildItem("RazorConfiguration");
configurationItem.TestMetadata.SetValue("Extensions", expectedExtensionName);
// Act
var extensionNames = DefaultMacRazorProjectHost.GetExtensionNames(configurationItem);
// Assert
var extensionName = Assert.Single(extensionNames);
Assert.Equal(expectedExtensionName, extensionName);
}
[Fact]
public void GetExtensionNames_SucceedsIfMultipleExtensions()
{
// Arrange
var configurationItem = new TestMSBuildItem("RazorConfiguration");
configurationItem.TestMetadata.SetValue("Extensions", "SomeExtensionName;SomeOtherExtensionName");
// Act
var extensionNames = DefaultMacRazorProjectHost.GetExtensionNames(configurationItem);
// Assert
Assert.Collection(
extensionNames,
name => Assert.Equal("SomeExtensionName", name),
name => Assert.Equal("SomeOtherExtensionName", name));
}
[Fact]
public void GetExtensions_NoExtensionTypes_ReturnsEmptyArray()
{
// Arrange
var projectItems = new IMSBuildItemEvaluated[]
{
new TestMSBuildItem("NotAnExtension")
{
Include = "Extension1",
},
};
// Act
var extensions = DefaultMacRazorProjectHost.GetExtensions(new[] { "Extension1", "Extension2" }, projectItems);
// Assert
Assert.Empty(extensions);
}
[Fact]
public void GetExtensions_UnConfiguredExtensionTypes_ReturnsEmptyArray()
{
// Arrange
var projectItems = new IMSBuildItemEvaluated[]
{
new TestMSBuildItem("RazorExtension")
{
Include = "UnconfiguredExtensionName",
},
};
// Act
var extensions = DefaultMacRazorProjectHost.GetExtensions(new[] { "Extension1", "Extension2" }, projectItems);
// Assert
Assert.Empty(extensions);
}
[Fact]
public void GetExtensions_SomeConfiguredExtensions_ReturnsConfiguredExtensions()
{
// Arrange
var expectedExtension1Name = "Extension1";
var expectedExtension2Name = "Extension2";
var projectItems = new IMSBuildItemEvaluated[]
{
new TestMSBuildItem("RazorExtension")
{
Include = "UnconfiguredExtensionName",
},
new TestMSBuildItem("RazorExtension")
{
Include = expectedExtension1Name,
},
new TestMSBuildItem("RazorExtension")
{
Include = expectedExtension2Name,
},
};
// Act
var extensions = DefaultMacRazorProjectHost.GetExtensions(new[] { expectedExtension1Name, expectedExtension2Name }, projectItems);
// Assert
Assert.Collection(
extensions,
extension => Assert.Equal(expectedExtension1Name, extension.ExtensionName),
extension => Assert.Equal(expectedExtension2Name, extension.ExtensionName));
}
[Fact]
public void TryGetConfiguration_FailsIfNoDefaultConfiguration()
{
// Arrange
var projectProperties = new MSBuildPropertyGroup();
var projectItems = Array.Empty<IMSBuildItemEvaluated>();
// Act
var result = DefaultMacRazorProjectHost.TryGetConfiguration(projectProperties, projectItems, out var configuration);
// Assert
Assert.False(result);
Assert.Null(configuration);
}
[Fact]
public void TryGetConfiguration_FailsIfNoLanguageVersion()
{
// Arrange
var projectProperties = new MSBuildPropertyGroup();
projectProperties.SetValue("RazorDefaultConfiguration", "Razor-13.37");
var projectItems = Array.Empty<IMSBuildItemEvaluated>();
// Act
var result = DefaultMacRazorProjectHost.TryGetConfiguration(projectProperties, projectItems, out var configuration);
// Assert
Assert.False(result);
Assert.Null(configuration);
}
[Fact]
public void TryGetConfiguration_FailsIfNoConfigurationItems()
{
// Arrange
var projectProperties = new MSBuildPropertyGroup();
projectProperties.SetValue("RazorDefaultConfiguration", "Razor-13.37");
projectProperties.SetValue("RazorLangVersion", "1.0");
var projectItems = Array.Empty<IMSBuildItemEvaluated>();
// Act
var result = DefaultMacRazorProjectHost.TryGetConfiguration(projectProperties, projectItems, out var configuration);
// Assert
Assert.False(result);
Assert.Null(configuration);
}
[Fact]
public void TryGetConfiguration_SucceedsWithoutConfiguredExtensionNames()
{
// Arrange
var projectProperties = new MSBuildPropertyGroup();
projectProperties.SetValue("RazorDefaultConfiguration", "Razor-13.37");
projectProperties.SetValue("RazorLangVersion", "1.0");
var projectItems = new IMSBuildItemEvaluated[]
{
new TestMSBuildItem("RazorConfiguration")
{
Include = "Razor-13.37",
},
};
// Act
var result = DefaultMacRazorProjectHost.TryGetConfiguration(projectProperties, projectItems, out var configuration);
// Assert
Assert.True(result);
Assert.Empty(configuration.Extensions);
}
// This is more of an integration test but is here to test the overall flow/functionality
[Fact]
public void TryGetConfiguration_SucceedsWithAllPreRequisites()
{
// Arrange
var expectedLanguageVersion = RazorLanguageVersion.Version_1_0;
var expectedConfigurationName = "Razor-Test";
var expectedExtension1Name = "Extension1";
var expectedExtension2Name = "Extension2";
var expectedRazorConfigurationItem = new TestMSBuildItem("RazorConfiguration")
{
Include = expectedConfigurationName,
};
expectedRazorConfigurationItem.TestMetadata.SetValue("Extensions", "Extension1;Extension2");
var projectItems = new IMSBuildItemEvaluated[]
{
new TestMSBuildItem("RazorConfiguration")
{
Include = "UnconfiguredRazorConfiguration",
},
new TestMSBuildItem("RazorExtension")
{
Include = "UnconfiguredExtensionName",
},
new TestMSBuildItem("RazorExtension")
{
Include = expectedExtension1Name,
},
new TestMSBuildItem("RazorExtension")
{
Include = expectedExtension2Name,
},
expectedRazorConfigurationItem,
};
var projectProperties = new MSBuildPropertyGroup();
projectProperties.SetValue("RazorDefaultConfiguration", expectedConfigurationName);
projectProperties.SetValue("RazorLangVersion", "1.0");
// Act
var result = DefaultMacRazorProjectHost.TryGetConfiguration(projectProperties, projectItems, out var configuration);
// Assert
Assert.True(result);
Assert.Equal(expectedLanguageVersion, configuration.LanguageVersion);
Assert.Equal(expectedConfigurationName, configuration.ConfigurationName);
Assert.Collection(
configuration.Extensions,
extension => Assert.Equal(expectedExtension1Name, extension.ExtensionName),
extension => Assert.Equal(expectedExtension2Name, extension.ExtensionName));
}
private class TestMSBuildItem : IMSBuildItemEvaluated
{
public TestMSBuildItem(string name)
{
Name = name;
TestMetadata = new MSBuildPropertyGroup();
}
public string Name { get; }
public string Include { get; set; }
public MSBuildPropertyGroup TestMetadata { get; }
public IMSBuildPropertyGroupEvaluated Metadata => TestMetadata;
public string Condition => throw new NotImplementedException();
public bool IsImported => throw new NotImplementedException();
public string UnevaluatedInclude => throw new NotImplementedException();
public MSBuildItem SourceItem => throw new NotImplementedException();
public IEnumerable<MSBuildItem> SourceItems => throw new NotImplementedException();
}
}

Просмотреть файл

@ -1,70 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using Microsoft.AspNetCore.Razor.Test.Common;
using MonoDevelop.Core;
using MonoDevelop.Projects;
using Xunit;
using Xunit.Abstractions;
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.ProjectSystem;
public class FallbackMacRazorProjectHostTest : TestBase
{
public FallbackMacRazorProjectHostTest(ITestOutputHelper testOutput)
: base(testOutput)
{
}
[Theory]
[InlineData(null)]
[InlineData("")]
public void IsMvcAssembly_FailsIfNullOrEmptyFilePath(string filePath)
{
// Arrange
var assemblyFilePath = new FilePath(filePath);
var assemblyReference = new AssemblyReference(assemblyFilePath);
// Act
var result = FallbackMacRazorProjectHost.IsMvcAssembly(assemblyReference);
// Assert
Assert.False(result);
}
[Fact]
public void IsMvcAssembly_FailsIfNotMvc()
{
// Arrange
var assemblyFilePath = new FilePath("C:/Path/To/Assembly.dll");
var assemblyReference = new AssemblyReference(assemblyFilePath);
// Act
var result = FallbackMacRazorProjectHost.IsMvcAssembly(assemblyReference);
// Assert
Assert.False(result);
}
[Fact]
public void IsMvcAssembly_SucceedsIfMvc()
{
// Arrange
var assemblyFilePath = new FilePath("C:/Path/To/Microsoft.AspNetCore.Mvc.Razor.dll");
var assemblyReference = new AssemblyReference(assemblyFilePath);
// Act
var result = FallbackMacRazorProjectHost.IsMvcAssembly(assemblyReference);
// Assert
Assert.True(result);
}
// -------------------------------------------------------------------------------------------
// Purposefully do not have any more tests here because that would involve mocking MonoDevelop
// types. The default constructors for the Solution / DotNetProject MonoDevelop types change
// static classes (they assume they're being created in an IDE).
// -------------------------------------------------------------------------------------------
}

Просмотреть файл

@ -1,182 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System.IO;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.LanguageServer;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.Editor.Razor;
using Moq;
using Xunit;
using Xunit.Abstractions;
using Xunit.Sdk;
namespace Microsoft.CodeAnalysis.Razor.ProjectSystem;
public class RazorDocumentInfoProviderTest : WorkspaceTestBase
{
private readonly VisualStudioMacDocumentInfoFactory _factory;
private readonly DefaultRazorDynamicFileInfoProvider _innerDynamicDocumentInfoProvider;
private readonly TestProjectSnapshotManager _projectSnapshotManager;
private readonly IProjectSnapshot _projectSnapshot;
private readonly ProjectId _projectId;
private readonly IDocumentSnapshot _documentSnapshot;
public RazorDocumentInfoProviderTest(ITestOutputHelper testOutput)
: base(testOutput)
{
_projectSnapshotManager = new TestProjectSnapshotManager(Workspace, new TestProjectSnapshotManagerDispatcher());
var serviceProviderFactory = new DefaultRazorDocumentServiceProviderFactory();
var lspEditorEnabledFeatureDetector = Mock.Of<LSPEditorFeatureDetector>(detector => detector.IsLSPEditorAvailable() == true, MockBehavior.Strict);
var projectSnapshotManagerAccessor = Mock.Of<ProjectSnapshotManagerAccessor>(a => a.Instance == _projectSnapshotManager, MockBehavior.Strict);
var filePathService = new FilePathService(TestLanguageServerFeatureOptions.Instance);
_innerDynamicDocumentInfoProvider = new DefaultRazorDynamicFileInfoProvider(serviceProviderFactory, lspEditorEnabledFeatureDetector, filePathService, projectSnapshotManagerAccessor);
var hostProject = new HostProject("C:/path/to/project.csproj", "C:/path/to/obj", RazorConfiguration.Default, "RootNamespace");
_projectSnapshotManager.ProjectAdded(hostProject);
var hostDocument = new HostDocument("C:/path/to/document.cshtml", "/C:/path/to/document.cshtml");
var sourceText = SourceText.From("Hello World");
var textAndVersion = TextAndVersion.Create(sourceText, VersionStamp.Default, hostDocument.FilePath);
_projectSnapshotManager.DocumentAdded(hostProject.Key, hostDocument, TextLoader.From(textAndVersion));
_projectSnapshot = _projectSnapshotManager.GetProjects()[0];
_documentSnapshot = _projectSnapshot.GetDocument(hostDocument.FilePath);
var factory = new Mock<VisualStudioMacDocumentInfoFactory>(MockBehavior.Strict);
factory.Setup(f => f.CreateEmpty(It.IsAny<string>(), It.IsAny<ProjectId>(), It.IsAny<ProjectKey>()))
.Returns<string, ProjectId, ProjectKey>((razorFilePath, projectId, projectKey) =>
{
var documentId = DocumentId.CreateNewId(projectId);
var documentInfo = DocumentInfo.Create(documentId, "testDoc", filePath: razorFilePath);
return documentInfo;
});
_factory = factory.Object;
_projectId = ProjectId.CreateNewId();
Workspace.TryApplyChanges(Workspace.CurrentSolution.AddProject(ProjectInfo.Create(
_projectId,
new VersionStamp(),
"Project",
"Assembly",
LanguageNames.CSharp,
filePath: _projectSnapshot.FilePath).WithCompilationOutputInfo(new CompilationOutputInfo().WithAssemblyPath(Path.Combine(_projectSnapshot.IntermediateOutputPath, "project.dll")))));
}
[Fact]
public void DelegatedUpdateFileInfo_UnknownDocument_Noops()
{
// Arrange
var provider = new RazorDynamicDocumentInfoProvider(_factory, _innerDynamicDocumentInfoProvider);
provider.Initialize(_projectSnapshotManager);
provider.Updated += (_) => throw new XunitException("This should not have been called.");
var documentContainer = new DefaultDynamicDocumentContainer(_documentSnapshot);
// Act & Assert
_innerDynamicDocumentInfoProvider.UpdateFileInfo(_projectSnapshot.Key, documentContainer);
}
[Fact]
public void DelegatedUpdateFileInfo_KnownDocument_TriggersUpdate()
{
// Arrange
var provider = new RazorDynamicDocumentInfoProvider(_factory, _innerDynamicDocumentInfoProvider);
provider.Initialize(_projectSnapshotManager);
DocumentInfo documentInfo = null;
provider.Updated += (info) => documentInfo = info;
// Populate the providers understanding of our project/document
provider.GetDynamicDocumentInfo(_projectId, _projectSnapshot.FilePath, _documentSnapshot.FilePath);
var documentContainer = new DefaultDynamicDocumentContainer(_documentSnapshot);
// Act
_innerDynamicDocumentInfoProvider.UpdateFileInfo(_projectSnapshot.Key, documentContainer);
// Assert
Assert.NotNull(documentInfo);
Assert.Equal(_documentSnapshot.FilePath, documentInfo.FilePath);
}
[Fact]
public void DelegatedSuppressDocument_UnknownDocument_Noops()
{
// Arrange
var provider = new RazorDynamicDocumentInfoProvider(_factory, _innerDynamicDocumentInfoProvider);
provider.Initialize(_projectSnapshotManager);
provider.Updated += (_) => throw new XunitException("This should not have been called.");
var documentContainer = new DefaultDynamicDocumentContainer(_documentSnapshot);
// Act & Assert
_innerDynamicDocumentInfoProvider.SuppressDocument(_projectSnapshot.Key, _documentSnapshot.FilePath);
}
[Fact]
public void DelegatedSuppressDocument_KnownDocument_NotUpdated_Noops()
{
// Arrange
var provider = new RazorDynamicDocumentInfoProvider(_factory, _innerDynamicDocumentInfoProvider);
provider.Initialize(_projectSnapshotManager);
provider.Updated += (_) => throw new XunitException("This should not have been called.");
// Populate the providers understanding of our project/document
provider.GetDynamicDocumentInfo(_projectId, _projectSnapshot.FilePath, _documentSnapshot.FilePath);
var documentContainer = new DefaultDynamicDocumentContainer(_documentSnapshot);
// Act & Assert
_innerDynamicDocumentInfoProvider.SuppressDocument(_projectSnapshot.Key, _documentSnapshot.FilePath);
}
[Fact]
public void DelegatedSuppressDocument_KnownAndUpdatedDocument_TriggersUpdate()
{
// Arrange
var provider = new RazorDynamicDocumentInfoProvider(_factory, _innerDynamicDocumentInfoProvider);
provider.Initialize(_projectSnapshotManager);
DocumentInfo documentInfo = null;
provider.Updated += (info) => documentInfo = info;
// Populate the providers understanding of our project/document
provider.GetDynamicDocumentInfo(_projectId, _projectSnapshot.FilePath, _documentSnapshot.FilePath);
var documentContainer = new DefaultDynamicDocumentContainer(_documentSnapshot);
// Update the document with content
_innerDynamicDocumentInfoProvider.UpdateFileInfo(_projectSnapshot.Key, documentContainer);
// Act
_innerDynamicDocumentInfoProvider.SuppressDocument(_projectSnapshot.Key, _documentSnapshot.FilePath);
// Assert
Assert.NotNull(documentInfo);
Assert.Equal(_documentSnapshot.FilePath, documentInfo.FilePath);
}
[Fact]
public void DelegatedRemoveDynamicDocumentInfo_UntracksDocument()
{
// Arrange
var provider = new RazorDynamicDocumentInfoProvider(_factory, _innerDynamicDocumentInfoProvider);
provider.Initialize(_projectSnapshotManager);
// Populate the providers understanding of our project/document
provider.GetDynamicDocumentInfo(_projectId, _projectSnapshot.FilePath, _documentSnapshot.FilePath);
var documentContainer = new DefaultDynamicDocumentContainer(_documentSnapshot);
// Update the document with content
_innerDynamicDocumentInfoProvider.UpdateFileInfo(_projectSnapshot.Key, documentContainer);
// Now explode if any further updates happen
provider.Updated += (_) => throw new XunitException("This should not have been called.");
// Act
provider.RemoveDynamicDocumentInfo(_projectId, _projectSnapshot.FilePath, _documentSnapshot.FilePath);
// Assert this should not update
_innerDynamicDocumentInfoProvider.UpdateFileInfo(_projectSnapshot.Key, documentContainer);
}
}

Просмотреть файл

@ -1,41 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.ProjectSystem;
internal class TestProjectConfigurationFilePathStore : ProjectConfigurationFilePathStore
{
public static readonly TestProjectConfigurationFilePathStore Instance = new();
private TestProjectConfigurationFilePathStore()
{
}
public override event EventHandler<ProjectConfigurationFilePathChangedEventArgs>? Changed;
public override IReadOnlyDictionary<ProjectKey, string> GetMappings()
{
throw new NotImplementedException();
}
public override void Remove(ProjectKey projectKey)
{
Changed?.Invoke(this, new ProjectConfigurationFilePathChangedEventArgs(projectKey, configurationFilePath: null));
}
public override void Set(ProjectKey projectKey, string configurationFilePath)
{
Changed?.Invoke(this, new ProjectConfigurationFilePathChangedEventArgs(projectKey, configurationFilePath));
}
public override bool TryGet(ProjectKey projectKey, [NotNullWhen(returnValue: true)] out string? configurationFilePath)
{
configurationFilePath = null;
return false;
}
}

Просмотреть файл

@ -1,22 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.VisualStudio.Editor.Razor;
using Moq;
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.ProjectSystem;
internal class TestVSLanguageServerFeatureOptions : VisualStudioMacLanguageServerFeatureOptions
{
#pragma warning disable CS0618 // Type or member is obsolete
public static readonly TestVSLanguageServerFeatureOptions Instance = new();
#pragma warning restore CS0618 // Type or member is obsolete
[Obsolete("Use static Instance member")]
public TestVSLanguageServerFeatureOptions()
: base(Mock.Of<LSPEditorFeatureDetector>(MockBehavior.Strict))
{
}
}

Просмотреть файл

@ -1,135 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using Microsoft.AspNetCore.Razor.Test.Common;
using MonoDevelop.Projects;
using Xunit;
using Xunit.Abstractions;
namespace Microsoft.VisualStudio.LanguageServices.Razor;
public class VisualStudioMacLSPEditorFeatureDetectorTest : TestBase
{
public VisualStudioMacLSPEditorFeatureDetectorTest(ITestOutputHelper testOutput)
: base(testOutput)
{
}
[Fact]
public void IsLSPEditorAvailable_ProjectSupported_ReturnsTrue()
{
// Arrange
var featureDetector = new TestLSPEditorFeatureDetector()
{
ProjectSupportsLSPEditorValue = true,
};
// Act
var result = featureDetector.IsLSPEditorAvailable("testMoniker", hierarchy: null);
// Assert
Assert.True(result);
}
[Fact]
public void IsLSPEditorAvailable_LegacyEditorEnabled_ReturnsFalse()
{
// Arrange
var featureDetector = new TestLSPEditorFeatureDetector()
{
UseLegacyEditor = true,
ProjectSupportsLSPEditorValue = true,
};
// Act
var result = featureDetector.IsLSPEditorAvailable("testMoniker", hierarchy: null);
// Assert
Assert.False(result);
}
[Fact]
public void IsLSPEditorAvailable_IsVSRemoteClient_ReturnsTrue()
{
// Arrange
var featureDetector = new TestLSPEditorFeatureDetector()
{
IsRemoteClientValue = true,
ProjectSupportsLSPEditorValue = true,
};
// Act
var result = featureDetector.IsLSPEditorAvailable("testMoniker", hierarchy: null);
// Assert
Assert.True(result);
}
[Fact]
public void IsLSPEditorAvailable_UnsupportedProject_ReturnsFalse()
{
// Arrange
var featureDetector = new TestLSPEditorFeatureDetector()
{
ProjectSupportsLSPEditorValue = false,
};
// Act
var result = featureDetector.IsLSPEditorAvailable("testMoniker", hierarchy: null);
// Assert
Assert.False(result);
}
[Fact]
public void IsRemoteClient_VSRemoteClient_ReturnsTrue()
{
// Arrange
var featureDetector = new TestLSPEditorFeatureDetector()
{
IsRemoteClientValue = true,
};
// Act
var result = featureDetector.IsRemoteClient();
// Assert
Assert.True(result);
}
[Fact]
public void IsRemoteClient_UnknownEnvironment_ReturnsFalse()
{
// Arrange
var featureDetector = new TestLSPEditorFeatureDetector();
// Act
var result = featureDetector.IsRemoteClient();
// Assert
Assert.False(result);
}
#pragma warning disable CS0618 // Type or member is obsolete (Test constructor)
private class TestLSPEditorFeatureDetector : VisualStudioMacLSPEditorFeatureDetector
{
public bool UseLegacyEditor { get; set; }
public bool IsLiveShareHostValue { get; set; }
public bool IsRemoteClientValue { get; set; }
public bool ProjectSupportsLSPEditorValue { get; set; }
public override bool IsLSPEditorAvailable() => !UseLegacyEditor;
public override bool IsLiveShareHost() => IsLiveShareHostValue;
public override bool IsRemoteClient() => IsRemoteClientValue;
private protected override bool ProjectSupportsLSPEditor(string documentFilePath, DotNetProject project) => ProjectSupportsLSPEditorValue;
}
#pragma warning restore CS0618 // Type or member is obsolete (Test constructor)
}

Просмотреть файл

@ -1,4 +0,0 @@
{
"methodDisplay": "method",
"shadowCopy": false
}

Просмотреть файл

@ -29,8 +29,6 @@ using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LanguageServerClient.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LanguageServices.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LiveShare.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Mac.RazorAddin, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Mac.LanguageServices.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.RazorExtension, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.RazorExtension.Dependencies, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("RazorDeployment, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
@ -56,7 +54,6 @@ using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LanguageServerClient.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LanguageServices.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LiveShare.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Mac.LanguageServices.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Razor.IntegrationTests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
// Benchmarks