diff --git a/Directory.Packages.props b/Directory.Packages.props
index 425bac1f55f..62a33472ea5 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -13,7 +13,6 @@
<_BasicReferenceAssembliesVersion>1.7.2
<_BenchmarkDotNetPackageVersion>0.13.5.2136
<_MicrosoftVisualStudioExtensibilityTestingVersion>0.1.187-beta
- <_MicrosoftCodeAnalysisAnalyzersPackageVersion>3.11.0
<_RoslynDiagnosticAnalyzersPackageVersion>3.11.0-beta1.24508.2
<_MicrosoftVisualStudioLanguageServicesPackageVersion>$(MicrosoftVisualStudioLanguageServicesPackageVersion)
<_XunitPackageVersion>2.9.2
@@ -33,8 +32,7 @@
-
-
+
@@ -46,16 +44,16 @@
-
-
-
+
+
+
-
+
diff --git a/NuGet.config b/NuGet.config
index b5e83791aff..6791c5978fb 100644
--- a/NuGet.config
+++ b/NuGet.config
@@ -20,8 +20,6 @@
-
-
@@ -36,18 +34,12 @@
-
-
-
-->
-
-
-
diff --git a/azure-pipelines-richnav.yml b/azure-pipelines-richnav.yml
deleted file mode 100644
index cd294a1938c..00000000000
--- a/azure-pipelines-richnav.yml
+++ /dev/null
@@ -1,62 +0,0 @@
-#
-# See https://docs.microsoft.com/azure/devops/pipelines/yaml-schema for reference.
-#
-
-variables:
-- template: /eng/common/templates/variables/pool-providers.yml
-- name: Build.Repository.Clean
- value: true
-- name: Codeql.Enabled
- value: false
-- name: Codeql.SkipTaskAutoInjection
- value: true
-
-trigger:
- branches:
- include:
- - main
-
-pr:
- autoCancel: true
- branches:
- include:
- - main
-
-stages:
-- stage: build
- displayName: Build
- jobs:
- - template: /eng/common/templates/jobs/jobs.yml
- parameters:
- helixRepo: dotnet/razor-tooling
- helixType: build.product/
- enableRichCodeNavigation: true
- richCodeNavigationLanguage: 'csharp'
- jobs:
- - job: Windows
- pool:
- name: $(DncEngPublicBuildPool)
- demands: ImageOverride -equals windows.vs2019.amd64.open
-
- steps:
- - task: NuGetCommand@2
- displayName: 'Clear NuGet caches'
- condition: succeeded()
- inputs:
- command: custom
- arguments: 'locals all -clear'
-
- - task: PowerShell@2
- displayName: Build
- condition: succeeded()
- inputs:
- filePath: eng/common/build.ps1
- arguments: -ci
- -restore
- -build
- -sign
- -pack
- -publish
- -configuration Debug
- -msbuildEngine dotnet
- -prepareMachine
\ No newline at end of file
diff --git a/eng/SetupVSHive.ps1 b/eng/SetupVSHive.ps1
index 097ca05c104..c47e7a040b9 100644
--- a/eng/SetupVSHive.ps1
+++ b/eng/SetupVSHive.ps1
@@ -12,6 +12,8 @@ $vsRegEdit = Join-Path (Join-Path (Join-Path $vsDir 'Common7') 'IDE') 'VSRegEdit
$hive = "RoslynDev"
&$vsRegEdit set "$vsDir" $hive HKCU "Roslyn\Internal\OnOff\Features" OOP64Bit dword 0
+&$vsRegEdit set "$vsDir" $hive HKLM "Profile" DisableFirstLaunchDialog dword 1
+
Write-Host "-- VS Info --"
$isolationIni = Join-Path (Join-Path (Join-Path $vsDir 'Common7') 'IDE') 'devenv.isolation.ini'
Get-Content $isolationIni | Write-Host
diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml
index 254993bb590..3069ccdf5d7 100644
--- a/eng/Version.Details.xml
+++ b/eng/Version.Details.xml
@@ -6,89 +6,109 @@
839cdfb0ecca5e0be3dbccd926e7651ef50fdf10
-
+
https://github.com/dotnet/source-build-reference-packages
- cf30e8fd726730aa4b142275fb2fc0503528b7dd
+ 14f833124983b36ac4083338d0cad6caefce2489
-
+
https://github.com/dotnet/roslyn
- 0a79874a2ea127eafd3a95a2a474d1e38b85221d
+ 605d9346cdae106907f67663250788eff6048b09
-
+
https://github.com/dotnet/roslyn
- 0a79874a2ea127eafd3a95a2a474d1e38b85221d
+ 605d9346cdae106907f67663250788eff6048b09
-
+
https://github.com/dotnet/roslyn
- 0a79874a2ea127eafd3a95a2a474d1e38b85221d
+ 09312a65870e883999ffe2ca25edd05cbc241e05
-
+
https://github.com/dotnet/roslyn
- 0a79874a2ea127eafd3a95a2a474d1e38b85221d
+ 605d9346cdae106907f67663250788eff6048b09
-
+
https://github.com/dotnet/roslyn
- 0a79874a2ea127eafd3a95a2a474d1e38b85221d
+ 605d9346cdae106907f67663250788eff6048b09
-
+
https://github.com/dotnet/roslyn
- 0a79874a2ea127eafd3a95a2a474d1e38b85221d
+ 605d9346cdae106907f67663250788eff6048b09
-
+
https://github.com/dotnet/roslyn
- 0a79874a2ea127eafd3a95a2a474d1e38b85221d
+ 605d9346cdae106907f67663250788eff6048b09
-
+
https://github.com/dotnet/roslyn
- 0a79874a2ea127eafd3a95a2a474d1e38b85221d
+ 605d9346cdae106907f67663250788eff6048b09
-
+
https://github.com/dotnet/roslyn
- 0a79874a2ea127eafd3a95a2a474d1e38b85221d
+ 605d9346cdae106907f67663250788eff6048b09
-
+
https://github.com/dotnet/roslyn
- 0a79874a2ea127eafd3a95a2a474d1e38b85221d
+ 605d9346cdae106907f67663250788eff6048b09
-
+
https://github.com/dotnet/roslyn
- 0a79874a2ea127eafd3a95a2a474d1e38b85221d
+ 605d9346cdae106907f67663250788eff6048b09
-
+
https://github.com/dotnet/roslyn
- 0a79874a2ea127eafd3a95a2a474d1e38b85221d
+ 605d9346cdae106907f67663250788eff6048b09
-
+
https://github.com/dotnet/roslyn
- 0a79874a2ea127eafd3a95a2a474d1e38b85221d
+ 605d9346cdae106907f67663250788eff6048b09
-
+
https://github.com/dotnet/roslyn
- 0a79874a2ea127eafd3a95a2a474d1e38b85221d
+ 605d9346cdae106907f67663250788eff6048b09
-
+
https://github.com/dotnet/roslyn
- 0a79874a2ea127eafd3a95a2a474d1e38b85221d
+ 605d9346cdae106907f67663250788eff6048b09
-
+
https://github.com/dotnet/roslyn
- 0a79874a2ea127eafd3a95a2a474d1e38b85221d
+ 605d9346cdae106907f67663250788eff6048b09
-
+
https://github.com/dotnet/roslyn
- 0a79874a2ea127eafd3a95a2a474d1e38b85221d
+ 605d9346cdae106907f67663250788eff6048b09
-
+
https://github.com/dotnet/roslyn
- 0a79874a2ea127eafd3a95a2a474d1e38b85221d
+ 605d9346cdae106907f67663250788eff6048b09
-
+
https://github.com/dotnet/roslyn
- 0a79874a2ea127eafd3a95a2a474d1e38b85221d
+ 605d9346cdae106907f67663250788eff6048b09
+
+ https://github.com/dotnet/roslyn
+ 605d9346cdae106907f67663250788eff6048b09
+
+
+ https://github.com/dotnet/roslyn
+ 605d9346cdae106907f67663250788eff6048b09
+
+
+ https://github.com/dotnet/roslyn
+ 605d9346cdae106907f67663250788eff6048b09
+
+
+ https://github.com/dotnet/roslyn
+ 605d9346cdae106907f67663250788eff6048b09
+
+
+ https://github.com/dotnet/roslyn
+ 605d9346cdae106907f67663250788eff6048b09
+
@@ -96,14 +116,14 @@
https://dev.azure.com/dnceng/internal/_git/dotnet-runtime
3a25a7f1cc446b60678ed25c9d829420d6321eba
-
+
https://github.com/dotnet/arcade
- f33d9e642f0e68a61312164cd9e0baf4e142a999
+ 97cbc7361ff28b2948c8182720c166a744049f55
-
+
https://github.com/dotnet/arcade
- f33d9e642f0e68a61312164cd9e0baf4e142a999
+ 97cbc7361ff28b2948c8182720c166a744049f55
- 9
+ 10
0
0
preview
@@ -30,8 +30,8 @@
imported. This OK because we want to just have an obvious salt for a local build.
-->
- 17.14.3
- 17.14
+ 17.15.1
+ 17.15
$(AddinMajorVersion)
$(AddinVersion).$(OfficialBuildId)
$(AddinVersion).42424242.42
@@ -47,29 +47,34 @@
-->
+ 3.12.0-beta1.25209.6
6.0.2-servicing.22064.6
6.0.1
- 10.0.617002
- 9.0.0-beta.25161.4
- 4.14.0-3.25176.5
- 4.14.0-3.25176.5
- 4.14.0-3.25176.5
- 4.14.0-3.25176.5
- 4.14.0-3.25176.5
- 4.14.0-3.25176.5
- 4.14.0-3.25176.5
- 4.14.0-3.25176.5
- 4.14.0-3.25176.5
- 4.14.0-3.25176.5
- 4.14.0-3.25176.5
- 4.14.0-3.25176.5
- 4.14.0-3.25176.5
- 4.14.0-3.25176.5
- 4.14.0-3.25176.5
- 4.14.0-3.25176.5
- 4.14.0-3.25176.5
- 4.14.0-3.25176.5
- 4.14.0-3.25176.5
+ 10.0.620402
+ 9.0.0-beta.25204.5
+ 5.0.0-1.25209.6
+ 5.0.0-1.25209.6
+ 5.0.0-1.25209.6
+ 5.0.0-1.25207.1
+ 5.0.0-1.25209.6
+ 5.0.0-1.25209.6
+ 5.0.0-1.25209.6
+ 5.0.0-1.25209.6
+ 5.0.0-1.25209.6
+ 5.0.0-1.25209.6
+ 5.0.0-1.25209.6
+ 5.0.0-1.25209.6
+ 5.0.0-1.25209.6
+ 5.0.0-1.25209.6
+ 5.0.0-1.25209.6
+ 5.0.0-1.25209.6
+ 5.0.0-1.25209.6
+ 5.0.0-1.25209.6
+ 5.0.0-1.25209.6
+ 5.0.0-1.25209.6
+ 5.0.0-1.25209.6
+ 5.0.0-1.25209.6
+ 5.0.0-1.25209.6
- IDE0005
+ $(NoWarn);IDE0005
+
+
+ $(NoWarn);0436
@@ -33,14 +39,7 @@
Now we aren't sure why this exposes a "flaky" issue; however, to workaround the break we pin the following packages to workaround the issue.
-->
-
-
-
+
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/OpenDocumentGenerator.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/OpenDocumentGenerator.cs
index 6501d1f50ac..d58b352a97b 100644
--- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/OpenDocumentGenerator.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/OpenDocumentGenerator.cs
@@ -6,10 +6,9 @@
using System.Collections.Immutable;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
-using Microsoft.AspNetCore.Razor.Utilities;
using Microsoft.CodeAnalysis.Razor.Logging;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
+using Microsoft.CodeAnalysis.Razor.Utilities;
using Microsoft.CodeAnalysis.Razor.Workspaces;
namespace Microsoft.AspNetCore.Razor.LanguageServer;
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectContexts/ProjectContextsEndpoint.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectContexts/ProjectContextsEndpoint.cs
index 7be2146e3a7..4d34108c12b 100644
--- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectContexts/ProjectContextsEndpoint.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectContexts/ProjectContextsEndpoint.cs
@@ -7,7 +7,6 @@
using Microsoft.AspNetCore.Razor.LanguageServer.EndpointContracts;
using Microsoft.AspNetCore.Razor.LanguageServer.Hosting;
using Microsoft.CodeAnalysis.Razor.Protocol;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.AspNetCore.Razor.LanguageServer.ProjectContexts;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IDocumentContextFactory.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/IDocumentContextFactory.cs
similarity index 77%
rename from src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IDocumentContextFactory.cs
rename to src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/IDocumentContextFactory.cs
index a29c943da58..5d76c6d1f23 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IDocumentContextFactory.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/IDocumentContextFactory.cs
@@ -3,9 +3,9 @@
using System;
using System.Diagnostics.CodeAnalysis;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
+using Microsoft.CodeAnalysis.Razor.ProjectSystem;
-namespace Microsoft.CodeAnalysis.Razor.ProjectSystem;
+namespace Microsoft.AspNetCore.Razor.LanguageServer.ProjectSystem;
internal interface IDocumentContextFactory
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IDocumentContextFactoryExtensions.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/IDocumentContextFactoryExtensions.cs
similarity index 87%
rename from src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IDocumentContextFactoryExtensions.cs
rename to src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/IDocumentContextFactoryExtensions.cs
index 4843df493cf..7e8a3a3bfcd 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IDocumentContextFactoryExtensions.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/IDocumentContextFactoryExtensions.cs
@@ -3,9 +3,9 @@
using System;
using System.Diagnostics.CodeAnalysis;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
+using Microsoft.CodeAnalysis.Razor.ProjectSystem;
-namespace Microsoft.CodeAnalysis.Razor.ProjectSystem;
+namespace Microsoft.AspNetCore.Razor.LanguageServer.ProjectSystem;
internal static class IDocumentContextFactoryExtensions
{
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/IProjectSnapshotManagerExtensions.SolutionQueryOperations.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/IProjectSnapshotManagerExtensions.SolutionQueryOperations.cs
index e1d1304794e..30e2c0072fb 100644
--- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/IProjectSnapshotManagerExtensions.SolutionQueryOperations.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/IProjectSnapshotManagerExtensions.SolutionQueryOperations.cs
@@ -5,7 +5,6 @@
using System.Collections.Immutable;
using System.Linq;
using Microsoft.AspNetCore.Razor.PooledObjects;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
namespace Microsoft.AspNetCore.Razor.LanguageServer.ProjectSystem;
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/IProjectSnapshotManagerExtensions.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/IProjectSnapshotManagerExtensions.cs
index c17926d7a5c..987c0731a03 100644
--- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/IProjectSnapshotManagerExtensions.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/IProjectSnapshotManagerExtensions.cs
@@ -5,11 +5,10 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Microsoft.AspNetCore.Razor.PooledObjects;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
-using Microsoft.AspNetCore.Razor.Utilities;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.CodeAnalysis.Razor.Logging;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
+using Microsoft.CodeAnalysis.Razor.Utilities;
namespace Microsoft.AspNetCore.Razor.LanguageServer.ProjectSystem;
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/IRazorProjectService.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/IRazorProjectService.cs
index a35fb0e58ac..ea039542057 100644
--- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/IRazorProjectService.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/IRazorProjectService.cs
@@ -4,9 +4,6 @@
using System.Collections.Immutable;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.AspNetCore.Razor.Language;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
-using Microsoft.AspNetCore.Razor.Serialization;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.AspNetCore.Razor.LanguageServer.ProjectSystem;
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/LspProjectSnapshotManager.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/LspProjectSnapshotManager.cs
index d1299b8a109..8a6a55312d3 100644
--- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/LspProjectSnapshotManager.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/LspProjectSnapshotManager.cs
@@ -1,8 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
-using Microsoft.AspNetCore.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Logging;
+using Microsoft.CodeAnalysis.Razor.ProjectEngineHost;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Workspaces;
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/MiscFilesProject.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/MiscFilesProject.cs
index cef0f40f76f..0c748cbbc67 100644
--- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/MiscFilesProject.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/MiscFilesProject.cs
@@ -4,10 +4,9 @@
using System;
using System.IO;
using Microsoft.AspNetCore.Razor.Language;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
-using Microsoft.AspNetCore.Razor.Utilities;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
+using Microsoft.CodeAnalysis.Razor.Utilities;
using Microsoft.Extensions.Internal;
namespace Microsoft.AspNetCore.Razor.LanguageServer.ProjectSystem;
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/RazorProjectService.TestAccessor.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/RazorProjectService.TestAccessor.cs
index a0312a283c8..88477f01ae2 100644
--- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/RazorProjectService.TestAccessor.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/RazorProjectService.TestAccessor.cs
@@ -1,12 +1,10 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
-using System.Collections.Immutable;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
-using Microsoft.AspNetCore.Razor.Serialization;
+using Microsoft.CodeAnalysis.Razor.ProjectSystem;
namespace Microsoft.AspNetCore.Razor.LanguageServer.ProjectSystem;
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/RazorProjectService.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/RazorProjectService.cs
index 989124b3779..3c72c35ee60 100644
--- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/RazorProjectService.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/RazorProjectService.cs
@@ -10,13 +10,12 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.LanguageServer.Common;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
-using Microsoft.AspNetCore.Razor.Serialization;
-using Microsoft.AspNetCore.Razor.Utilities;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.CodeAnalysis.Razor.Logging;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
+using Microsoft.CodeAnalysis.Razor.Serialization;
+using Microsoft.CodeAnalysis.Razor.Utilities;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CodeAnalysis.Text;
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorConfigurationEndpoint.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorConfigurationEndpoint.cs
index 57e8793dd49..904cf2bc67e 100644
--- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorConfigurationEndpoint.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorConfigurationEndpoint.cs
@@ -7,15 +7,17 @@
using Microsoft.AspNetCore.Razor.LanguageServer.EndpointContracts;
using Microsoft.CodeAnalysis.Razor.Logging;
using Microsoft.CodeAnalysis.Razor.Protocol;
-using Microsoft.CommonLanguageServerProtocol.Framework;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.AspNetCore.Razor.LanguageServer;
-internal class RazorConfigurationEndpoint(RazorLSPOptionsMonitor optionsMonitor, ILoggerFactory loggerFactory)
+internal sealed class RazorConfigurationEndpoint(
+ LspServices services,
+ RazorLSPOptionsMonitor optionsMonitor,
+ ILoggerFactory loggerFactory)
: IDidChangeConfigurationEndpoint, IOnInitialized
{
- private readonly RazorLSPOptionsMonitor _optionsMonitor = optionsMonitor ?? throw new ArgumentNullException(nameof(optionsMonitor));
+ private readonly LspServices _services = services;
+ private readonly RazorLSPOptionsMonitor _optionsMonitor = optionsMonitor;
private readonly ILogger _logger = loggerFactory.GetOrCreateLogger();
public bool MutatesSolutionState => true;
@@ -27,9 +29,9 @@ public async Task HandleNotificationAsync(DidChangeConfigurationParams request,
await _optionsMonitor.UpdateAsync(cancellationToken).ConfigureAwait(false);
}
- public async Task OnInitializedAsync(ILspServices services, CancellationToken cancellationToken)
+ public async Task OnInitializedAsync(CancellationToken cancellationToken)
{
- var capabilitiesService = services.GetRequiredService();
+ var capabilitiesService = _services.GetRequiredService();
var clientCapabilities = capabilitiesService.ClientCapabilities;
if (clientCapabilities.Workspace?.Configuration == true)
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorFileSystemWatcher.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorFileSystemWatcher.cs
index 34d78ec5b5f..47f9973c20a 100644
--- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorFileSystemWatcher.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorFileSystemWatcher.cs
@@ -2,7 +2,7 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.ComponentModel;
-using System.IO;
+using FileSystemWatcher = System.IO.FileSystemWatcher;
namespace Microsoft.AspNetCore.Razor.LanguageServer;
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorInitializeEndpoint.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorInitializeEndpoint.cs
index 158e76d4f86..1a21274f58f 100644
--- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorInitializeEndpoint.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorInitializeEndpoint.cs
@@ -4,10 +4,9 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.LanguageServer.EndpointContracts;
-using Microsoft.AspNetCore.Razor.Telemetry;
+using Microsoft.CodeAnalysis.Razor.Telemetry;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CommonLanguageServerProtocol.Framework;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.AspNetCore.Razor.LanguageServer;
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorInitializedEndpoint.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorInitializedEndpoint.cs
index 277533d056c..1af32d0bfeb 100644
--- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorInitializedEndpoint.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorInitializedEndpoint.cs
@@ -7,7 +7,6 @@
using Microsoft.AspNetCore.Razor.LanguageServer.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Protocol;
using Microsoft.CommonLanguageServerProtocol.Framework;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.AspNetCore.Razor.LanguageServer;
@@ -22,7 +21,7 @@ public async Task HandleNotificationAsync(InitializedParams request, RazorReques
foreach (var onStartedItem in onStartedItems)
{
- await onStartedItem.OnInitializedAsync(requestContext.LspServices, cancellationToken).ConfigureAwait(false);
+ await onStartedItem.OnInitializedAsync(cancellationToken).ConfigureAwait(false);
}
}
}
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorLanguageServer.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorLanguageServer.cs
index dda62959a52..543d83b988b 100644
--- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorLanguageServer.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorLanguageServer.cs
@@ -24,7 +24,6 @@
using Microsoft.AspNetCore.Razor.LanguageServer.Refactoring;
using Microsoft.AspNetCore.Razor.LanguageServer.SignatureHelp;
using Microsoft.AspNetCore.Razor.LanguageServer.WrapWithTag;
-using Microsoft.AspNetCore.Razor.Telemetry;
using Microsoft.CodeAnalysis.Razor.AutoInsert;
using Microsoft.CodeAnalysis.Razor.FoldingRanges;
using Microsoft.CodeAnalysis.Razor.Formatting;
@@ -32,6 +31,7 @@
using Microsoft.CodeAnalysis.Razor.Logging;
using Microsoft.CodeAnalysis.Razor.Protocol.DocumentSymbols;
using Microsoft.CodeAnalysis.Razor.Rename;
+using Microsoft.CodeAnalysis.Razor.Telemetry;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CommonLanguageServerProtocol.Framework;
using Microsoft.Extensions.DependencyInjection;
@@ -82,7 +82,7 @@ public void Dispose()
_jsonRpc.Dispose();
}
- private static ILspLogger CreateILspLogger(ILoggerFactory loggerFactory, ITelemetryReporter telemetryReporter)
+ private static ClaspLoggingBridge CreateILspLogger(ILoggerFactory loggerFactory, ITelemetryReporter telemetryReporter)
{
return new ClaspLoggingBridge(loggerFactory, telemetryReporter);
}
@@ -127,40 +127,37 @@ protected override ILspServices ConstructLspServices()
services.AddLifeCycleServices(this, _clientConnection, _lspServerActivationTracker);
- services.AddSemanticTokensServices(featureOptions);
+ services.AddSemanticTokensServices();
services.AddDocumentManagementServices();
- services.AddFormattingServices(featureOptions);
+ services.AddFormattingServices();
services.AddOptionsServices(_lspOptions);
- services.AddTextDocumentServices(featureOptions);
+ services.AddTextDocumentServices();
- if (!featureOptions.UseRazorCohostServer)
- {
- // Diagnostics
- services.AddDiagnosticServices();
+ // Diagnostics
+ services.AddDiagnosticServices();
- services.AddCodeActionsServices();
+ services.AddCodeActionsServices();
- // Completion
- services.AddCompletionServices();
+ // Completion
+ services.AddCompletionServices();
- // Auto insert
- services.AddSingleton();
- services.AddSingleton();
+ // Auto insert
+ services.AddSingleton();
+ services.AddSingleton();
- services.AddSingleton();
+ services.AddSingleton();
- // Folding Range Providers
- services.AddSingleton();
- services.AddSingleton();
- services.AddSingleton();
- services.AddSingleton();
- services.AddSingleton();
+ // Folding Range Providers
+ services.AddSingleton();
+ services.AddSingleton();
+ services.AddSingleton();
+ services.AddSingleton();
+ services.AddSingleton();
- services.AddSingleton();
+ services.AddSingleton();
- // Hover
- services.AddHoverServices();
- }
+ // Hover
+ services.AddHoverServices();
// Other
services.AddSingleton();
@@ -171,13 +168,13 @@ protected override ILspServices ConstructLspServices()
// Defaults: For when the caller hasn't provided them through the `configure` action.
services.TryAddSingleton();
- AddHandlers(services, featureOptions);
+ AddHandlers(services);
var lspServices = new LspServices(services);
return lspServices;
- static void AddHandlers(IServiceCollection services, LanguageServerFeatureOptions featureOptions)
+ static void AddHandlers(IServiceCollection services)
{
// Not calling AddHandler because we want to register this endpoint as an IOnInitialized too
services.AddSingleton();
@@ -185,40 +182,37 @@ static void AddHandlers(IServiceCollection services, LanguageServerFeatureOption
// Transient because it should only be used once and I'm hoping it doesn't stick around.
services.AddTransient(sp => sp.GetRequiredService());
- if (!featureOptions.UseRazorCohostServer)
- {
- services.AddHandlerWithCapabilities();
+ services.AddHandlerWithCapabilities();
- services.AddSingleton();
- services.AddHandlerWithCapabilities();
+ services.AddSingleton();
+ services.AddHandlerWithCapabilities();
- services.AddSingleton();
- services.AddHandlerWithCapabilities();
+ services.AddSingleton();
+ services.AddHandlerWithCapabilities();
- services.AddHandlerWithCapabilities();
- services.AddHandlerWithCapabilities();
- services.AddHandlerWithCapabilities();
- services.AddHandlerWithCapabilities();
- services.AddHandlerWithCapabilities();
+ services.AddHandlerWithCapabilities();
+ services.AddHandlerWithCapabilities();
+ services.AddHandlerWithCapabilities();
+ services.AddHandlerWithCapabilities();
+ services.AddHandlerWithCapabilities();
- services.AddSingleton();
- services.AddHandlerWithCapabilities();
- services.AddHandler();
+ services.AddSingleton();
+ services.AddHandlerWithCapabilities();
+ services.AddHandler();
- services.AddHandlerWithCapabilities();
- services.AddSingleton();
+ services.AddHandlerWithCapabilities();
+ services.AddSingleton();
- services.AddHandlerWithCapabilities();
- services.AddHandler();
+ services.AddHandlerWithCapabilities();
+ services.AddHandler();
- services.AddHandlerWithCapabilities();
+ services.AddHandlerWithCapabilities();
- services.AddHandlerWithCapabilities();
+ services.AddHandlerWithCapabilities();
- services.AddHandlerWithCapabilities();
- services.AddHandler();
- services.AddHandler();
- }
+ services.AddHandlerWithCapabilities();
+ services.AddHandler();
+ services.AddHandler();
services.AddHandler();
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorRequestContextFactory.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorRequestContextFactory.cs
index f89b213204c..245311ec7df 100644
--- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorRequestContextFactory.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorRequestContextFactory.cs
@@ -5,54 +5,55 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.LanguageServer.EndpointContracts;
+using Microsoft.AspNetCore.Razor.LanguageServer.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Logging;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CommonLanguageServerProtocol.Framework;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.AspNetCore.Razor.LanguageServer;
-internal class RazorRequestContextFactory(ILspServices lspServices) : AbstractRequestContextFactory
+internal sealed class RazorRequestContextFactory(
+ LspServices lspServices,
+ IDocumentContextFactory documentContextFactory,
+ ILoggerFactory loggerFactory) : AbstractRequestContextFactory
{
- private readonly ILspServices _lspServices = lspServices;
+ private readonly LspServices _lspServices = lspServices;
+ private readonly IDocumentContextFactory _documentContextFactory = documentContextFactory;
+ private readonly ILogger _logger = loggerFactory.GetOrCreateLogger();
public override Task CreateRequestContextAsync(IQueueItem queueItem, IMethodHandler methodHandler, TRequestParams @params, CancellationToken cancellationToken)
{
- var logger = _lspServices.GetRequiredService().GetOrCreateLogger();
-
DocumentContext? documentContext = null;
- var textDocumentHandler = methodHandler as ITextDocumentIdentifierHandler;
-
Uri? uri = null;
- var documentContextFactory = _lspServices.GetRequiredService();
- if (textDocumentHandler is not null)
+
+ if (methodHandler is ITextDocumentIdentifierHandler textDocumentHandler)
{
if (textDocumentHandler is ITextDocumentIdentifierHandler tdiHandler)
{
var textDocumentIdentifier = tdiHandler.GetTextDocumentIdentifier(@params);
uri = textDocumentIdentifier.Uri;
- logger.LogDebug($"Trying to create DocumentContext for {queueItem.MethodName} for {textDocumentIdentifier.GetProjectContext()?.Id ?? "(no project context)"} for {uri}");
+ _logger.LogDebug($"Trying to create DocumentContext for {queueItem.MethodName} for {textDocumentIdentifier.GetProjectContext()?.Id ?? "(no project context)"} for {uri}");
- documentContextFactory.TryCreate(textDocumentIdentifier, out documentContext);
+ _documentContextFactory.TryCreate(textDocumentIdentifier, out documentContext);
}
else if (textDocumentHandler is ITextDocumentIdentifierHandler uriHandler)
{
uri = uriHandler.GetTextDocumentIdentifier(@params);
- logger.LogDebug($"Trying to create DocumentContext for {queueItem.MethodName}, with no project context, for {uri}");
+ _logger.LogDebug($"Trying to create DocumentContext for {queueItem.MethodName}, with no project context, for {uri}");
- documentContextFactory.TryCreate(uri, out documentContext);
+ _documentContextFactory.TryCreate(uri, out documentContext);
}
else
{
- throw new NotImplementedException();
+ return Assumed.Unreachable>();
}
if (documentContext is null)
{
- logger.LogWarning($"Could not create a document context for {queueItem.MethodName} for {uri}. Endpoint may crash later if it calls GetRequiredDocumentContext.");
+ _logger.LogWarning($"Could not create a document context for {queueItem.MethodName} for {uri}. Endpoint may crash later if it calls GetRequiredDocumentContext.");
}
}
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Refactoring/RenameEndpoint.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Refactoring/RenameEndpoint.cs
index fa8fc0c94a6..b615215bd5b 100644
--- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Refactoring/RenameEndpoint.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Refactoring/RenameEndpoint.cs
@@ -13,7 +13,6 @@
using Microsoft.CodeAnalysis.Razor.Protocol;
using Microsoft.CodeAnalysis.Razor.Rename;
using Microsoft.CodeAnalysis.Razor.Workspaces;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.AspNetCore.Razor.LanguageServer.Refactoring;
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RemoteProjectItem.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RemoteProjectItem.cs
index e94428bb9ce..7d63758175b 100644
--- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RemoteProjectItem.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RemoteProjectItem.cs
@@ -9,11 +9,11 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer;
internal sealed class RemoteProjectItem : RazorProjectItem
{
- public RemoteProjectItem(string filePath, string physicalPath, string? fileKind)
+ public RemoteProjectItem(string filePath, string physicalPath, RazorFileKind? fileKind)
{
FilePath = filePath;
PhysicalPath = physicalPath;
- FileKind = fileKind ?? FileKinds.GetFileKindFromFilePath(FilePath);
+ FileKind = fileKind ?? FileKinds.GetFileKindFromPath(FilePath);
RelativePhysicalPath = FilePath.StartsWith('/')
? FilePath[1..]
: FilePath;
@@ -25,7 +25,7 @@ public RemoteProjectItem(string filePath, string physicalPath, string? fileKind)
public override string PhysicalPath { get; }
- public override string FileKind { get; }
+ public override RazorFileKind FileKind { get; }
public override string RelativePhysicalPath { get; }
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RemoteRazorProjectFileSystem.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RemoteRazorProjectFileSystem.cs
index 34077b711aa..d83f7de41a5 100644
--- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RemoteRazorProjectFileSystem.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RemoteRazorProjectFileSystem.cs
@@ -4,10 +4,10 @@
using System;
using System.Collections.Generic;
using System.IO;
-using System.Linq;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Utilities;
using Microsoft.CodeAnalysis.Razor;
+using Microsoft.CodeAnalysis.Razor.Utilities;
namespace Microsoft.AspNetCore.Razor.LanguageServer;
@@ -25,7 +25,7 @@ public RemoteRazorProjectFileSystem(string root)
public override IEnumerable EnumerateItems(string basePath)
=> throw new NotSupportedException();
- public override RazorProjectItem GetItem(string path, string? fileKind)
+ public override RazorProjectItem GetItem(string path, RazorFileKind? fileKind)
{
ArgHelper.ThrowIfNull(path);
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Semantic/SemanticTokensRangeEndpoint.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Semantic/SemanticTokensRangeEndpoint.cs
index 5f3e72b28dc..fe2148bc212 100644
--- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Semantic/SemanticTokensRangeEndpoint.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Semantic/SemanticTokensRangeEndpoint.cs
@@ -6,11 +6,9 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.LanguageServer.EndpointContracts;
using Microsoft.AspNetCore.Razor.LanguageServer.Hosting;
-using Microsoft.AspNetCore.Razor.Telemetry;
using Microsoft.CodeAnalysis.Razor.SemanticTokens;
+using Microsoft.CodeAnalysis.Razor.Telemetry;
using Microsoft.CodeAnalysis.Razor.Workspaces;
-using Microsoft.CodeAnalysis.Razor.Workspaces.Telemetry;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.AspNetCore.Razor.LanguageServer.Semantic;
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Semantic/Services/LSPCSharpSemanticTokensProvider.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Semantic/Services/LSPCSharpSemanticTokensProvider.cs
index 982197f8e19..3848cc5b75d 100644
--- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Semantic/Services/LSPCSharpSemanticTokensProvider.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Semantic/Services/LSPCSharpSemanticTokensProvider.cs
@@ -14,8 +14,6 @@
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CodeAnalysis.Razor.Workspaces.Protocol.SemanticTokens;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
-using Range = Microsoft.VisualStudio.LanguageServer.Protocol.Range;
namespace Microsoft.AspNetCore.Razor.LanguageServer.Semantic;
@@ -33,7 +31,7 @@ internal class LSPCSharpSemanticTokensProvider(LanguageServerFeatureOptions lang
{
var documentVersion = documentContext.Snapshot.Version;
- using var _ = ListPool.GetPooledObject(out var csharpRangeList);
+ using var _ = ListPool.GetPooledObject(out var csharpRangeList);
foreach (var span in csharpSpans)
{
csharpRangeList.Add(span.ToRange());
@@ -55,7 +53,7 @@ internal class LSPCSharpSemanticTokensProvider(LanguageServerFeatureOptions lang
// Likely the server doesn't support the new endpoint, fallback to the original one
if (csharpResponse?.Tokens is null && csharpRanges.Length > 1)
{
- var minimalRange = VsLspFactory.CreateRange(csharpRanges[0].Start, csharpRanges[^1].End);
+ var minimalRange = LspFactory.CreateRange(csharpRanges[0].Start, csharpRanges[^1].End);
var newParams = new ProvideSemanticTokensRangesParams(
parameter.TextDocument,
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/SignatureHelp/SignatureHelpEndpoint.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/SignatureHelp/SignatureHelpEndpoint.cs
index e7c488771e3..b400757fd64 100644
--- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/SignatureHelp/SignatureHelpEndpoint.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/SignatureHelp/SignatureHelpEndpoint.cs
@@ -10,12 +10,9 @@
using Microsoft.CodeAnalysis.Razor.Logging;
using Microsoft.CodeAnalysis.Razor.Protocol;
using Microsoft.CodeAnalysis.Razor.Workspaces;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.AspNetCore.Razor.LanguageServer.SignatureHelp;
-using SignatureHelp = VisualStudio.LanguageServer.Protocol.SignatureHelp;
-
[RazorLanguageServerEndpoint(Methods.TextDocumentSignatureHelpName)]
internal sealed class SignatureHelpEndpoint(
LanguageServerFeatureOptions languageServerFeatureOptions,
@@ -23,7 +20,7 @@ internal sealed class SignatureHelpEndpoint(
IClientConnection clientConnection,
RazorLSPOptionsMonitor optionsMonitor,
ILoggerFactory loggerProvider)
- : AbstractRazorDelegatingEndpoint(
+ : AbstractRazorDelegatingEndpoint(
languageServerFeatureOptions,
documentMappingService,
clientConnection,
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/SpellCheck/DocumentSpellCheckEndpoint.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/SpellCheck/DocumentSpellCheckEndpoint.cs
index 3cd304c989a..c2cfa6a59ee 100644
--- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/SpellCheck/DocumentSpellCheckEndpoint.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/SpellCheck/DocumentSpellCheckEndpoint.cs
@@ -6,7 +6,6 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.LanguageServer.EndpointContracts;
using Microsoft.CodeAnalysis.Razor.SpellCheck;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.AspNetCore.Razor.LanguageServer.SpellCheck;
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/SpellCheck/LspCSharpSpellCheckRangeProvider.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/SpellCheck/LspCSharpSpellCheckRangeProvider.cs
index f0181c75da7..7e92261ae77 100644
--- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/SpellCheck/LspCSharpSpellCheckRangeProvider.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/SpellCheck/LspCSharpSpellCheckRangeProvider.cs
@@ -15,7 +15,6 @@
using Microsoft.CodeAnalysis.Razor.Protocol;
using Microsoft.CodeAnalysis.Razor.SpellCheck;
using Microsoft.CodeAnalysis.Razor.Workspaces;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.AspNetCore.Razor.LanguageServer.SpellCheck;
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/SpellCheck/WorkspaceSpellCheckEndpoint.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/SpellCheck/WorkspaceSpellCheckEndpoint.cs
index ae7a2195b0f..2b7ed9b8bfa 100644
--- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/SpellCheck/WorkspaceSpellCheckEndpoint.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/SpellCheck/WorkspaceSpellCheckEndpoint.cs
@@ -6,7 +6,6 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.LanguageServer.EndpointContracts;
using Microsoft.AspNetCore.Razor.Threading;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.AspNetCore.Razor.LanguageServer.SpellCheck;
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/WorkspaceDiagnosticsRefresher.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/WorkspaceDiagnosticsRefresher.cs
index bde94393175..2693db34c80 100644
--- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/WorkspaceDiagnosticsRefresher.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/WorkspaceDiagnosticsRefresher.cs
@@ -5,11 +5,10 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.LanguageServer.Hosting;
-using Microsoft.AspNetCore.Razor.Utilities;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Protocol;
+using Microsoft.CodeAnalysis.Razor.Utilities;
using Microsoft.CodeAnalysis.Razor.Workspaces;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
using Microsoft.VisualStudio.Threading;
namespace Microsoft.AspNetCore.Razor.LanguageServer;
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/WorkspaceRootPathWatcher.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/WorkspaceRootPathWatcher.cs
index d30f740078f..bed642cff5e 100644
--- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/WorkspaceRootPathWatcher.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/WorkspaceRootPathWatcher.cs
@@ -10,11 +10,11 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.LanguageServer.ProjectSystem;
using Microsoft.AspNetCore.Razor.PooledObjects;
-using Microsoft.AspNetCore.Razor.Utilities;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.CodeAnalysis.Razor.Logging;
+using Microsoft.CodeAnalysis.Razor.Utilities;
using Microsoft.CodeAnalysis.Razor.Workspaces;
-using Microsoft.CommonLanguageServerProtocol.Framework;
+using FileSystemWatcher = System.IO.FileSystemWatcher;
namespace Microsoft.AspNetCore.Razor.LanguageServer;
@@ -160,7 +160,7 @@ private async ValueTask ProcessBatchAsync(ImmutableArray<(string, RazorFileChang
}
}
- public async Task OnInitializedAsync(ILspServices services, CancellationToken cancellationToken)
+ public async Task OnInitializedAsync(CancellationToken cancellationToken)
{
// Initialized request, this occurs once the server and client have agreed on what sort of features they both support. It only happens once.
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/WorkspaceSemanticTokensRefreshNotifier.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/WorkspaceSemanticTokensRefreshNotifier.cs
index b0930093fa7..a72a3b7c8b9 100644
--- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/WorkspaceSemanticTokensRefreshNotifier.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/WorkspaceSemanticTokensRefreshNotifier.cs
@@ -5,9 +5,8 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.LanguageServer.Hosting;
-using Microsoft.AspNetCore.Razor.Utilities;
using Microsoft.CodeAnalysis.Razor.Protocol;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
+using Microsoft.CodeAnalysis.Razor.Utilities;
using Microsoft.VisualStudio.Threading;
namespace Microsoft.AspNetCore.Razor.LanguageServer;
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/WrapWithTag/WrapWithTagEndpoint.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/WrapWithTag/WrapWithTagEndpoint.cs
index 2b2df489b6b..7b4e9f0dd5f 100644
--- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/WrapWithTag/WrapWithTagEndpoint.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/WrapWithTag/WrapWithTagEndpoint.cs
@@ -12,7 +12,6 @@
using Microsoft.CodeAnalysis.Razor.Logging;
using Microsoft.CodeAnalysis.Razor.Protocol;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.AspNetCore.Razor.LanguageServer.WrapWithTag;
@@ -41,19 +40,31 @@ public TextDocumentIdentifier GetTextDocumentIdentifier(WrapWithTagParams reques
cancellationToken.ThrowIfCancellationRequested();
var codeDocument = await documentContext.GetCodeDocumentAsync(cancellationToken).ConfigureAwait(false);
- if (codeDocument.IsUnsupported())
- {
- _logger.LogWarning($"Failed to retrieve generated output for document {request.TextDocument.Uri}.");
- return null;
- }
+ var sourceText = codeDocument.Source.Text;
- var sourceText = await documentContext.GetSourceTextAsync(cancellationToken).ConfigureAwait(false);
if (request.Range?.Start is not { } start ||
!sourceText.TryGetAbsoluteIndex(start, out var hostDocumentIndex))
{
return null;
}
+ // First thing we do is make sure we start at a non-whitespace character. This is important because in some
+ // situations the whitespace can be technically C#, but move one character to the right and it's HTML. eg
+ //
+ // @if (true) {
+ // |
+ // }
+ //
+ // Limiting this to only whitespace on the same line, as it's not clear what user expectation would be otherwise.
+ var requestSpan = sourceText.GetTextSpan(request.Range);
+ if (sourceText.TryGetFirstNonWhitespaceOffset(requestSpan, out var offset, out var newLineCount) &&
+ newLineCount == 0)
+ {
+ request.Range.Start.Character += offset;
+ requestSpan = sourceText.GetTextSpan(request.Range);
+ hostDocumentIndex += offset;
+ }
+
// Since we're at the start of the selection, lets prefer the language to the right of the cursor if possible.
// That way with the following situation:
//
@@ -89,13 +100,12 @@ public TextDocumentIdentifier GetTextDocumentIdentifier(WrapWithTagParams reques
// [|@currentCount|]
var tree = await documentContext.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);
- var requestSpan = sourceText.GetTextSpan(request.Range);
var node = tree.Root.FindNode(requestSpan, includeWhitespace: false, getInnermostNodeForTie: true);
if (node?.FirstAncestorOrSelf() is { Parent: CSharpCodeBlockSyntax codeBlock } &&
- (requestSpan == codeBlock.FullSpan || requestSpan.Length == 0))
+ (requestSpan == codeBlock.Span || requestSpan.Length == 0))
{
// Pretend we're in Html so the rest of the logic can continue
- request.Range = sourceText.GetRange(codeBlock.FullSpan);
+ request.Range = sourceText.GetRange(codeBlock.Span);
languageKind = RazorLanguageKind.Html;
}
}
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/WrapWithTag/WrapWithTagParams.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/WrapWithTag/WrapWithTagParams.cs
index 41700e4a53e..6bf162f8f1a 100644
--- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/WrapWithTag/WrapWithTagParams.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/WrapWithTag/WrapWithTagParams.cs
@@ -2,7 +2,6 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Text.Json.Serialization;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.AspNetCore.Razor.LanguageServer.WrapWithTag;
@@ -21,7 +20,7 @@ internal class WrapWithTagParams(TextDocumentIdentifier textDocument)
/// Gets or sets the selection range to be wrapped.
///
[JsonPropertyName("_vs_range")]
- public Range? Range { get; set; }
+ public LspRange? Range { get; set; }
///
/// Gets or sets the wrapping tag name.
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/WrapWithTag/WrapWithTagResponse.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/WrapWithTag/WrapWithTagResponse.cs
index 1f580332c7d..5d9eb3d1f6c 100644
--- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/WrapWithTag/WrapWithTagResponse.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/WrapWithTag/WrapWithTagResponse.cs
@@ -2,7 +2,6 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Text.Json.Serialization;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.AspNetCore.Razor.LanguageServer.WrapWithTag;
@@ -15,7 +14,7 @@ internal class WrapWithTagResponse
/// Gets or sets the range of the wrapping tag.
///
[JsonPropertyName("_vs_tagRange")]
- public Range? TagRange { get; set; }
+ public LspRange? TagRange { get; set; }
///
/// Gets or sets the text edits.
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AbstractFilePathService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AbstractFilePathService.cs
index 4e6efb7477f..4171de809e7 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AbstractFilePathService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AbstractFilePathService.cs
@@ -4,7 +4,7 @@
using System;
using System.Diagnostics;
using System.Text;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
+using Microsoft.CodeAnalysis.Razor.ProjectSystem;
namespace Microsoft.CodeAnalysis.Razor.Workspaces;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/AutoClosingTagOnAutoInsertProvider.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/AutoClosingTagOnAutoInsertProvider.cs
index c532fa188c6..6c3e0fe6e5c 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/AutoClosingTagOnAutoInsertProvider.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/AutoClosingTagOnAutoInsertProvider.cs
@@ -7,7 +7,7 @@
using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.Syntax;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
+using Microsoft.CodeAnalysis.Text;
using RazorSyntaxNode = Microsoft.AspNetCore.Razor.Language.Syntax.SyntaxNode;
@@ -59,7 +59,7 @@ public bool TryResolveInsertion(
if (tagNameWithClosingBehavior.AutoClosingBehavior == AutoClosingBehavior.EndTag)
{
var formatForEndTag = InsertTextFormat.Snippet;
- var editForEndTag = VsLspFactory.CreateTextEdit(position, $"$0{tagNameWithClosingBehavior.TagName}>");
+ var editForEndTag = LspFactory.CreateTextEdit(position, $"$0{tagNameWithClosingBehavior.TagName}>");
autoInsertEdit = new()
{
@@ -76,7 +76,7 @@ public bool TryResolveInsertion(
// Need to replace the `>` with ' />$0' or '/>$0' depending on if there's prefixed whitespace.
var insertionText = char.IsWhiteSpace(sourceText[afterCloseAngleIndex - 2]) ? "/" : " /";
- var edit = VsLspFactory.CreateTextEdit(position.Line, position.Character - 1, insertionText);
+ var edit = LspFactory.CreateTextEdit(position.Line, position.Character - 1, insertionText);
autoInsertEdit = new()
{
@@ -153,10 +153,9 @@ private static bool TryGetTagHelperAutoClosingBehavior(TagHelperBinding bindingR
{
var resolvedTagStructure = TagStructure.Unspecified;
- foreach (var descriptor in bindingResult.Descriptors)
+ foreach (var boundRulesInfo in bindingResult.AllBoundRules)
{
- var tagMatchingRules = bindingResult.Mappings[descriptor];
- foreach (var tagMatchingRule in tagMatchingRules)
+ foreach (var tagMatchingRule in boundRulesInfo.Rules)
{
if (tagMatchingRule.TagStructure == TagStructure.Unspecified)
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/AutoInsertService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/AutoInsertService.cs
index d6b6e3e3a47..4e4291a5dea 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/AutoInsertService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/AutoInsertService.cs
@@ -8,7 +8,6 @@
using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.PooledObjects;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.AutoInsert;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/CloseTextTagOnAutoInsertProvider.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/CloseTextTagOnAutoInsertProvider.cs
index b2a791b6881..5cf92b55ea8 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/CloseTextTagOnAutoInsertProvider.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/CloseTextTagOnAutoInsertProvider.cs
@@ -7,7 +7,7 @@
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.Legacy;
using Microsoft.AspNetCore.Razor.Language.Syntax;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
+using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis.Razor.AutoInsert;
@@ -29,7 +29,7 @@ public bool TryResolveInsertion(
// This is a text tag.
var format = InsertTextFormat.Snippet;
- var edit = VsLspFactory.CreateTextEdit(position, $"$0{SyntaxConstants.TextTagName}>");
+ var edit = LspFactory.CreateTextEdit(position, $"$0{SyntaxConstants.TextTagName}>");
autoInsertEdit = new()
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/IAutoInsertService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/IAutoInsertService.cs
index 8bad0493d0f..81609e43cf6 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/IAutoInsertService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/IAutoInsertService.cs
@@ -4,7 +4,6 @@
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Razor.Language;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.AutoInsert;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/IOnAutoInsertProvider.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/IOnAutoInsertProvider.cs
index 9d1db1b72ad..12278f27fe7 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/IOnAutoInsertProvider.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/IOnAutoInsertProvider.cs
@@ -3,7 +3,6 @@
using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Razor.Language;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.AutoInsert;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/CSharp/CSharpCodeActionResolver.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/CSharp/CSharpCodeActionResolver.cs
index 46f23c36e7a..5102d51d85a 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/CSharp/CSharpCodeActionResolver.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/CSharp/CSharpCodeActionResolver.cs
@@ -8,7 +8,6 @@
using Microsoft.CodeAnalysis.Razor.Formatting;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Protocol;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.CodeActions;
@@ -47,7 +46,7 @@ public async Task ResolveAsync(
cancellationToken.ThrowIfCancellationRequested();
var csharpSourceText = await documentContext.GetCSharpSourceTextAsync(cancellationToken).ConfigureAwait(false);
- var csharpTextChanges = textDocumentEdit.Edits.SelectAsArray(csharpSourceText.GetTextChange);
+ var csharpTextChanges = textDocumentEdit.Edits.SelectAsArray(e => csharpSourceText.GetTextChange((TextEdit)e));
// Remaps the text edits from the generated C# to the razor file,
// as well as applying appropriate formatting.
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/CSharp/ICSharpCodeActionResolver.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/CSharp/ICSharpCodeActionResolver.cs
index 36d4ae4a03a..2dba2d424c4 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/CSharp/ICSharpCodeActionResolver.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/CSharp/ICSharpCodeActionResolver.cs
@@ -4,7 +4,6 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.CodeActions;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/CSharp/TypeAccessibilityCodeActionProvider.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/CSharp/TypeAccessibilityCodeActionProvider.cs
index d60297bbc00..1163f0a4aba 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/CSharp/TypeAccessibilityCodeActionProvider.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/CSharp/TypeAccessibilityCodeActionProvider.cs
@@ -19,9 +19,6 @@
using Microsoft.CodeAnalysis.Razor.Formatting;
using Microsoft.CodeAnalysis.Razor.Protocol;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
-using LspDiagnostic = Microsoft.VisualStudio.LanguageServer.Protocol.Diagnostic;
-using LspDiagnosticSeverity = Microsoft.VisualStudio.LanguageServer.Protocol.DiagnosticSeverity;
namespace Microsoft.CodeAnalysis.Razor.CodeActions;
@@ -267,7 +264,7 @@ private static RazorVSInternalCodeAction CreateFQNCodeAction(
{
var codeDocumentIdentifier = new OptionalVersionedTextDocumentIdentifier() { Uri = context.Request.TextDocument.Uri };
- var fqnTextEdit = VsLspFactory.CreateTextEdit(fqnDiagnostic.Range, fullyQualifiedName);
+ var fqnTextEdit = LspFactory.CreateTextEdit(fqnDiagnostic.Range, fullyQualifiedName);
var fqnWorkspaceEditDocumentChange = new TextDocumentEdit()
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/CSharp/UnformattedRemappingCSharpCodeActionResolver.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/CSharp/UnformattedRemappingCSharpCodeActionResolver.cs
index 56c2329a7fc..2bb8db0e6d4 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/CSharp/UnformattedRemappingCSharpCodeActionResolver.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/CSharp/UnformattedRemappingCSharpCodeActionResolver.cs
@@ -9,7 +9,6 @@
using Microsoft.CodeAnalysis.Razor.DocumentMapping;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Protocol;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.CodeActions;
@@ -49,7 +48,7 @@ public async Task ResolveAsync(
return codeAction;
}
- var textEdit = textDocumentEdit.Edits.FirstOrDefault();
+ var textEdit = (TextEdit)textDocumentEdit.Edits.FirstOrDefault();
if (textEdit is null)
{
// No text edit available
@@ -57,10 +56,6 @@ public async Task ResolveAsync(
}
var codeDocument = await documentContext.Snapshot.GetGeneratedOutputAsync(cancellationToken).ConfigureAwait(false);
- if (codeDocument.IsUnsupported())
- {
- return codeAction;
- }
if (!_documentMappingService.TryMapToHostDocumentRange(codeDocument.GetCSharpDocument(), textEdit.Range, MappingBehavior.Inclusive, out var originalRange))
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/CodeActionResolveService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/CodeActionResolveService.cs
index d842c00bed1..c66cd78dccb 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/CodeActionResolveService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/CodeActionResolveService.cs
@@ -16,7 +16,6 @@
using Microsoft.CodeAnalysis.Razor.Logging;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Protocol;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.CodeActions;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/CodeActionsService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/CodeActionsService.cs
index 920086be4c8..221da57e574 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/CodeActionsService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/CodeActionsService.cs
@@ -12,14 +12,13 @@
using Microsoft.AspNetCore.Razor;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.PooledObjects;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
using Microsoft.CodeAnalysis.Razor.CodeActions.Models;
using Microsoft.CodeAnalysis.Razor.DocumentMapping;
+using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Protocol;
using Microsoft.CodeAnalysis.Razor.Protocol.CodeActions;
using Microsoft.CodeAnalysis.Razor.Workspaces;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.CodeActions;
@@ -102,11 +101,6 @@ void ConvertCodeActionsToSumType(ImmutableArray codeA
CancellationToken cancellationToken)
{
var codeDocument = await documentSnapshot.GetGeneratedOutputAsync(cancellationToken).ConfigureAwait(false);
- if (codeDocument.IsUnsupported())
- {
- return null;
- }
-
var sourceText = codeDocument.Source.Text;
if (!sourceText.TryGetAbsoluteIndex(request.Range.Start, out var startLocation))
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Html/HtmlCodeActionProvider.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Html/HtmlCodeActionProvider.cs
index 9dc00f1a2c0..03c9f846b6c 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Html/HtmlCodeActionProvider.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Html/HtmlCodeActionProvider.cs
@@ -6,12 +6,11 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.PooledObjects;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.CodeActions.Models;
using Microsoft.CodeAnalysis.Razor.DocumentMapping;
using Microsoft.CodeAnalysis.Razor.Formatting;
+using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Protocol;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.CodeActions;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Html/HtmlCodeActionResolver.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Html/HtmlCodeActionResolver.cs
index 538b01ee571..919ed1ba1ef 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Html/HtmlCodeActionResolver.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Html/HtmlCodeActionResolver.cs
@@ -6,7 +6,6 @@
using Microsoft.CodeAnalysis.Razor.DocumentMapping;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Protocol;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.CodeActions;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Html/IHtmlCodeActionResolver.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Html/IHtmlCodeActionResolver.cs
index e6ed1800723..6bbb4e81ddc 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Html/IHtmlCodeActionResolver.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Html/IHtmlCodeActionResolver.cs
@@ -4,7 +4,6 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.CodeActions;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/ICodeActionResolveService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/ICodeActionResolveService.cs
index a93ee1a57c6..87cdfeddb5e 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/ICodeActionResolveService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/ICodeActionResolveService.cs
@@ -5,7 +5,6 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Razor.Formatting;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.CodeActions;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/ICodeActionsService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/ICodeActionsService.cs
index 59f8666c4da..72da31b3aa2 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/ICodeActionsService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/ICodeActionsService.cs
@@ -4,10 +4,9 @@
using System;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.CodeActions.Models;
+using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Protocol.CodeActions;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.CodeActions;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Models/AddUsingsCodeActionParams.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Models/AddUsingsCodeActionParams.cs
index df5b4e5d055..30726570106 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Models/AddUsingsCodeActionParams.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Models/AddUsingsCodeActionParams.cs
@@ -2,7 +2,6 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Text.Json.Serialization;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.CodeActions.Models;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Models/CodeActionExtensions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Models/CodeActionExtensions.cs
index 088fd58e3c4..6b15aab3a90 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Models/CodeActionExtensions.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Models/CodeActionExtensions.cs
@@ -7,7 +7,6 @@
using System.Text.Json.Nodes;
using Microsoft.AspNetCore.Razor;
using Microsoft.CodeAnalysis.Razor.Protocol;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.CodeActions.Models;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Models/RazorCodeActionResolutionParams.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Models/RazorCodeActionResolutionParams.cs
index d3006b3432d..ba4c49ea9f9 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Models/RazorCodeActionResolutionParams.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Models/RazorCodeActionResolutionParams.cs
@@ -4,7 +4,6 @@
using System;
using System.Text.Json.Serialization;
using Microsoft.CodeAnalysis.Razor.Protocol;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.CodeActions.Models;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Models/RazorVSInternalCodeAction.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Models/RazorVSInternalCodeAction.cs
index 40fae3fa3f5..a3ac2a7422c 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Models/RazorVSInternalCodeAction.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Models/RazorVSInternalCodeAction.cs
@@ -3,7 +3,6 @@
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.CodeActions.Models;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/AddUsingsCodeActionResolver.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/AddUsingsCodeActionResolver.cs
index fffc8ec4b55..f0dbfd42107 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/AddUsingsCodeActionResolver.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/AddUsingsCodeActionResolver.cs
@@ -6,12 +6,10 @@
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.AspNetCore.Razor.Language;
using Microsoft.CodeAnalysis.Razor.CodeActions.Models;
using Microsoft.CodeAnalysis.Razor.Formatting;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Protocol;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.CodeActions;
@@ -30,12 +28,8 @@ internal class AddUsingsCodeActionResolver : IRazorCodeActionResolver
var documentSnapshot = documentContext.Snapshot;
var codeDocument = await documentSnapshot.GetGeneratedOutputAsync(cancellationToken).ConfigureAwait(false);
- if (codeDocument.IsUnsupported())
- {
- return null;
- }
-
var codeDocumentIdentifier = new OptionalVersionedTextDocumentIdentifier() { Uri = documentContext.Uri };
+
return AddUsingsHelper.CreateAddUsingWorkspaceEdit(actionParams.Namespace, actionParams.AdditionalEdit, codeDocument, codeDocumentIdentifier);
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/CodeBlockService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/CodeBlockService.cs
index a68c3e0d896..c2c99724bc4 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/CodeBlockService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/CodeBlockService.cs
@@ -8,7 +8,6 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Razor.Formatting;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.CodeActions.Razor;
@@ -59,10 +58,10 @@ public static TextEdit[] CreateFormattedTextEdit(RazorCodeDocument code, string
codeBlockStartText = $"{Environment.NewLine}{codeBlockStartText}";
}
- var eofRange = VsLspFactory.CreateZeroWidthRange(lastCharacterLocation.LineNumber, insertCharacterIndex);
- var start = VsLspFactory.CreateTextEdit(eofRange, codeBlockStartText);
- var method = VsLspFactory.CreateTextEdit(eofRange, indentedMethod);
- var end = VsLspFactory.CreateTextEdit(eofRange, Environment.NewLine + "}");
+ var eofRange = LspFactory.CreateZeroWidthRange(lastCharacterLocation.LineNumber, insertCharacterIndex);
+ var start = LspFactory.CreateTextEdit(eofRange, codeBlockStartText);
+ var method = LspFactory.CreateTextEdit(eofRange, indentedMethod);
+ var end = LspFactory.CreateTextEdit(eofRange, Environment.NewLine + "}");
return [start, method, end];
}
@@ -92,7 +91,7 @@ public static TextEdit[] CreateFormattedTextEdit(RazorCodeDocument code, string
? closeBraceLocation.CharacterIndex
: 0;
- return [VsLspFactory.CreateTextEdit(insertLineLocation.LineIndex, insertCharacter, formattedGeneratedMethod)];
+ return [LspFactory.CreateTextEdit(insertLineLocation.LineIndex, insertCharacter, formattedGeneratedMethod)];
}
private static string FormatMethodInCodeBlock(
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/ComponentAccessibilityCodeActionProvider.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/ComponentAccessibilityCodeActionProvider.cs
index 3f2666fb432..9e9fef93798 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/ComponentAccessibilityCodeActionProvider.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/ComponentAccessibilityCodeActionProvider.cs
@@ -13,13 +13,12 @@
using Microsoft.AspNetCore.Razor.Language.Components;
using Microsoft.AspNetCore.Razor.Language.Syntax;
using Microsoft.AspNetCore.Razor.PooledObjects;
-using Microsoft.AspNetCore.Razor.Utilities;
using Microsoft.CodeAnalysis.Razor.CodeActions.Models;
using Microsoft.CodeAnalysis.Razor.CodeActions.Razor;
using Microsoft.CodeAnalysis.Razor.Protocol;
+using Microsoft.CodeAnalysis.Razor.Utilities;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.VisualStudio.Editor.Razor;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.CodeActions;
@@ -82,7 +81,7 @@ public async Task> ProvideAsync(RazorC
private static bool IsApplicableTag(IStartTagSyntaxNode startTag)
{
- if (startTag.Name.FullWidth == 0)
+ if (startTag.Name.Width == 0)
{
// Empty tag name, we shouldn't show a light bulb just to create an empty file.
return false;
@@ -133,7 +132,7 @@ private static async Task AddComponentAccessFromTagAsync(RazorCodeActionContext
var haveAddedNonQualifiedFix = false;
// First see if there are any components that match in name, but not case, without qualification
- foreach (var t in context.CodeDocument.GetTagHelperContext().TagHelpers)
+ foreach (var t in context.CodeDocument.GetRequiredTagHelperContext().TagHelpers)
{
if (t.TagMatchingRules is [{ CaseSensitive: true } rule] &&
rule.TagName.Equals(startTag.Name.Content, StringComparison.OrdinalIgnoreCase) &&
@@ -280,17 +279,17 @@ private static bool SatisfiesRules(ImmutableArray tag
private static WorkspaceEdit CreateRenameTagEdit(RazorCodeActionContext context, IStartTagSyntaxNode startTag, string newTagName)
{
- using var textEdits = new PooledArrayBuilder();
+ using var textEdits = new PooledArrayBuilder>();
var codeDocumentIdentifier = new OptionalVersionedTextDocumentIdentifier() { Uri = context.Request.TextDocument.Uri };
- var startTagTextEdit = VsLspFactory.CreateTextEdit(startTag.Name.GetRange(context.CodeDocument.Source), newTagName);
+ var startTagTextEdit = LspFactory.CreateTextEdit(startTag.Name.GetRange(context.CodeDocument.Source), newTagName);
textEdits.Add(startTagTextEdit);
var endTag = (startTag.Parent as MarkupElementSyntax)?.EndTag;
if (endTag != null)
{
- var endTagTextEdit = VsLspFactory.CreateTextEdit(endTag.Name.GetRange(context.CodeDocument.Source), newTagName);
+ var endTagTextEdit = LspFactory.CreateTextEdit(endTag.Name.GetRange(context.CodeDocument.Source), newTagName);
textEdits.Add(endTagTextEdit);
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/CreateComponentCodeActionResolver.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/CreateComponentCodeActionResolver.cs
index 245a6863414..9809f966c58 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/CreateComponentCodeActionResolver.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/CreateComponentCodeActionResolver.cs
@@ -16,7 +16,6 @@
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Protocol;
using Microsoft.CodeAnalysis.Razor.Workspaces;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.CodeActions;
@@ -34,22 +33,18 @@ internal class CreateComponentCodeActionResolver(LanguageServerFeatureOptions la
return null;
}
- var codeDocument = await documentContext.GetCodeDocumentAsync(cancellationToken).ConfigureAwait(false);
- if (codeDocument.IsUnsupported())
+ if (!documentContext.FileKind.IsComponent())
{
return null;
}
- if (!FileKinds.IsComponent(codeDocument.FileKind))
- {
- return null;
- }
+ var codeDocument = await documentContext.GetCodeDocumentAsync(cancellationToken).ConfigureAwait(false);
// VS Code in Windows expects path to start with '/'
var updatedPath = _languageServerFeatureOptions.ReturnCodeActionAndRenamePathsWithPrefixedSlash && !actionParams.Path.StartsWith("/")
? '/' + actionParams.Path
: actionParams.Path;
- var newComponentUri = VsLspFactory.CreateFilePathUri(updatedPath);
+ var newComponentUri = LspFactory.CreateFilePathUri(updatedPath);
using var documentChanges = new PooledArrayBuilder>();
documentChanges.Add(new CreateFile() { Uri = newComponentUri });
@@ -76,7 +71,7 @@ private static void TryAddNamespaceDirective(RazorCodeDocument codeDocument, Uri
documentChanges.Add(new TextDocumentEdit
{
TextDocument = documentIdentifier,
- Edits = [VsLspFactory.CreateTextEdit(position: (0, 0), namespaceDirective.GetContent())]
+ Edits = [LspFactory.CreateTextEdit(position: (0, 0), namespaceDirective.GetContent())]
});
}
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/ExtractToCodeBehindCodeActionProvider.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/ExtractToCodeBehindCodeActionProvider.cs
index 90c7520da09..c044a817dc1 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/ExtractToCodeBehindCodeActionProvider.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/ExtractToCodeBehindCodeActionProvider.cs
@@ -31,7 +31,7 @@ public Task> ProvideAsync(RazorCodeAct
return SpecializedTasks.EmptyImmutableArray();
}
- if (!FileKinds.IsComponent(context.CodeDocument.FileKind))
+ if (!context.CodeDocument.FileKind.IsComponent())
{
return SpecializedTasks.EmptyImmutableArray();
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/ExtractToCodeBehindCodeActionResolver.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/ExtractToCodeBehindCodeActionResolver.cs
index 0bc79eea905..079ab783f7e 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/ExtractToCodeBehindCodeActionResolver.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/ExtractToCodeBehindCodeActionResolver.cs
@@ -14,9 +14,9 @@
using Microsoft.CodeAnalysis.Razor.Formatting;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Protocol;
+using Microsoft.CodeAnalysis.Razor.Utilities;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.CodeActions;
@@ -37,19 +37,14 @@ internal class ExtractToCodeBehindCodeActionResolver(
return null;
}
- var path = FilePathNormalizer.Normalize(documentContext.Uri.GetAbsoluteOrUNCPath());
-
- var codeDocument = await documentContext.GetCodeDocumentAsync(cancellationToken).ConfigureAwait(false);
- if (codeDocument.IsUnsupported())
+ if (!documentContext.FileKind.IsComponent())
{
return null;
}
- if (!FileKinds.IsComponent(codeDocument.FileKind))
- {
- return null;
- }
+ var codeDocument = await documentContext.GetCodeDocumentAsync(cancellationToken).ConfigureAwait(false);
+ var path = FilePathNormalizer.Normalize(documentContext.Uri.GetAbsoluteOrUNCPath());
var codeBehindPath = FileUtilities.GenerateUniquePath(path, $"{Path.GetExtension(path)}.cs");
// VS Code in Windows expects path to start with '/'
@@ -57,7 +52,7 @@ internal class ExtractToCodeBehindCodeActionResolver(
? '/' + codeBehindPath
: codeBehindPath;
- var codeBehindUri = VsLspFactory.CreateFilePathUri(updatedCodeBehindPath);
+ var codeBehindUri = LspFactory.CreateFilePathUri(updatedCodeBehindPath);
var text = await documentContext.GetSourceTextAsync(cancellationToken).ConfigureAwait(false);
@@ -78,12 +73,12 @@ internal class ExtractToCodeBehindCodeActionResolver(
new TextDocumentEdit
{
TextDocument = codeDocumentIdentifier,
- Edits = [VsLspFactory.CreateTextEdit(removeRange, string.Empty)]
+ Edits = [LspFactory.CreateTextEdit(removeRange, string.Empty)]
},
new TextDocumentEdit
{
TextDocument = codeBehindDocumentIdentifier,
- Edits = [VsLspFactory.CreateTextEdit(position: (0, 0), codeBehindContent)]
+ Edits = [LspFactory.CreateTextEdit(position: (0, 0), codeBehindContent)]
}
};
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/ExtractToComponentCodeActionProvider.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/ExtractToComponentCodeActionProvider.cs
index 3e2b583614d..8e85a84b016 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/ExtractToComponentCodeActionProvider.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/ExtractToComponentCodeActionProvider.cs
@@ -12,7 +12,6 @@
using Microsoft.CodeAnalysis.Razor.CodeActions.Models;
using Microsoft.CodeAnalysis.Razor.Protocol;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.CodeActions.Razor;
@@ -35,7 +34,7 @@ public Task> ProvideAsync(RazorCodeAct
return SpecializedTasks.EmptyImmutableArray();
}
- if (!FileKinds.IsComponent(context.CodeDocument.FileKind))
+ if (!context.CodeDocument.FileKind.IsComponent())
{
return SpecializedTasks.EmptyImmutableArray();
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/ExtractToComponentCodeActionResolver.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/ExtractToComponentCodeActionResolver.cs
index ab8dc39c773..d5461f98575 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/ExtractToComponentCodeActionResolver.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/ExtractToComponentCodeActionResolver.cs
@@ -16,9 +16,9 @@
using Microsoft.CodeAnalysis.Razor.Formatting;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Protocol;
+using Microsoft.CodeAnalysis.Razor.Utilities;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.CodeActions.Razor;
@@ -43,10 +43,6 @@ internal class ExtractToComponentCodeActionResolver(
}
var componentDocument = await documentContext.GetCodeDocumentAsync(cancellationToken).ConfigureAwait(false);
- if (componentDocument.IsUnsupported())
- {
- return null;
- }
var text = componentDocument.Source.Text;
var path = FilePathNormalizer.Normalize(documentContext.Uri.GetAbsoluteOrUNCPath());
@@ -60,7 +56,7 @@ internal class ExtractToComponentCodeActionResolver(
? '/' + componentPath
: componentPath;
- var newComponentUri = VsLspFactory.CreateFilePathUri(componentPath);
+ var newComponentUri = LspFactory.CreateFilePathUri(componentPath);
using var _ = StringBuilderPool.GetPooledObject(out var builder);
@@ -71,7 +67,7 @@ internal class ExtractToComponentCodeActionResolver(
var usingDirectives = syntaxTree.GetUsingDirectives();
foreach (var usingDirective in usingDirectives)
{
- builder.AppendLine(usingDirective.ToFullString());
+ builder.AppendLine(usingDirective.ToString());
}
// If any using directives were added, add a newline before the extracted content.
@@ -108,7 +104,7 @@ internal class ExtractToComponentCodeActionResolver(
new TextEdit
{
NewText = builder.ToString(),
- Range = VsLspFactory.DefaultRange,
+ Range = LspFactory.DefaultRange,
}
],
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/GenerateMethodCodeActionResolver.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/GenerateMethodCodeActionResolver.cs
index d40c8594c9a..2a484576b9a 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/GenerateMethodCodeActionResolver.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/GenerateMethodCodeActionResolver.cs
@@ -11,7 +11,6 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
-using Microsoft.AspNetCore.Razor.Utilities;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
@@ -20,9 +19,9 @@
using Microsoft.CodeAnalysis.Razor.Formatting;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Protocol;
+using Microsoft.CodeAnalysis.Razor.Utilities;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.CodeActions.Razor;
@@ -84,7 +83,7 @@ razorClassName is null ||
cancellationToken).ConfigureAwait(false);
}
- var codeBehindUri = VsLspFactory.CreateFilePathUri(codeBehindPath);
+ var codeBehindUri = LspFactory.CreateFilePathUri(codeBehindPath);
var codeBehindTextDocumentIdentifier = new OptionalVersionedTextDocumentIdentifier() { Uri = codeBehindUri };
@@ -98,7 +97,7 @@ razorClassName is null ||
classLocationLineSpan.StartLinePosition.Character,
text);
- var edit = VsLspFactory.CreateTextEdit(
+ var edit = LspFactory.CreateTextEdit(
line: classLocationLineSpan.EndLinePosition.Line,
character: 0,
$"{formattedMethod}{Environment.NewLine}");
@@ -108,7 +107,7 @@ razorClassName is null ||
var codeBehindTextDocEdit = new TextDocumentEdit()
{
TextDocument = codeBehindTextDocumentIdentifier,
- Edits = result ?? [edit]
+ Edits = [.. result ?? [edit]]
};
return new WorkspaceEdit() { DocumentChanges = new[] { codeBehindTextDocEdit } };
@@ -140,7 +139,7 @@ private async Task GenerateMethodInCodeBlockAsync(
// just get the simplified text that comes back from Roslyn.
var classLocationLineSpan = @class.GetLocation().GetLineSpan();
- var tempTextEdit = VsLspFactory.CreateTextEdit(
+ var tempTextEdit = LspFactory.CreateTextEdit(
line: classLocationLineSpan.EndLinePosition.Line,
character: 0,
editToSendToRoslyn.NewText);
@@ -167,7 +166,7 @@ private async Task GenerateMethodInCodeBlockAsync(
.Replace(FormattingUtilities.InitialIndent, string.Empty)
.Replace(FormattingUtilities.Indent, string.Empty);
- var remappedEdit = VsLspFactory.CreateTextEdit(remappedRange, unformattedMethodSignature);
+ var remappedEdit = LspFactory.CreateTextEdit(remappedRange, unformattedMethodSignature);
var result = await _roslynCodeActionHelpers.GetSimplifiedTextEditsAsync(documentContext, codeBehindUri: null, remappedEdit, cancellationToken).ConfigureAwait(false);
if (result is not null)
@@ -192,7 +191,7 @@ private async Task GenerateMethodInCodeBlockAsync(
var razorTextDocEdit = new TextDocumentEdit()
{
TextDocument = new OptionalVersionedTextDocumentIdentifier() { Uri = documentContext.Uri },
- Edits = edits,
+ Edits = [.. edits],
};
return new WorkspaceEdit() { DocumentChanges = new[] { razorTextDocEdit } };
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/IRazorCodeActionResolver.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/IRazorCodeActionResolver.cs
index d9418b20570..bbbdf1f31c1 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/IRazorCodeActionResolver.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/IRazorCodeActionResolver.cs
@@ -6,7 +6,6 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Razor.Formatting;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.CodeActions;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/IRoslynCodeActionHelpers.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/IRoslynCodeActionHelpers.cs
index 71893c035d3..0e6a132b8f0 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/IRoslynCodeActionHelpers.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/IRoslynCodeActionHelpers.cs
@@ -4,9 +4,7 @@
using System;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.CodeActions;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/PromoteUsingCodeActionProvider.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/PromoteUsingCodeActionProvider.cs
index 481da94603a..7b5d6b6ffcc 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/PromoteUsingCodeActionProvider.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/PromoteUsingCodeActionProvider.cs
@@ -68,10 +68,10 @@ public Task> ProvideAsync(RazorCodeAct
return Task.FromResult>([action]);
}
- public static string GetImportsFileName(string fileKind)
+ public static string GetImportsFileName(RazorFileKind fileKind)
{
- return FileKinds.IsLegacy(fileKind)
- ? MvcImportProjectFeature.ImportsFileName
- : ComponentMetadata.ImportsFileName;
+ return fileKind.IsLegacy()
+ ? MvcImportProjectFeature.ImportsFileName
+ : ComponentMetadata.ImportsFileName;
}
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/PromoteUsingCodeActionResolver.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/PromoteUsingCodeActionResolver.cs
index 5e4291b35f5..a7249e8bf82 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/PromoteUsingCodeActionResolver.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/PromoteUsingCodeActionResolver.cs
@@ -8,14 +8,13 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor;
using Microsoft.AspNetCore.Razor.PooledObjects;
-using Microsoft.AspNetCore.Razor.Utilities;
using Microsoft.CodeAnalysis.Razor.CodeActions.Models;
using Microsoft.CodeAnalysis.Razor.Formatting;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Protocol;
+using Microsoft.CodeAnalysis.Razor.Utilities;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.CodeActions;
@@ -40,7 +39,7 @@ internal class PromoteUsingCodeActionResolver(IFileSystem fileSystem) : IRazorCo
var file = FilePathNormalizer.Normalize(documentContext.Uri.GetAbsoluteOrUNCPath());
var folder = Path.GetDirectoryName(file).AssumeNotNull();
var importsFile = Path.GetFullPath(Path.Combine(folder, "..", importsFileName));
- var importFileUri = VsLspFactory.CreateFilePathUri(importsFile);
+ var importFileUri = LspFactory.CreateFilePathUri(importsFile);
using var edits = new PooledArrayBuilder>();
@@ -67,7 +66,7 @@ internal class PromoteUsingCodeActionResolver(IFileSystem fileSystem) : IRazorCo
edits.Add(new TextDocumentEdit
{
TextDocument = new OptionalVersionedTextDocumentIdentifier() { Uri = importFileUri },
- Edits = [VsLspFactory.CreateTextEdit(insertLocation, textToInsert)]
+ Edits = [LspFactory.CreateTextEdit(insertLocation, textToInsert)]
});
var removeRange = sourceText.GetRange(actionParams.RemoveStart, actionParams.RemoveEnd);
@@ -75,7 +74,7 @@ internal class PromoteUsingCodeActionResolver(IFileSystem fileSystem) : IRazorCo
edits.Add(new TextDocumentEdit
{
TextDocument = new OptionalVersionedTextDocumentIdentifier() { Uri = documentContext.Uri },
- Edits = [VsLspFactory.CreateTextEdit(removeRange, string.Empty)]
+ Edits = [LspFactory.CreateTextEdit(removeRange, string.Empty)]
});
return new WorkspaceEdit
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/RazorCodeActionFactory.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/RazorCodeActionFactory.cs
index 2f7bb59b582..052f323bc45 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/RazorCodeActionFactory.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/RazorCodeActionFactory.cs
@@ -5,7 +5,6 @@
using System.Text.Json;
using Microsoft.CodeAnalysis.Razor.CodeActions.Models;
using Microsoft.CodeAnalysis.Razor.Protocol;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.CodeActions.Razor;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/WrapAttributesCodeActionResolver.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/WrapAttributesCodeActionResolver.cs
index 772be95a93d..f65c1e28641 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/WrapAttributesCodeActionResolver.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/WrapAttributesCodeActionResolver.cs
@@ -11,7 +11,6 @@
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Protocol;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.CodeActions;
@@ -29,13 +28,13 @@ internal class WrapAttributesCodeActionResolver : IRazorCodeActionResolver
var indentationString = FormattingUtilities.GetIndentationString(actionParams.IndentSize, options.InsertSpaces, options.TabSize);
var sourceText = await documentContext.GetSourceTextAsync(cancellationToken).ConfigureAwait(false);
- using var edits = new PooledArrayBuilder();
+ using var edits = new PooledArrayBuilder>();
foreach (var position in actionParams.NewLinePositions)
{
var start = sourceText.GetLinePosition(FindPreviousNonWhitespacePosition(sourceText, position) + 1);
var end = sourceText.GetLinePosition(position);
- edits.Add(VsLspFactory.CreateTextEdit(start, end, Environment.NewLine + indentationString));
+ edits.Add(LspFactory.CreateTextEdit(start, end, Environment.NewLine + indentationString));
}
var tde = new TextDocumentEdit
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/RazorCodeActionContext.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/RazorCodeActionContext.cs
index 3d5f054e7cc..65ee7d71706 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/RazorCodeActionContext.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/RazorCodeActionContext.cs
@@ -3,7 +3,7 @@
using System;
using Microsoft.AspNetCore.Razor.Language;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
+using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Protocol.CodeActions;
using Microsoft.CodeAnalysis.Text;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/AggregateCompletionItemResolver.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/AggregateCompletionItemResolver.cs
index a77413cddb7..267b39e6daf 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/AggregateCompletionItemResolver.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/AggregateCompletionItemResolver.cs
@@ -10,7 +10,6 @@
using Microsoft.AspNetCore.Razor.PooledObjects;
using Microsoft.CodeAnalysis.Razor.Logging;
using Microsoft.CodeAnalysis.Razor.Tooltip;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Completion;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/CompletionItemResolver.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/CompletionItemResolver.cs
index 396585f9723..fae961fafb1 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/CompletionItemResolver.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/CompletionItemResolver.cs
@@ -4,7 +4,6 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Razor.Tooltip;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Completion;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/CompletionListCache.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/CompletionListCache.cs
index 00ec6876cc1..f2ca83547a1 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/CompletionListCache.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/CompletionListCache.cs
@@ -2,7 +2,6 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Diagnostics.CodeAnalysis;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Completion;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/CompletionListMerger.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/CompletionListMerger.cs
index 78b3468297f..1073b73b7a0 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/CompletionListMerger.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/CompletionListMerger.cs
@@ -8,7 +8,6 @@
using System.Linq;
using System.Text.Json;
using Microsoft.AspNetCore.Razor.PooledObjects;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Completion;
@@ -20,7 +19,7 @@ internal static class CompletionListMerger
[return: NotNullIfNotNull(nameof(razorCompletionList))]
[return: NotNullIfNotNull(nameof(delegatedCompletionList))]
- public static VSInternalCompletionList? Merge(VSInternalCompletionList? razorCompletionList, VSInternalCompletionList? delegatedCompletionList)
+ public static RazorVSInternalCompletionList? Merge(RazorVSInternalCompletionList? razorCompletionList, RazorVSInternalCompletionList? delegatedCompletionList)
{
if (razorCompletionList is null)
{
@@ -47,7 +46,7 @@ internal static class CompletionListMerger
// We don't fully support merging edit ranges currently. Razor doesn't currently use them so delegated completion lists always win.
var mergedItemDefaultsEditRange = razorCompletionList.ItemDefaults?.EditRange ?? delegatedCompletionList.ItemDefaults?.EditRange;
- var mergedCompletionList = new VSInternalCompletionList()
+ var mergedCompletionList = new RazorVSInternalCompletionList()
{
CommitCharacters = mergedCommitCharacters,
Data = mergedData,
@@ -142,7 +141,7 @@ private static void TrySplitJsonElement(object data, ref PooledArrayBuilder? completionItemsToStopInheriting;
- VSInternalCompletionList? completionListToStopInheriting;
+ RazorVSInternalCompletionList? completionListToStopInheriting;
// Decide which completion list has more items that benefit from "inheriting" commit characters.
if (inheritableCommitCharacterCompletionsA.Length >= inheritableCommitCharacterCompletionsB.Length)
@@ -206,7 +205,7 @@ private static void EnsureMergeableCommitCharacters(VSInternalCompletionList com
}
}
- private static ImmutableArray GetCompletionsThatDoNotSpecifyCommitCharacters(VSInternalCompletionList completionList)
+ private static ImmutableArray GetCompletionsThatDoNotSpecifyCommitCharacters(RazorVSInternalCompletionList completionList)
{
using var inheritableCompletions = new PooledArrayBuilder();
for (var i = 0; i < completionList.Items.Length; i++)
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/CompletionListOptimizer.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/CompletionListOptimizer.cs
index cdf9a3766fe..4e09baf97c9 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/CompletionListOptimizer.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/CompletionListOptimizer.cs
@@ -3,26 +3,23 @@
using System.Collections.Generic;
using System.Linq;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
-using AliasedVSCommitCharacters = Microsoft.VisualStudio.LanguageServer.Protocol.SumType;
+using AliasedVSCommitCharacters = Roslyn.LanguageServer.Protocol.SumType;
namespace Microsoft.CodeAnalysis.Razor.Completion;
internal static class CompletionListOptimizer
{
- public static VSInternalCompletionList Optimize(VSInternalCompletionList completionList, VSInternalCompletionSetting? completionCapability)
+ public static RazorVSInternalCompletionList Optimize(RazorVSInternalCompletionList completionList, VSInternalCompletionSetting? completionCapability)
{
if (completionCapability is not null)
{
completionList = OptimizeCommitCharacters(completionList, completionCapability);
}
- // We wrap the pre-existing completion list with an optimized completion list to better control serialization/deserialization
- var optimizedCompletionList = new OptimizedVSCompletionList(completionList);
- return optimizedCompletionList;
+ return completionList;
}
- private static VSInternalCompletionList OptimizeCommitCharacters(VSInternalCompletionList completionList, VSInternalCompletionSetting completionCapability)
+ private static RazorVSInternalCompletionList OptimizeCommitCharacters(RazorVSInternalCompletionList completionList, VSInternalCompletionSetting completionCapability)
{
var completionListCapability = completionCapability.CompletionList;
if (completionListCapability?.CommitCharacters != true)
@@ -35,7 +32,7 @@ private static VSInternalCompletionList OptimizeCommitCharacters(VSInternalCompl
return completionList;
}
- private static VSInternalCompletionList PromoteVSCommonCommitCharactersOntoList(VSInternalCompletionList completionList)
+ private static RazorVSInternalCompletionList PromoteVSCommonCommitCharactersOntoList(RazorVSInternalCompletionList completionList)
{
(AliasedVSCommitCharacters VsCommitCharacters, List AssociatedCompletionItems)? mostUsedCommitCharacterToItems = null;
var commitCharacterMap = new Dictionary>(AliasedVSCommitCharactersComparer.Instance);
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/CompletionTriggerAndCommitCharacters.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/CompletionTriggerAndCommitCharacters.cs
index dc7e482aebd..1776660768f 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/CompletionTriggerAndCommitCharacters.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/CompletionTriggerAndCommitCharacters.cs
@@ -4,7 +4,6 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using Microsoft.CodeAnalysis.Razor.Workspaces;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Completion;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/Delegation/DelegatedCompletionHelper.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/Delegation/DelegatedCompletionHelper.cs
index 6b460666425..c3d4632f800 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/Delegation/DelegatedCompletionHelper.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/Delegation/DelegatedCompletionHelper.cs
@@ -7,7 +7,6 @@
using Microsoft.CodeAnalysis.Razor.DocumentMapping;
using Microsoft.CodeAnalysis.Razor.Protocol;
using Microsoft.CodeAnalysis.Razor.Protocol.Completion;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Completion.Delegation;
@@ -93,8 +92,8 @@ internal static class DelegatedCompletionHelper
///
/// Possibly modified completion response.
///
- public static VSInternalCompletionList RewriteCSharpResponse(
- VSInternalCompletionList? delegatedResponse,
+ public static RazorVSInternalCompletionList RewriteCSharpResponse(
+ RazorVSInternalCompletionList? delegatedResponse,
int absoluteIndex,
RazorCodeDocument codeDocument,
Position projectedPosition,
@@ -106,7 +105,7 @@ public static VSInternalCompletionList RewriteCSharpResponse(
// list. When a user is typing quickly, the delegated request from the first keystroke will fail to synchronize,
// so if we return a "complete" list then the query won't re-query us for completion once the typing stops/slows
// so we'd only ever return Razor completion items.
- return new VSInternalCompletionList() { IsIncomplete = true, Items = [] };
+ return new RazorVSInternalCompletionList() { IsIncomplete = true, Items = [] };
}
var rewrittenResponse = delegatedResponse;
@@ -124,8 +123,8 @@ public static VSInternalCompletionList RewriteCSharpResponse(
return rewrittenResponse;
}
- public static VSInternalCompletionList RewriteHtmlResponse(
- VSInternalCompletionList? delegatedResponse,
+ public static RazorVSInternalCompletionList RewriteHtmlResponse(
+ RazorVSInternalCompletionList? delegatedResponse,
RazorCompletionOptions completionOptions)
{
if (delegatedResponse?.Items is null)
@@ -134,7 +133,7 @@ public static VSInternalCompletionList RewriteHtmlResponse(
// list. When a user is typing quickly, the delegated request from the first keystroke will fail to synchronize,
// so if we return a "complete" list then the query won't re-query us for completion once the typing stops/slows
// so we'd only ever return Razor completion items.
- return new VSInternalCompletionList() { IsIncomplete = true, Items = [] };
+ return new RazorVSInternalCompletionList() { IsIncomplete = true, Items = [] };
}
var rewrittenResponse = s_delegatedHtmlCompletionResponseRewriter.Rewrite(
@@ -190,11 +189,11 @@ public static bool TryGetProvisionalCompletionInfo(
// Edit the CSharp projected document to contain a '.'. This allows C# completion to provide valid
// completion items for moments when a user has typed a '.' that's typically interpreted as Html.
- var addProvisionalDot = VsLspFactory.CreateTextEdit(previousPosition, ".");
+ var addProvisionalDot = LspFactory.CreateTextEdit(previousPosition, ".");
var provisionalPositionInfo = new DocumentPositionInfo(
RazorLanguageKind.CSharp,
- VsLspFactory.CreatePosition(
+ LspFactory.CreatePosition(
previousPosition.Line,
previousPosition.Character + 1),
previousCharacterPositionInfo.HostDocumentIndex + 1);
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/Delegation/DesignTimeHelperResponseRewriter.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/Delegation/DesignTimeHelperResponseRewriter.cs
index 55580f43d63..4825fd47673 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/Delegation/DesignTimeHelperResponseRewriter.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/Delegation/DesignTimeHelperResponseRewriter.cs
@@ -8,7 +8,6 @@
using Microsoft.AspNetCore.Razor.Language.Syntax;
using Microsoft.AspNetCore.Razor.PooledObjects;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
using RazorSyntaxNode = Microsoft.AspNetCore.Razor.Language.Syntax.SyntaxNode;
namespace Microsoft.CodeAnalysis.Razor.Completion.Delegation;
@@ -30,8 +29,8 @@ internal class DesignTimeHelperResponseRewriter : IDelegatedCSharpCompletionResp
"BuildRenderTree"
}.ToFrozenSet();
- public VSInternalCompletionList Rewrite(
- VSInternalCompletionList completionList,
+ public RazorVSInternalCompletionList Rewrite(
+ RazorVSInternalCompletionList completionList,
RazorCodeDocument codeDocument,
int hostDocumentIndex,
Position projectedPosition,
@@ -54,7 +53,7 @@ public VSInternalCompletionList Rewrite(
// from the completion list. If the current identifier does start with a double underscore (e.g. "__ab[||]"),
// we only trim out common design time helpers from the completion list.
- using var _ = ListPool.GetPooledObject(out var filteredItems);
+ using var _ = ListPool.GetPooledObject(out var filteredItems);
var items = completionList.Items;
filteredItems.SetCapacityIfLarger(items.Length);
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/Delegation/HtmlCommitCharacterResponseRewriter.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/Delegation/HtmlCommitCharacterResponseRewriter.cs
index 5e34b3dd8f7..1c2bbff2389 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/Delegation/HtmlCommitCharacterResponseRewriter.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/Delegation/HtmlCommitCharacterResponseRewriter.cs
@@ -3,14 +3,13 @@
using System.Collections.Generic;
using System.Linq;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Completion.Delegation;
internal class HtmlCommitCharacterResponseRewriter
{
- public VSInternalCompletionList Rewrite(
- VSInternalCompletionList completionList,
+ public RazorVSInternalCompletionList Rewrite(
+ RazorVSInternalCompletionList completionList,
RazorCompletionOptions completionOptions)
{
if (completionOptions.CommitElementsWithSpace)
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/Delegation/IDelegatedCSharpCompletionResponseRewriter.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/Delegation/IDelegatedCSharpCompletionResponseRewriter.cs
index 4779ed134f8..bd623a77cef 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/Delegation/IDelegatedCSharpCompletionResponseRewriter.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/Delegation/IDelegatedCSharpCompletionResponseRewriter.cs
@@ -2,14 +2,13 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using Microsoft.AspNetCore.Razor.Language;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Completion.Delegation;
internal interface IDelegatedCSharpCompletionResponseRewriter
{
- VSInternalCompletionList Rewrite(
- VSInternalCompletionList completionList,
+ RazorVSInternalCompletionList Rewrite(
+ RazorVSInternalCompletionList completionList,
RazorCodeDocument codeDocument,
int hostDocumentIndex,
Position projectedPosition,
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/Delegation/SnippetResponseRewriter.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/Delegation/SnippetResponseRewriter.cs
index 829f5b5e9de..3abf03ecb8a 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/Delegation/SnippetResponseRewriter.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/Delegation/SnippetResponseRewriter.cs
@@ -3,7 +3,6 @@
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.PooledObjects;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Completion.Delegation;
@@ -15,14 +14,14 @@ namespace Microsoft.CodeAnalysis.Razor.Completion.Delegation;
///
internal class SnippetResponseRewriter : IDelegatedCSharpCompletionResponseRewriter
{
- public VSInternalCompletionList Rewrite(
- VSInternalCompletionList completionList,
+ public RazorVSInternalCompletionList Rewrite(
+ RazorVSInternalCompletionList completionList,
RazorCodeDocument codeDocument,
int hostDocumentIndex,
Position projectedPosition,
RazorCompletionOptions completionOptionsn)
{
- using var items = new PooledArrayBuilder(completionList.Items.Length);
+ using var items = new PooledArrayBuilder(completionList.Items.Length);
foreach (var item in completionList.Items)
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/Delegation/TextEditResponseRewriter.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/Delegation/TextEditResponseRewriter.cs
index 62e9cf521cd..e7d83891b47 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/Delegation/TextEditResponseRewriter.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/Delegation/TextEditResponseRewriter.cs
@@ -2,14 +2,13 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using Microsoft.AspNetCore.Razor.Language;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Completion.Delegation;
internal class TextEditResponseRewriter : IDelegatedCSharpCompletionResponseRewriter
{
- public VSInternalCompletionList Rewrite(
- VSInternalCompletionList completionList,
+ public RazorVSInternalCompletionList Rewrite(
+ RazorVSInternalCompletionList completionList,
RazorCodeDocument codeDocument,
int hostDocumentIndex,
Position projectedPosition,
@@ -36,10 +35,10 @@ public VSInternalCompletionList Rewrite(
return completionList;
}
- private static VSInternalCompletionList TranslateTextEdits(
+ private static RazorVSInternalCompletionList TranslateTextEdits(
Position hostDocumentPosition,
Position projectedPosition,
- VSInternalCompletionList completionList)
+ RazorVSInternalCompletionList completionList)
{
// The TextEdit positions returned to us from the C#/HTML language servers are positions correlating to the virtual document.
// We need to translate these positions to apply to the Razor document instead. Performance is a big concern here, so we want to
@@ -73,14 +72,14 @@ private static VSInternalCompletionList TranslateTextEdits(
return completionList;
}
- private static Range TranslateRange(Position hostDocumentPosition, Position projectedPosition, Range textEditRange)
+ private static LspRange TranslateRange(Position hostDocumentPosition, Position projectedPosition, LspRange textEditRange)
{
var offset = projectedPosition.Character - hostDocumentPosition.Character;
var translatedStartPosition = TranslatePosition(offset, hostDocumentPosition, textEditRange.Start);
var translatedEndPosition = TranslatePosition(offset, hostDocumentPosition, textEditRange.End);
- return VsLspFactory.CreateRange(translatedStartPosition, translatedEndPosition);
+ return LspFactory.CreateRange(translatedStartPosition, translatedEndPosition);
static Position TranslatePosition(int offset, Position hostDocumentPosition, Position editPosition)
{
@@ -88,7 +87,7 @@ static Position TranslatePosition(int offset, Position hostDocumentPosition, Pos
// Note: If this completion handler ever expands to deal with multi-line TextEdits, this logic will likely need to change since
// it assumes we're only dealing with single-line TextEdits.
- return VsLspFactory.CreatePosition(hostDocumentPosition.Line, translatedCharacter);
+ return LspFactory.CreatePosition(hostDocumentPosition.Line, translatedCharacter);
}
}
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/DirectiveAttributeCompletionItemProvider.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/DirectiveAttributeCompletionItemProvider.cs
index b0527a32799..5778c0a2ec6 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/DirectiveAttributeCompletionItemProvider.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/DirectiveAttributeCompletionItemProvider.cs
@@ -16,7 +16,7 @@ internal class DirectiveAttributeCompletionItemProvider : DirectiveAttributeComp
{
public override ImmutableArray GetCompletionItems(RazorCompletionContext context)
{
- if (!FileKinds.IsComponent(context.SyntaxTree.Options.FileKind))
+ if (!context.SyntaxTree.Options.FileKind.IsComponent())
{
// Directive attributes are only supported in components
return [];
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/DirectiveAttributeParameterCompletionItemProvider.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/DirectiveAttributeParameterCompletionItemProvider.cs
index 58a0192262a..871e8b22d93 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/DirectiveAttributeParameterCompletionItemProvider.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/DirectiveAttributeParameterCompletionItemProvider.cs
@@ -15,7 +15,7 @@ internal class DirectiveAttributeParameterCompletionItemProvider : DirectiveAttr
{
public override ImmutableArray GetCompletionItems(RazorCompletionContext context)
{
- if (!FileKinds.IsComponent(context.SyntaxTree.Options.FileKind))
+ if (!context.SyntaxTree.Options.FileKind.IsComponent())
{
// Directive attribute parameters are only supported in components
return [];
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/DirectiveAttributeTransitionCompletionItemProvider.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/DirectiveAttributeTransitionCompletionItemProvider.cs
index a407d384407..3614aeecb12 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/DirectiveAttributeTransitionCompletionItemProvider.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/DirectiveAttributeTransitionCompletionItemProvider.cs
@@ -51,7 +51,7 @@ public static bool IsTransitionCompletionItem(RazorCompletionItem completionItem
public override ImmutableArray GetCompletionItems(RazorCompletionContext context)
{
- if (!FileKinds.IsComponent(context.SyntaxTree.Options.FileKind))
+ if (!context.SyntaxTree.Options.FileKind.IsComponent())
{
// Directive attributes are only supported in components
return [];
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/DirectiveCompletionItemProvider.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/DirectiveCompletionItemProvider.cs
index ad7b9162911..79ebfcbcb42 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/DirectiveCompletionItemProvider.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/DirectiveCompletionItemProvider.cs
@@ -81,7 +81,7 @@ internal static bool ShouldProvideCompletions(RazorCompletionContext context)
return false;
}
- if (implicitExpression.FullWidth > 2 && context.Reason != CompletionReason.Invoked)
+ if (implicitExpression.Width > 2 && context.Reason != CompletionReason.Invoked)
{
// We only want to provide directive completions if the implicit expression is empty "@|" or at the beginning of a word "@i|", this ensures
// we're consistent with how C# typically provides completion items.
@@ -124,7 +124,7 @@ internal static bool ShouldProvideCompletions(RazorCompletionContext context)
// Internal for testing
internal static ImmutableArray GetDirectiveCompletionItems(RazorSyntaxTree syntaxTree)
{
- var defaultDirectives = FileKinds.IsComponent(syntaxTree.Options.FileKind)
+ var defaultDirectives = syntaxTree.Options.FileKind.IsComponent()
? ComponentDefaultDirectives
: MvcDefaultDirectives;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/RazorCompletionItemResolver.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/RazorCompletionItemResolver.cs
index a8733cd5bbd..b753b906b1d 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/RazorCompletionItemResolver.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/RazorCompletionItemResolver.cs
@@ -7,8 +7,7 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Razor.Tooltip;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
-using Microsoft.VisualStudio.Text.Adornments;
+using Roslyn.Text.Adornments;
namespace Microsoft.CodeAnalysis.Razor.Completion;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/RazorCompletionListProvider.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/RazorCompletionListProvider.cs
index 821c06282e8..3a6b37195c4 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/RazorCompletionListProvider.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/RazorCompletionListProvider.cs
@@ -12,7 +12,6 @@
using Microsoft.AspNetCore.Razor.Language.Syntax;
using Microsoft.AspNetCore.Razor.PooledObjects;
using Microsoft.CodeAnalysis.Razor.Logging;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Completion;
@@ -31,7 +30,7 @@ internal class RazorCompletionListProvider(
};
// virtual for tests
- public virtual VSInternalCompletionList? GetCompletionList(
+ public virtual RazorVSInternalCompletionList? GetCompletionList(
RazorCodeDocument codeDocument,
int absoluteIndex,
VSInternalCompletionContext completionContext,
@@ -85,11 +84,11 @@ internal class RazorCompletionListProvider(
}
// Internal for benchmarking and testing
- internal static VSInternalCompletionList CreateLSPCompletionList(
+ internal static RazorVSInternalCompletionList CreateLSPCompletionList(
ImmutableArray razorCompletionItems,
VSInternalClientCapabilities clientCapabilities)
{
- using var items = new PooledArrayBuilder();
+ using var items = new PooledArrayBuilder();
foreach (var razorCompletionItem in razorCompletionItems)
{
@@ -99,7 +98,7 @@ internal static VSInternalCompletionList CreateLSPCompletionList(
}
}
- var completionList = new VSInternalCompletionList()
+ var completionList = new RazorVSInternalCompletionList()
{
Items = items.ToArray(),
IsIncomplete = false,
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/VSInternalCompletionItemExtensions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/VSInternalCompletionItemExtensions.cs
index e4f4330726c..2d764dac81a 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/VSInternalCompletionItemExtensions.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/VSInternalCompletionItemExtensions.cs
@@ -5,7 +5,6 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using Microsoft.AspNetCore.Razor.PooledObjects;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Completion;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/VSInternalCompletionListExtensions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/VSInternalCompletionListExtensions.cs
index 6e4b52b9cb3..c0b12459007 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/VSInternalCompletionListExtensions.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/VSInternalCompletionListExtensions.cs
@@ -4,7 +4,6 @@
using System.Linq;
using System.Text.Json;
using System.Text.Json.Nodes;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Completion;
@@ -14,7 +13,7 @@ internal static class VSInternalCompletionListExtensions
private const string ResultIdKey = "_resultId";
public static void SetResultId(
- this VSInternalCompletionList completionList,
+ this RazorVSInternalCompletionList completionList,
int resultId,
VSInternalCompletionSetting? completionSetting)
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DebuggerDisplay.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DebuggerDisplay.cs
index 986350fb436..c0058d8d05c 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DebuggerDisplay.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DebuggerDisplay.cs
@@ -2,6 +2,5 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Diagnostics;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
[assembly: DebuggerDisplay("{Label} ({Kind})", Target = typeof(CompletionItem))]
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Diagnostics/RazorDiagnosticHelper.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Diagnostics/RazorDiagnosticHelper.cs
index 05308f35dfa..16b2dcf23b6 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Diagnostics/RazorDiagnosticHelper.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Diagnostics/RazorDiagnosticHelper.cs
@@ -7,12 +7,8 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
+using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
-using LspDiagnostic = Microsoft.VisualStudio.LanguageServer.Protocol.Diagnostic;
-using LspDiagnosticSeverity = Microsoft.VisualStudio.LanguageServer.Protocol.DiagnosticSeverity;
-using LspRange = Microsoft.VisualStudio.LanguageServer.Protocol.Range;
namespace Microsoft.CodeAnalysis.Razor.Diagnostics;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Diagnostics/RazorTranslateDiagnosticsService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Diagnostics/RazorTranslateDiagnosticsService.cs
index db949e181ed..760a80715e9 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Diagnostics/RazorTranslateDiagnosticsService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Diagnostics/RazorTranslateDiagnosticsService.cs
@@ -11,16 +11,12 @@
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.Syntax;
using Microsoft.AspNetCore.Razor.PooledObjects;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Razor.DocumentMapping;
using Microsoft.CodeAnalysis.Razor.Logging;
+using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Protocol;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
-using LspDiagnostic = Microsoft.VisualStudio.LanguageServer.Protocol.Diagnostic;
-using LspDiagnosticSeverity = Microsoft.VisualStudio.LanguageServer.Protocol.DiagnosticSeverity;
-using LspRange = Microsoft.VisualStudio.LanguageServer.Protocol.Range;
namespace Microsoft.CodeAnalysis.Razor.Diagnostics;
@@ -67,11 +63,6 @@ internal async Task TranslateAsync(
CancellationToken cancellationToken)
{
var codeDocument = await documentSnapshot.GetGeneratedOutputAsync(cancellationToken).ConfigureAwait(false);
- if (codeDocument.IsUnsupported() != false)
- {
- _logger.LogInformation($"Unsupported code document.");
- return [];
- }
var filteredDiagnostics = diagnosticKind == RazorLanguageKind.CSharp
? FilterCSharpDiagnostics(diagnostics, codeDocument)
@@ -240,7 +231,7 @@ private static bool ShouldFilterHtmlDiagnosticBasedOnErrorCode(LspDiagnostic dia
CSSErrorCodes.MissingSelectorBeforeCombinatorCode => IsCSharpInStyleBlock(diagnostic, sourceText, syntaxTree),
HtmlErrorCodes.UnexpectedEndTagErrorCode => IsHtmlWithBangAndMatchingTags(diagnostic, sourceText, syntaxTree),
HtmlErrorCodes.InvalidNestingErrorCode => IsAnyFilteredInvalidNestingError(diagnostic, sourceText, syntaxTree),
- HtmlErrorCodes.MissingEndTagErrorCode => FileKinds.IsComponent(syntaxTree.Options.FileKind), // Redundant with RZ9980 in Components
+ HtmlErrorCodes.MissingEndTagErrorCode => syntaxTree.Options.FileKind.IsComponent(), // Redundant with RZ9980 in Components
HtmlErrorCodes.TooFewElementsErrorCode => IsAnyFilteredTooFewElementsError(diagnostic, sourceText, syntaxTree),
_ => false,
};
@@ -414,10 +405,10 @@ n is MarkupTagHelperAttributeSyntax ||
if (markupAttributeNode is not null)
{
- if (!processedAttributes.TryGetValue(markupAttributeNode.FullSpan, out var doesAttributeContainNonMarkup))
+ if (!processedAttributes.TryGetValue(markupAttributeNode.Span, out var doesAttributeContainNonMarkup))
{
doesAttributeContainNonMarkup = CheckIfAttributeContainsNonMarkupNodes(markupAttributeNode);
- processedAttributes.Add(markupAttributeNode.FullSpan, doesAttributeContainNonMarkup);
+ processedAttributes.Add(markupAttributeNode.Span, doesAttributeContainNonMarkup);
}
return doesAttributeContainNonMarkup;
@@ -575,7 +566,7 @@ private bool TryRemapRudeEditRange(LspRange diagnosticRange, RazorCodeDocument c
var diagnosticEndWhitespaceOffset = diagnosticEndCharacter + 1;
var endLinePosition = (endLineIndex, diagnosticEndWhitespaceOffset);
- remappedRange = VsLspFactory.CreateRange(startLinePosition, endLinePosition);
+ remappedRange = LspFactory.CreateRange(startLinePosition, endLinePosition);
return true;
}
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Diagnostics/TaskListDiagnosticProvider.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Diagnostics/TaskListDiagnosticProvider.cs
index dc1fff07407..8617d1f01c2 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Diagnostics/TaskListDiagnosticProvider.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Diagnostics/TaskListDiagnosticProvider.cs
@@ -6,9 +6,6 @@
using Microsoft.AspNetCore.Razor.Language.Syntax;
using Microsoft.AspNetCore.Razor.PooledObjects;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
-using LspDiagnostic = Microsoft.VisualStudio.LanguageServer.Protocol.Diagnostic;
-using LspDiagnosticSeverity = Microsoft.VisualStudio.LanguageServer.Protocol.DiagnosticSeverity;
namespace Microsoft.CodeAnalysis.Razor.Diagnostics;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/AbstractDocumentMappingService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/AbstractDocumentMappingService.cs
index 1720bfc720b..ca6b1c2bd56 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/AbstractDocumentMappingService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/AbstractDocumentMappingService.cs
@@ -12,7 +12,6 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Razor.Logging;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.DocumentMapping;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/AbstractEditMappingService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/AbstractEditMappingService.cs
index d0bcb0fa462..338a0b94f82 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/AbstractEditMappingService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/AbstractEditMappingService.cs
@@ -4,14 +4,13 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
+using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.PooledObjects;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Workspaces;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.DocumentMapping;
@@ -101,7 +100,7 @@ private TextEdit[] RemapTextEditsCore(Uri generatedDocumentUri, RazorCodeDocumen
continue;
}
- var remappedEdit = VsLspFactory.CreateTextEdit(hostDocumentRange, edit.NewText);
+ var remappedEdit = LspFactory.CreateTextEdit(hostDocumentRange, edit.NewText);
remappedEdits.Add(remappedEdit);
}
@@ -133,7 +132,8 @@ private async Task RemapTextDocumentEditsAsync(IDocumentSnap
var codeDocument = await documentContext.GetCodeDocumentAsync(cancellationToken).ConfigureAwait(false);
- var remappedEdits = RemapTextEditsCore(generatedDocumentUri, codeDocument, entry.Edits);
+ // entry.Edits is SumType but AnnotatedTextEdit inherits from TextEdit, so we can just cast
+ var remappedEdits = RemapTextEditsCore(generatedDocumentUri, codeDocument, entry.Edits.Select(e => (TextEdit)e).ToArray());
if (remappedEdits.Length == 0)
{
// Nothing to do.
@@ -146,7 +146,7 @@ private async Task RemapTextDocumentEditsAsync(IDocumentSnap
{
Uri = razorDocumentUri,
},
- Edits = remappedEdits
+ Edits = remappedEdits.Select(e => new SumType(e)).ToArray()
});
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/DocumentPositionInfo.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/DocumentPositionInfo.cs
index bfdca6934f4..4acb0995bb3 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/DocumentPositionInfo.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/DocumentPositionInfo.cs
@@ -3,7 +3,6 @@
using System.Text.Json.Serialization;
using Microsoft.CodeAnalysis.Razor.Protocol;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.DocumentMapping;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/IDocumentMappingServiceExtensions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/IDocumentMappingServiceExtensions.cs
index e83f826b2ec..229ade4d819 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/IDocumentMappingServiceExtensions.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/IDocumentMappingServiceExtensions.cs
@@ -9,8 +9,6 @@
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.CodeAnalysis.Razor.Protocol;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
-using Range = Microsoft.VisualStudio.LanguageServer.Protocol.Range;
namespace Microsoft.CodeAnalysis.Razor.DocumentMapping;
@@ -29,7 +27,7 @@ public static TextEdit[] GetHostDocumentEdits(this IDocumentMappingService servi
public static bool TryMapToHostDocumentRange(this IDocumentMappingService service, IRazorGeneratedDocument generatedDocument, LinePositionSpan projectedRange, out LinePositionSpan originalRange)
=> service.TryMapToHostDocumentRange(generatedDocument, projectedRange, MappingBehavior.Strict, out originalRange);
- public static bool TryMapToHostDocumentRange(this IDocumentMappingService service, IRazorGeneratedDocument generatedDocument, Range projectedRange, [NotNullWhen(true)] out Range? originalRange)
+ public static bool TryMapToHostDocumentRange(this IDocumentMappingService service, IRazorGeneratedDocument generatedDocument, LspRange projectedRange, [NotNullWhen(true)] out LspRange? originalRange)
=> service.TryMapToHostDocumentRange(generatedDocument, projectedRange, MappingBehavior.Strict, out originalRange);
public static DocumentPositionInfo GetPositionInfo(
@@ -75,14 +73,14 @@ public static DocumentPositionInfo GetPositionInfo(
return new DocumentPositionInfo(languageKind, position, hostDocumentIndex);
}
- public static bool TryMapToHostDocumentRange(this IDocumentMappingService service, IRazorGeneratedDocument generatedDocument, Range generatedDocumentRange, MappingBehavior mappingBehavior, [NotNullWhen(true)] out Range? hostDocumentRange)
+ public static bool TryMapToHostDocumentRange(this IDocumentMappingService service, IRazorGeneratedDocument generatedDocument, LspRange generatedDocumentRange, MappingBehavior mappingBehavior, [NotNullWhen(true)] out LspRange? hostDocumentRange)
{
var result = service.TryMapToHostDocumentRange(generatedDocument, generatedDocumentRange.ToLinePositionSpan(), mappingBehavior, out var hostDocumentLinePositionSpan);
hostDocumentRange = result ? hostDocumentLinePositionSpan.ToRange() : null;
return result;
}
- public static bool TryMapToGeneratedDocumentRange(this IDocumentMappingService service, IRazorGeneratedDocument generatedDocument, Range hostDocumentRange, [NotNullWhen(true)] out Range? generatedDocumentRange)
+ public static bool TryMapToGeneratedDocumentRange(this IDocumentMappingService service, IRazorGeneratedDocument generatedDocument, LspRange hostDocumentRange, [NotNullWhen(true)] out LspRange? generatedDocumentRange)
{
var result = service.TryMapToGeneratedDocumentRange(generatedDocument, hostDocumentRange.ToLinePositionSpan(), out var generatedDocumentLinePositionSpan);
generatedDocumentRange = result ? generatedDocumentLinePositionSpan.ToRange() : null;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/IEditMappingService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/IEditMappingService.cs
index 0f186d239bc..8c85b5a7fb0 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/IEditMappingService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/IEditMappingService.cs
@@ -3,8 +3,7 @@
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
+using Microsoft.CodeAnalysis.Razor.ProjectSystem;
namespace Microsoft.CodeAnalysis.Razor.DocumentMapping;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/PreferHtmlInAttributeValuesDocumentPositionStrategy.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/PreferHtmlInAttributeValuesDocumentPositionStrategy.cs
index 7de3f5f7612..f063780797d 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/PreferHtmlInAttributeValuesDocumentPositionStrategy.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/PreferHtmlInAttributeValuesDocumentPositionStrategy.cs
@@ -5,7 +5,6 @@
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.Syntax;
using Microsoft.CodeAnalysis.Razor.Protocol;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.DocumentMapping;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/RangeComparer.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/RangeComparer.cs
index eafd7e047f8..405ad8f60d3 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/RangeComparer.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/RangeComparer.cs
@@ -2,15 +2,14 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Collections.Generic;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Workspaces.DocumentMapping;
-internal sealed class RangeComparer : IComparer
+internal sealed class RangeComparer : IComparer
{
public static readonly RangeComparer Instance = new();
- public int Compare(Range? x, Range? y)
+ public int Compare(LspRange? x, LspRange? y)
{
if (x is null)
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/RazorEditHelper.TextChangeBuilder.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/RazorEditHelper.TextChangeBuilder.cs
index cb906f5e489..857b70b9c55 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/RazorEditHelper.TextChangeBuilder.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/RazorEditHelper.TextChangeBuilder.cs
@@ -17,7 +17,6 @@
using Microsoft.CodeAnalysis.Razor.Protocol;
using Microsoft.CodeAnalysis.Text;
using Microsoft.Extensions.ObjectPool;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.DocumentMapping;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/RazorEditHelper.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/RazorEditHelper.cs
index 9b7b2d22948..16f66b4e81c 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/RazorEditHelper.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/RazorEditHelper.cs
@@ -8,11 +8,11 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.PooledObjects;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
-using Microsoft.AspNetCore.Razor.Telemetry;
using Microsoft.AspNetCore.Razor.Utilities;
using Microsoft.CodeAnalysis.Razor.Formatting;
+using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Protocol;
+using Microsoft.CodeAnalysis.Razor.Telemetry;
namespace Microsoft.CodeAnalysis.Razor.DocumentMapping;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/ClientCapabilitiesExtensions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/ClientCapabilitiesExtensions.cs
index e3d51e5a63f..12a856ef8e4 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/ClientCapabilitiesExtensions.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/ClientCapabilitiesExtensions.cs
@@ -3,7 +3,7 @@
using System;
-namespace Microsoft.VisualStudio.LanguageServer.Protocol;
+namespace Roslyn.LanguageServer.Protocol;
internal static class ClientCapabilitiesExtensions
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/RoslynLspExtensions_LinePosition.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_LinePosition.cs
similarity index 55%
rename from src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/RoslynLspExtensions_LinePosition.cs
rename to src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_LinePosition.cs
index 7401bd5ca1f..9e48d992ea0 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/RoslynLspExtensions_LinePosition.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_LinePosition.cs
@@ -5,8 +5,11 @@
namespace Roslyn.LanguageServer.Protocol;
-internal static partial class RoslynLspExtensions
+internal static partial class LspExtensions
{
public static Position ToPosition(this LinePosition linePosition)
- => RoslynLspFactory.CreatePosition(linePosition.Line, linePosition.Character);
+ => LspFactory.CreatePosition(linePosition.Line, linePosition.Character);
+
+ public static LspRange ToZeroWidthRange(this LinePosition position)
+ => LspFactory.CreateZeroWidthRange(position);
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/RoslynLspExtensions_LinePositionSpan.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_LinePositionSpan.cs
similarity index 56%
rename from src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/RoslynLspExtensions_LinePositionSpan.cs
rename to src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_LinePositionSpan.cs
index 2819933b95f..456a3f911a1 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/RoslynLspExtensions_LinePositionSpan.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_LinePositionSpan.cs
@@ -5,8 +5,8 @@
namespace Roslyn.LanguageServer.Protocol;
-internal static partial class RoslynLspExtensions
+internal static partial class LspExtensions
{
- public static Range ToRange(this LinePositionSpan linePositionSpan)
- => RoslynLspFactory.CreateRange(linePositionSpan);
+ public static LspRange ToRange(this LinePositionSpan linePositionSpan)
+ => LspFactory.CreateRange(linePositionSpan);
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/RoslynLspExtensions_Location.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_Location.cs
similarity index 66%
rename from src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/RoslynLspExtensions_Location.cs
rename to src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_Location.cs
index d79991b8e22..999eae90ccc 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/RoslynLspExtensions_Location.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_Location.cs
@@ -5,8 +5,8 @@
namespace Roslyn.LanguageServer.Protocol;
-internal static partial class RoslynLspExtensions
+internal static partial class LspExtensions
{
- public static void Deconstruct(this Location position, out Uri uri, out Range range)
+ public static void Deconstruct(this LspLocation position, out Uri uri, out LspRange range)
=> (uri, range) = (position.Uri, position.Range);
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_Position.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_Position.cs
similarity index 78%
rename from src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_Position.cs
rename to src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_Position.cs
index df93c93333f..efa8366d6d4 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_Position.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_Position.cs
@@ -3,9 +3,9 @@
using Microsoft.CodeAnalysis.Text;
-namespace Microsoft.VisualStudio.LanguageServer.Protocol;
+namespace Roslyn.LanguageServer.Protocol;
-internal static partial class VsLspExtensions
+internal static partial class LspExtensions
{
public static void Deconstruct(this Position position, out int line, out int character)
=> (line, character) = (position.Line, position.Character);
@@ -13,8 +13,8 @@ public static void Deconstruct(this Position position, out int line, out int cha
public static LinePosition ToLinePosition(this Position position)
=> new(position.Line, position.Character);
- public static Range ToZeroWidthRange(this Position position)
- => VsLspFactory.CreateZeroWidthRange(position);
+ public static LspRange ToZeroWidthRange(this Position position)
+ => LspFactory.CreateZeroWidthRange(position);
public static int CompareTo(this Position position, Position other)
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_Range.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_Range.cs
similarity index 63%
rename from src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_Range.cs
rename to src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_Range.cs
index 582e9b0bea5..0241f5566d6 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_Range.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_Range.cs
@@ -3,20 +3,20 @@
using Microsoft.CodeAnalysis.Text;
-namespace Microsoft.VisualStudio.LanguageServer.Protocol;
+namespace Roslyn.LanguageServer.Protocol;
-internal static partial class VsLspExtensions
+internal static partial class LspExtensions
{
- public static void Deconstruct(this Range range, out Position start, out Position end)
+ public static void Deconstruct(this LspRange range, out Position start, out Position end)
=> (start, end) = (range.Start, range.End);
- public static void Deconstruct(this Range range, out int startLine, out int startCharacter, out int endLine, out int endCharacter)
+ public static void Deconstruct(this LspRange range, out int startLine, out int startCharacter, out int endLine, out int endCharacter)
=> (startLine, startCharacter, endLine, endCharacter) = (range.Start.Line, range.Start.Character, range.End.Line, range.End.Character);
- public static LinePositionSpan ToLinePositionSpan(this Range range)
+ public static LinePositionSpan ToLinePositionSpan(this LspRange range)
=> new(range.Start.ToLinePosition(), range.End.ToLinePosition());
- public static bool IntersectsOrTouches(this Range range, Range other)
+ public static bool IntersectsOrTouches(this LspRange range, LspRange other)
{
if (range.IsBefore(other))
{
@@ -31,18 +31,18 @@ public static bool IntersectsOrTouches(this Range range, Range other)
return true;
}
- private static bool IsBefore(this Range range, Range other) =>
+ private static bool IsBefore(this LspRange range, LspRange other) =>
range.End.Line < other.Start.Line || (range.End.Line == other.Start.Line && range.End.Character < other.Start.Character);
- private static bool IsAfter(this Range range, Range other) =>
+ private static bool IsAfter(this LspRange range, LspRange other) =>
other.End.Line < range.Start.Line || (other.End.Line == range.Start.Line && other.End.Character < range.Start.Character);
- public static bool OverlapsWith(this Range range, Range other)
+ public static bool OverlapsWith(this LspRange range, LspRange other)
{
return range.ToLinePositionSpan().OverlapsWith(other.ToLinePositionSpan());
}
- public static bool LineOverlapsWith(this Range range, Range other)
+ public static bool LineOverlapsWith(this LspRange range, LspRange other)
{
var overlapStart = range.Start.Line;
if (range.Start.Line.CompareTo(other.Start.Line) < 0)
@@ -59,32 +59,32 @@ public static bool LineOverlapsWith(this Range range, Range other)
return overlapStart.CompareTo(overlapEnd) <= 0;
}
- public static bool Contains(this Range range, Range other)
+ public static bool Contains(this LspRange range, LspRange other)
{
return range.Start.CompareTo(other.Start) <= 0 && range.End.CompareTo(other.End) >= 0;
}
- public static bool SpansMultipleLines(this Range range)
+ public static bool SpansMultipleLines(this LspRange range)
{
return range.Start.Line != range.End.Line;
}
- public static bool IsSingleLine(this Range range)
+ public static bool IsSingleLine(this LspRange range)
{
return range.Start.Line == range.End.Line;
}
- public static bool IsUndefined(this Range range)
+ public static bool IsUndefined(this LspRange range)
{
- return range == VsLspFactory.UndefinedRange;
+ return range == LspFactory.UndefinedRange;
}
- public static bool IsZeroWidth(this Range range)
+ public static bool IsZeroWidth(this LspRange range)
{
return range.Start == range.End;
}
- public static int CompareTo(this Range range1, Range range2)
+ public static int CompareTo(this LspRange range1, LspRange range2)
{
var result = range1.Start.CompareTo(range2.Start);
@@ -96,7 +96,7 @@ public static int CompareTo(this Range range1, Range range2)
return result;
}
- public static Range? Overlap(this Range range, Range other)
+ public static LspRange? Overlap(this LspRange range, LspRange other)
{
var overlapStart = range.Start;
if (range.Start.CompareTo(other.Start) < 0)
@@ -113,12 +113,12 @@ public static int CompareTo(this Range range1, Range range2)
// Empty ranges do not overlap with any range.
if (overlapStart.CompareTo(overlapEnd) < 0)
{
- return VsLspFactory.CreateRange(overlapStart, overlapEnd);
+ return LspFactory.CreateRange(overlapStart, overlapEnd);
}
return null;
}
- public static string ToDisplayString(this Range range)
+ public static string ToDisplayString(this LspRange range)
=> $"{range.Start.ToDisplayString()}-{range.End.ToDisplayString()}";
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_RazorSyntaxTree.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_RazorSyntaxTree.cs
similarity index 87%
rename from src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_RazorSyntaxTree.cs
rename to src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_RazorSyntaxTree.cs
index 1bd0773e024..fa4d5f9b090 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_RazorSyntaxTree.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_RazorSyntaxTree.cs
@@ -5,9 +5,9 @@
using Microsoft.AspNetCore.Razor.Language.Syntax;
using Microsoft.CodeAnalysis.Text;
-namespace Microsoft.VisualStudio.LanguageServer.Protocol;
+namespace Roslyn.LanguageServer.Protocol;
-internal static partial class VsLspExtensions
+internal static partial class LspExtensions
{
public static SyntaxNode? FindInnermostNode(
this RazorSyntaxTree syntaxTree,
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_SourceText.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_SourceText.cs
similarity index 75%
rename from src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_SourceText.cs
rename to src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_SourceText.cs
index 1eff67c59aa..2238f9a204f 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_SourceText.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_SourceText.cs
@@ -4,9 +4,9 @@
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.CodeAnalysis.Text;
-namespace Microsoft.VisualStudio.LanguageServer.Protocol;
+namespace Roslyn.LanguageServer.Protocol;
-internal static partial class VsLspExtensions
+internal static partial class LspExtensions
{
public static int GetPosition(this SourceText text, Position position)
=> text.GetPosition(position.ToLinePosition());
@@ -14,16 +14,16 @@ public static int GetPosition(this SourceText text, Position position)
public static Position GetPosition(this SourceText text, int position)
=> text.GetLinePosition(position).ToPosition();
- public static Range GetRange(this SourceText text, TextSpan span)
+ public static LspRange GetRange(this SourceText text, TextSpan span)
=> text.GetLinePositionSpan(span).ToRange();
- public static Range GetRange(this SourceText text, SourceSpan span)
+ public static LspRange GetRange(this SourceText text, SourceSpan span)
=> text.GetLinePositionSpan(span).ToRange();
- public static Range GetRange(this SourceText text, int start, int end)
+ public static LspRange GetRange(this SourceText text, int start, int end)
=> text.GetLinePositionSpan(start, end).ToRange();
- public static Range GetZeroWidthRange(this SourceText text, int position)
+ public static LspRange GetZeroWidthRange(this SourceText text, int position)
=> text.GetLinePosition(position).ToZeroWidthRange();
public static bool IsValidPosition(this SourceText text, Position position)
@@ -35,7 +35,7 @@ public static bool TryGetAbsoluteIndex(this SourceText text, Position position,
public static int GetRequiredAbsoluteIndex(this SourceText text, Position position)
=> text.GetRequiredAbsoluteIndex(position.Line, position.Character);
- public static TextSpan GetTextSpan(this SourceText text, Range range)
+ public static TextSpan GetTextSpan(this SourceText text, LspRange range)
=> text.GetTextSpan(range.Start.Line, range.Start.Character, range.End.Line, range.End.Character);
public static bool TryGetSourceLocation(this SourceText text, Position position, out SourceLocation location)
@@ -45,5 +45,5 @@ public static TextChange GetTextChange(this SourceText text, TextEdit edit)
=> new(text.GetTextSpan(edit.Range), edit.NewText);
public static TextEdit GetTextEdit(this SourceText text, TextChange change)
- => VsLspFactory.CreateTextEdit(text.GetRange(change.Span), change.NewText ?? "");
+ => LspFactory.CreateTextEdit(text.GetRange(change.Span), change.NewText ?? "");
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_SumTypes.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_SumTypes.cs
similarity index 96%
rename from src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_SumTypes.cs
rename to src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_SumTypes.cs
index 6c75dd21d31..4a349e70091 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_SumTypes.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_SumTypes.cs
@@ -5,9 +5,9 @@
using System.Linq;
using Microsoft.AspNetCore.Razor;
-namespace Microsoft.VisualStudio.LanguageServer.Protocol;
+namespace Roslyn.LanguageServer.Protocol;
-internal static partial class VsLspExtensions
+internal static partial class LspExtensions
{
internal static int Count(this SumType[]> sumType)
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_SyntaxNode.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_SyntaxNode.cs
similarity index 59%
rename from src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_SyntaxNode.cs
rename to src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_SyntaxNode.cs
index a92ee4b4831..8602438b7dc 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_SyntaxNode.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_SyntaxNode.cs
@@ -5,14 +5,14 @@
using Microsoft.AspNetCore.Razor.Language.Syntax;
using Microsoft.CodeAnalysis.Text;
-namespace Microsoft.VisualStudio.LanguageServer.Protocol;
+namespace Roslyn.LanguageServer.Protocol;
-internal static partial class VsLspExtensions
+internal static partial class LspExtensions
{
- public static Range GetRange(this SyntaxNode node, RazorSourceDocument source)
+ public static LspRange GetRange(this SyntaxNode node, RazorSourceDocument source)
{
var linePositionSpan = node.GetLinePositionSpan(source);
- return VsLspFactory.CreateRange(linePositionSpan);
+ return LspFactory.CreateRange(linePositionSpan);
}
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_TextChange.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_TextChange.cs
similarity index 85%
rename from src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_TextChange.cs
rename to src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_TextChange.cs
index 5feb06ba64f..91c400b9eff 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_TextChange.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_TextChange.cs
@@ -4,9 +4,9 @@
using Microsoft.CodeAnalysis.Razor.Protocol;
using Microsoft.CodeAnalysis.Text;
-namespace Microsoft.VisualStudio.LanguageServer.Protocol;
+namespace Roslyn.LanguageServer.Protocol;
-internal static partial class VsLspExtensions
+internal static partial class LspExtensions
{
public static RazorTextChange ToRazorTextChange(this TextChange textChange)
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_TextDocumentIdentifier.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_TextDocumentIdentifier.cs
similarity index 92%
rename from src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_TextDocumentIdentifier.cs
rename to src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_TextDocumentIdentifier.cs
index f265744db95..991544ca22c 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_TextDocumentIdentifier.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_TextDocumentIdentifier.cs
@@ -4,9 +4,9 @@
using System;
using Microsoft.CodeAnalysis.ExternalAccess.Razor.Cohost;
-namespace Microsoft.VisualStudio.LanguageServer.Protocol;
+namespace Roslyn.LanguageServer.Protocol;
-internal static partial class VsLspExtensions
+internal static partial class LspExtensions
{
public static VSProjectContext? GetProjectContext(this TextDocumentIdentifier textDocumentIdentifier)
=> textDocumentIdentifier is VSTextDocumentIdentifier vsIdentifier
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_VSInternalClientCapabilities.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_VSInternalClientCapabilities.cs
similarity index 87%
rename from src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_VSInternalClientCapabilities.cs
rename to src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_VSInternalClientCapabilities.cs
index ef801c03cec..0d8e0aab7c3 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_VSInternalClientCapabilities.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_VSInternalClientCapabilities.cs
@@ -1,9 +1,9 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
-namespace Microsoft.VisualStudio.LanguageServer.Protocol;
+namespace Roslyn.LanguageServer.Protocol;
-internal static partial class VsLspExtensions
+internal static partial class LspExtensions
{
internal static VSInternalClientCapabilities ToVSInternalClientCapabilities(this ClientCapabilities clientCapabilities)
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_VSProjectContext.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_VSProjectContext.cs
similarity index 66%
rename from src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_VSProjectContext.cs
rename to src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_VSProjectContext.cs
index 959c14c116a..92856518504 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_VSProjectContext.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_VSProjectContext.cs
@@ -1,11 +1,11 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
-using Microsoft.AspNetCore.Razor.ProjectSystem;
+using Microsoft.CodeAnalysis.Razor.ProjectSystem;
-namespace Microsoft.VisualStudio.LanguageServer.Protocol;
+namespace Roslyn.LanguageServer.Protocol;
-internal static partial class VsLspExtensions
+internal static partial class LspExtensions
{
internal static ProjectKey ToProjectKey(this VSProjectContext projectContext)
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_WorkspaceEdit.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_WorkspaceEdit.cs
similarity index 92%
rename from src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_WorkspaceEdit.cs
rename to src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_WorkspaceEdit.cs
index 961a810f3de..875ba97e065 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_WorkspaceEdit.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspExtensions_WorkspaceEdit.cs
@@ -4,9 +4,9 @@
using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Razor.PooledObjects;
-namespace Microsoft.VisualStudio.LanguageServer.Protocol;
+namespace Roslyn.LanguageServer.Protocol;
-internal static partial class VsLspExtensions
+internal static partial class LspExtensions
{
public static bool TryGetTextDocumentEdits(this WorkspaceEdit workspaceEdit, [NotNullWhen(true)] out TextDocumentEdit[]? textDocumentEdits)
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspFactory.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspFactory.cs
similarity index 71%
rename from src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspFactory.cs
rename to src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspFactory.cs
index 53664af6b1f..1e565f32e3a 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspFactory.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LspFactory.cs
@@ -5,13 +5,13 @@
using System.Diagnostics;
using Microsoft.CodeAnalysis.Text;
-namespace Microsoft.VisualStudio.LanguageServer.Protocol;
+namespace Roslyn.LanguageServer.Protocol;
-internal static class VsLspFactory
+internal static class LspFactory
{
private static readonly Position s_defaultPosition = new(0, 0);
- private static readonly Range s_defaultRange = new()
+ private static readonly LspRange s_defaultRange = new()
{
Start = s_defaultPosition,
End = s_defaultPosition
@@ -19,7 +19,7 @@ internal static class VsLspFactory
private static readonly Position s_undefinedPosition = new(-1, -1);
- private static readonly Range s_undefinedRange = new()
+ private static readonly LspRange s_undefinedRange = new()
{
Start = s_undefinedPosition,
End = s_undefinedPosition
@@ -38,7 +38,7 @@ public static Position DefaultPosition
Debug.Assert(
defaultPosition.Line == 0 &&
defaultPosition.Character == 0,
- $"{nameof(VsLspFactory)}.{nameof(DefaultPosition)} has been corrupted. Current value: {defaultPosition.ToDisplayString()}");
+ $"{nameof(LspFactory)}.{nameof(DefaultPosition)} has been corrupted. Current value: {defaultPosition.ToDisplayString()}");
return defaultPosition;
}
@@ -48,7 +48,7 @@ public static Position DefaultPosition
/// Returns a for starting line 0 and character 0,
/// and ending line 0 and character 0.
///
- public static Range DefaultRange
+ public static LspRange DefaultRange
{
get
{
@@ -60,7 +60,7 @@ public static Range DefaultRange
defaultRange.Start.Character == 0 &&
defaultRange.End.Line == 0 &&
defaultRange.End.Character == 0,
- $"{nameof(VsLspFactory)}.{nameof(DefaultRange)} has been corrupted. Current value: {defaultRange.ToDisplayString()}");
+ $"{nameof(LspFactory)}.{nameof(DefaultRange)} has been corrupted. Current value: {defaultRange.ToDisplayString()}");
return defaultRange;
}
@@ -76,13 +76,13 @@ public static Position UndefinedPosition
Debug.Assert(
undefinedPosition.Line == -1 &&
undefinedPosition.Character == -1,
- $"{nameof(VsLspFactory)}.{nameof(UndefinedPosition)} has been corrupted. Current value: {undefinedPosition.ToDisplayString()}");
+ $"{nameof(LspFactory)}.{nameof(UndefinedPosition)} has been corrupted. Current value: {undefinedPosition.ToDisplayString()}");
return undefinedPosition;
}
}
- public static Range UndefinedRange
+ public static LspRange UndefinedRange
{
get
{
@@ -94,7 +94,7 @@ public static Range UndefinedRange
undefinedRange.Start.Character == -1 &&
undefinedRange.End.Line == -1 &&
undefinedRange.End.Character == -1,
- $"{nameof(VsLspFactory)}.{nameof(UndefinedRange)} has been corrupted. Current value: {undefinedRange.ToDisplayString()}");
+ $"{nameof(LspFactory)}.{nameof(UndefinedRange)} has been corrupted. Current value: {undefinedRange.ToDisplayString()}");
return undefinedRange;
}
@@ -114,24 +114,24 @@ public static Position CreatePosition(LinePosition linePosition)
public static Position CreatePosition((int line, int character) position)
=> CreatePosition(position.line, position.character);
- public static Range CreateRange(int startLine, int startCharacter, int endLine, int endCharacter)
+ public static LspRange CreateRange(int startLine, int startCharacter, int endLine, int endCharacter)
=> startLine == endLine && startCharacter == endCharacter
? CreateZeroWidthRange(startLine, startCharacter)
: CreateRange(CreatePosition(startLine, startCharacter), CreatePosition(endLine, endCharacter));
- public static Range CreateRange(Position start, Position end)
+ public static LspRange CreateRange(Position start, Position end)
=> new() { Start = start, End = end };
- public static Range CreateRange(LinePosition start, LinePosition end)
+ public static LspRange CreateRange(LinePosition start, LinePosition end)
=> CreateRange(start.Line, start.Character, end.Line, end.Character);
- public static Range CreateRange((int line, int character) start, (int line, int character) end)
+ public static LspRange CreateRange((int line, int character) start, (int line, int character) end)
=> CreateRange(start.line, start.character, end.line, end.character);
- public static Range CreateRange(LinePositionSpan span)
+ public static LspRange CreateRange(LinePositionSpan span)
=> CreateRange(span.Start, span.End);
- public static Range CreateZeroWidthRange(int line, int character)
+ public static LspRange CreateZeroWidthRange(int line, int character)
=> (line, character) switch
{
(0, 0) => DefaultRange,
@@ -139,39 +139,45 @@ public static Range CreateZeroWidthRange(int line, int character)
_ => CreateZeroWidthRange(CreatePosition(line, character))
};
- public static Range CreateZeroWidthRange(Position position)
+ public static LspRange CreateZeroWidthRange(Position position)
=> CreateRange(position, position);
- public static Range CreateZeroWidthRange(LinePosition position)
+ public static LspRange CreateZeroWidthRange(LinePosition position)
=> CreateRange(position, position);
- public static Range CreateZeroWidthRange((int line, int character) position)
+ public static LspRange CreateZeroWidthRange((int line, int character) position)
=> CreateRange(position, position);
- public static Range CreateSingleLineRange(int line, int character, int length)
+ public static LspRange CreateSingleLineRange(int line, int character, int length)
=> CreateRange(line, character, line, character + length);
- public static Range CreateSingleLineRange(Position start, int length)
+ public static LspRange CreateSingleLineRange(Position start, int length)
=> CreateRange(start, CreatePosition(start.Line, start.Character + length));
- public static Range CreateSingleLineRange(LinePosition start, int length)
+ public static LspRange CreateSingleLineRange(LinePosition start, int length)
=> CreateSingleLineRange(start.Line, start.Character, length);
- public static Range CreateSingleLineRange((int line, int character) start, int length)
+ public static LspRange CreateSingleLineRange((int line, int character) start, int length)
=> CreateRange(CreatePosition(start), CreatePosition(start.line, start.character + length));
- public static Location CreateLocation(string filePath, LinePositionSpan span)
+ public static LspLocation CreateLocation(string filePath, LinePositionSpan span)
=> CreateLocation(CreateFilePathUri(filePath), CreateRange(span));
- public static Location CreateLocation(Uri uri, LinePositionSpan span)
+ public static LspLocation CreateLocation(Uri uri, LinePositionSpan span)
=> CreateLocation(uri, CreateRange(span));
- public static Location CreateLocation(string filePath, Range range)
+ public static LspLocation CreateLocation(string filePath, LspRange range)
=> CreateLocation(CreateFilePathUri(filePath), range);
- public static Location CreateLocation(Uri uri, Range range)
+ public static LspLocation CreateLocation(Uri uri, LspRange range)
=> new() { Uri = uri, Range = range };
+ public static DocumentLink CreateDocumentLink(Uri target, LspRange range)
+ => new() { Target = target, Range = range };
+
+ public static DocumentLink CreateDocumentLink(Uri target, LinePositionSpan span)
+ => new() { Target = target, Range = CreateRange(span) };
+
public static TextEdit CreateTextEdit(Range range, string newText)
=> new() { Range = range, NewText = newText };
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/ProjectExtensions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/ProjectExtensions.cs
index bd6e3c0f7b4..710747ccbce 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/ProjectExtensions.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/ProjectExtensions.cs
@@ -11,9 +11,9 @@
using Microsoft.AspNetCore.Razor;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.PooledObjects;
-using Microsoft.AspNetCore.Razor.Telemetry;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
+using Microsoft.CodeAnalysis.Razor.Telemetry;
namespace Microsoft.CodeAnalysis;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/RazorCodeDocumentExtensions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/RazorCodeDocumentExtensions.cs
index a563aa045c4..26ecac7bf81 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/RazorCodeDocumentExtensions.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/RazorCodeDocumentExtensions.cs
@@ -21,33 +21,6 @@ namespace Microsoft.AspNetCore.Razor.Language;
internal static class RazorCodeDocumentExtensions
{
private static readonly object s_csharpSyntaxTreeKey = new();
- private static readonly object s_unsupportedKey = new();
-
- public static bool IsUnsupported(this RazorCodeDocument document)
- {
- if (document is null)
- {
- throw new ArgumentNullException(nameof(document));
- }
-
- var unsupportedObj = document.Items[s_unsupportedKey];
- if (unsupportedObj is null)
- {
- return false;
- }
-
- return (bool)unsupportedObj;
- }
-
- public static void SetUnsupported(this RazorCodeDocument document)
- {
- if (document is null)
- {
- throw new ArgumentNullException(nameof(document));
- }
-
- document.Items[s_unsupportedKey] = true;
- }
public static RazorSyntaxTree GetRequiredSyntaxTree(this RazorCodeDocument codeDocument)
=> codeDocument.GetSyntaxTree().AssumeNotNull();
@@ -55,9 +28,6 @@ public static RazorSyntaxTree GetRequiredSyntaxTree(this RazorCodeDocument codeD
public static Syntax.SyntaxNode GetRequiredSyntaxRoot(this RazorCodeDocument codeDocument)
=> codeDocument.GetRequiredSyntaxTree().Root;
- public static TagHelperDocumentContext GetRequiredTagHelperContext(this RazorCodeDocument codeDocument)
- => codeDocument.GetTagHelperContext().AssumeNotNull();
-
public static SourceText GetCSharpSourceText(this RazorCodeDocument document)
=> document.GetCSharpDocument().Text;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/RazorSyntaxNodeExtensions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/RazorSyntaxNodeExtensions.cs
index 1d350ab5a22..96a04ec822a 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/RazorSyntaxNodeExtensions.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/RazorSyntaxNodeExtensions.cs
@@ -8,7 +8,6 @@
using Microsoft.AspNetCore.Razor.Language.Extensions;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.AspNetCore.Razor.Language.Syntax;
@@ -199,7 +198,7 @@ public static LinePositionSpan GetLinePositionSpan(this SyntaxNode node, RazorSo
Debug.Assert(start <= sourceText.Length && end <= sourceText.Length, "Node position exceeds source length.");
- if (start == sourceText.Length && node.FullWidth == 0)
+ if (start == sourceText.Length && node.Width == 0)
{
// Marker symbol at the end of the document.
var location = node.GetSourceLocation(sourceDocument);
@@ -257,14 +256,14 @@ public static LinePositionSpan GetLinePositionSpan(this SyntaxNode node, RazorSo
public static SyntaxNode? FindNode(this SyntaxNode @this, TextSpan span, bool includeWhitespace = false, bool getInnermostNodeForTie = false)
{
- if (!@this.FullSpan.Contains(span))
+ if (!@this.Span.Contains(span))
{
return ThrowHelper.ThrowArgumentOutOfRangeException(nameof(span));
}
var node = @this.FindToken(span.Start, includeWhitespace)
.Parent!
- .FirstAncestorOrSelf(a => a.FullSpan.Contains(span));
+ .FirstAncestorOrSelf(a => a.Span.Contains(span));
node.AssumeNotNull();
@@ -283,7 +282,7 @@ public static LinePositionSpan GetLinePositionSpan(this SyntaxNode node, RazorSo
{
var parent = node.Parent;
// NOTE: We care about FullSpan equality, but FullWidth is cheaper and equivalent.
- if (parent == null || parent.FullWidth != node.FullWidth)
+ if (parent == null || parent.Width != node.Width)
{
break;
}
@@ -305,10 +304,10 @@ public static bool ExistsOnTarget(this SyntaxNode node, SyntaxNode target)
{
// TODO: This looks like a potential allocation hotspot and performance bottleneck.
- var nodeString = node.RemoveEmptyNewLines().ToFullString();
+ var nodeString = node.RemoveEmptyNewLines().ToString();
var matchingNode = target.DescendantNodesAndSelf()
// Empty new lines can affect our comparison so we remove them since they're insignificant.
- .Where(n => n.RemoveEmptyNewLines().ToFullString() == nodeString)
+ .Where(n => n.RemoveEmptyNewLines().ToString() == nodeString)
.FirstOrDefault();
return matchingNode is not null;
@@ -353,7 +352,7 @@ CSharpExplicitExpressionSyntax or
// code {
// var foo = "bar";
// }
- var directive = body.Keyword.ToFullString();
+ var directive = body.Keyword.ToString();
if (directive != "code")
{
return false;
@@ -473,7 +472,7 @@ static LinePositionSpan GetLinePositionSpan(SyntaxNode node, RazorSourceDocument
var start = node.Position + parentStart;
var end = node.EndPosition + parentStart;
- if (start == sourceText.Length && node.FullWidth == 0)
+ if (start == sourceText.Length && node.Width == 0)
{
// Marker symbol at the end of the document.
var location = node.GetSourceLocation(source);
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/RoslynLspExtensions_Position.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/RoslynLspExtensions_Position.cs
deleted file mode 100644
index e4cd3c1ac93..00000000000
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/RoslynLspExtensions_Position.cs
+++ /dev/null
@@ -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.Text;
-
-namespace Roslyn.LanguageServer.Protocol;
-
-internal static partial class RoslynLspExtensions
-{
- public static LinePosition ToLinePosition(this Position position)
- => new(position.Line, position.Character);
-
- public static string ToDisplayString(this Position position)
- => $"({position.Line}, {position.Character})";
-}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/RoslynLspExtensions_Range.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/RoslynLspExtensions_Range.cs
deleted file mode 100644
index af7e54346c8..00000000000
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/RoslynLspExtensions_Range.cs
+++ /dev/null
@@ -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.Text;
-
-namespace Roslyn.LanguageServer.Protocol;
-
-internal static partial class RoslynLspExtensions
-{
- public static LinePositionSpan ToLinePositionSpan(this Range range)
- => new(range.Start.ToLinePosition(), range.End.ToLinePosition());
-
- public static string ToDisplayString(this Range range)
- => $"{range.Start.ToDisplayString()}-{range.End.ToDisplayString()}";
-}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/RoslynLspExtensions_SourceText.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/RoslynLspExtensions_SourceText.cs
deleted file mode 100644
index 2a7b95f56e3..00000000000
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/RoslynLspExtensions_SourceText.cs
+++ /dev/null
@@ -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 Microsoft.CodeAnalysis.Text;
-
-namespace Roslyn.LanguageServer.Protocol;
-
-internal static partial class RoslynLspExtensions
-{
- public static int GetPosition(this SourceText text, Position position)
- => text.GetPosition(position.ToLinePosition());
-
- public static Position GetPosition(this SourceText text, int position)
- => text.GetLinePosition(position).ToPosition();
-
- public static Range GetRange(this SourceText text, TextSpan span)
- => text.GetLinePositionSpan(span).ToRange();
-
- public static bool TryGetAbsoluteIndex(this SourceText text, Position position, out int absoluteIndex)
- => text.TryGetAbsoluteIndex(position.Line, position.Character, out absoluteIndex);
-
- public static int GetRequiredAbsoluteIndex(this SourceText text, Position position)
- => text.GetRequiredAbsoluteIndex(position.Line, position.Character);
-
- public static TextSpan GetTextSpan(this SourceText text, Range range)
- => text.GetTextSpan(range.Start.Line, range.Start.Character, range.End.Line, range.End.Character);
-
- public static TextChange GetTextChange(this SourceText text, TextEdit edit)
- => new(text.GetTextSpan(edit.Range), edit.NewText);
-
- public static TextEdit GetTextEdit(this SourceText text, TextChange change)
- => RoslynLspFactory.CreateTextEdit(text.GetRange(change.Span), change.NewText ?? "");
-}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/RoslynLspExtensions_TextDocumentIdentifier.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/RoslynLspExtensions_TextDocumentIdentifier.cs
deleted file mode 100644
index 1d610d572d3..00000000000
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/RoslynLspExtensions_TextDocumentIdentifier.cs
+++ /dev/null
@@ -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.ExternalAccess.Razor.Cohost;
-
-namespace Roslyn.LanguageServer.Protocol;
-
-internal static partial class RoslynLspExtensions
-{
- ///
- /// Returns a copy of the passed in with the passed in .
- ///
- public static TextDocumentIdentifier WithUri(this TextDocumentIdentifier textDocumentIdentifier, Uri uri)
- {
- if (textDocumentIdentifier is VSTextDocumentIdentifier vsTdi)
- {
- return new VSTextDocumentIdentifier
- {
- Uri = uri,
- ProjectContext = vsTdi.ProjectContext
- };
- }
-
- return new TextDocumentIdentifier
- {
- Uri = uri
- };
- }
-
- public static RazorTextDocumentIdentifier ToRazorTextDocumentIdentifier(this TextDocumentIdentifier textDocumentIdentifier)
- => new RazorTextDocumentIdentifier(textDocumentIdentifier.Uri, (textDocumentIdentifier as VSTextDocumentIdentifier)?.ProjectContext?.Id);
-}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/RoslynLspFactory.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/RoslynLspFactory.cs
deleted file mode 100644
index f26c4feb903..00000000000
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/RoslynLspFactory.cs
+++ /dev/null
@@ -1,204 +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;
-using Microsoft.CodeAnalysis.Text;
-
-namespace Roslyn.LanguageServer.Protocol;
-
-internal static class RoslynLspFactory
-{
- private static readonly Position s_defaultPosition = new(0, 0);
-
- private static readonly Range s_defaultRange = new()
- {
- Start = s_defaultPosition,
- End = s_defaultPosition
- };
-
- private static readonly Position s_undefinedPosition = new(-1, -1);
-
- private static readonly Range s_undefinedRange = new()
- {
- Start = s_undefinedPosition,
- End = s_undefinedPosition
- };
-
- ///
- /// Returns a for line 0 and character 0.
- ///
- public static Position DefaultPosition
- {
- get
- {
- var defaultPosition = s_defaultPosition;
-
- // Since Position is mutable, it's possible that something might modify it. If that happens, we should know!
- Debug.Assert(
- defaultPosition.Line == 0 &&
- defaultPosition.Character == 0,
- $"{nameof(RoslynLspFactory)}.{nameof(DefaultPosition)} has been corrupted. Current value: {defaultPosition.ToDisplayString()}");
-
- return defaultPosition;
- }
- }
-
- ///
- /// Returns a for starting line 0 and character 0,
- /// and ending line 0 and character 0.
- ///
- public static Range DefaultRange
- {
- get
- {
- var defaultRange = s_defaultRange;
-
- // Since Range is mutable, it's possible that something might modify it. If that happens, we should know!
- Debug.Assert(
- defaultRange.Start.Line == 0 &&
- defaultRange.Start.Character == 0 &&
- defaultRange.End.Line == 0 &&
- defaultRange.End.Character == 0,
- $"{nameof(RoslynLspFactory)}.{nameof(DefaultRange)} has been corrupted. Current value: {defaultRange.ToDisplayString()}");
-
- return defaultRange;
- }
- }
-
- public static Position UndefinedPosition
- {
- get
- {
- var undefinedPosition = s_undefinedPosition;
-
- // Since Position is mutable, it's possible that something might modify it. If that happens, we should know!
- Debug.Assert(
- undefinedPosition.Line == -1 &&
- undefinedPosition.Character == -1,
- $"{nameof(RoslynLspFactory)}.{nameof(UndefinedPosition)} has been corrupted. Current value: {undefinedPosition.ToDisplayString()}");
-
- return undefinedPosition;
- }
- }
-
- public static Range UndefinedRange
- {
- get
- {
- var undefinedRange = s_undefinedRange;
-
- // Since Range is mutable, it's possible that something might modify it. If that happens, we should know!
- Debug.Assert(
- undefinedRange.Start.Line == -1 &&
- undefinedRange.Start.Character == -1 &&
- undefinedRange.End.Line == -1 &&
- undefinedRange.End.Character == -1,
- $"{nameof(RoslynLspFactory)}.{nameof(UndefinedRange)} has been corrupted. Current value: {undefinedRange.ToDisplayString()}");
-
- return undefinedRange;
- }
- }
-
- public static Position CreatePosition(int line, int character)
- => (line, character) switch
- {
- (0, 0) => DefaultPosition,
- (-1, -1) => UndefinedPosition,
- _ => new(line, character)
- };
-
- public static Position CreatePosition(LinePosition linePosition)
- => CreatePosition(linePosition.Line, linePosition.Character);
-
- public static Position CreatePosition((int line, int character) position)
- => CreatePosition(position.line, position.character);
-
- public static Range CreateRange(int startLine, int startCharacter, int endLine, int endCharacter)
- => startLine == endLine && startCharacter == endCharacter
- ? CreateZeroWidthRange(startLine, startCharacter)
- : CreateRange(CreatePosition(startLine, startCharacter), CreatePosition(endLine, endCharacter));
-
- public static Range CreateRange(Position start, Position end)
- => new() { Start = start, End = end };
-
- public static Range CreateRange(LinePosition start, LinePosition end)
- => CreateRange(start.Line, start.Character, end.Line, end.Character);
-
- public static Range CreateRange((int line, int character) start, (int line, int character) end)
- => CreateRange(start.line, start.character, end.line, end.character);
-
- public static Range CreateRange(LinePositionSpan span)
- => CreateRange(span.Start, span.End);
-
- public static Range CreateZeroWidthRange(int line, int character)
- => (line, character) switch
- {
- (0, 0) => DefaultRange,
- (-1, -1) => UndefinedRange,
- _ => CreateZeroWidthRange(CreatePosition(line, character))
- };
-
- public static Range CreateZeroWidthRange(Position position)
- => CreateRange(position, position);
-
- public static Range CreateZeroWidthRange(LinePosition position)
- => CreateRange(position, position);
-
- public static Range CreateZeroWidthRange((int line, int character) position)
- => CreateRange(position, position);
-
- public static Range CreateSingleLineRange(int line, int character, int length)
- => CreateRange(line, character, line, character + length);
-
- public static Range CreateSingleLineRange(Position start, int length)
- => CreateRange(start, CreatePosition(start.Line, start.Character + length));
-
- public static Range CreateSingleLineRange(LinePosition start, int length)
- => CreateSingleLineRange(start.Line, start.Character, length);
-
- public static Range CreateSingleLineRange((int line, int character) start, int length)
- => CreateRange(CreatePosition(start), CreatePosition(start.line, start.character + length));
-
- public static Location CreateLocation(Uri uri, Range range)
- => new() { Uri = uri, Range = range };
-
- public static Location CreateLocation(Uri uri, LinePositionSpan span)
- => new() { Uri = uri, Range = CreateRange(span) };
-
- public static DocumentLink CreateDocumentLink(Uri target, Range range)
- => new() { Target = target, Range = range };
-
- public static DocumentLink CreateDocumentLink(Uri target, LinePositionSpan span)
- => new() { Target = target, Range = CreateRange(span) };
-
- public static TextEdit CreateTextEdit(Range range, string newText)
- => new() { Range = range, NewText = newText };
-
- public static TextEdit CreateTextEdit(LinePositionSpan span, string newText)
- => CreateTextEdit(CreateRange(span), newText);
-
- public static TextEdit CreateTextEdit(int startLine, int startCharacter, int endLine, int endCharacter, string newText)
- => CreateTextEdit(CreateRange(startLine, startCharacter, endLine, endCharacter), newText);
-
- public static TextEdit CreateTextEdit(Position start, Position end, string newText)
- => CreateTextEdit(CreateRange(start, end), newText);
-
- public static TextEdit CreateTextEdit(LinePosition start, LinePosition end, string newText)
- => CreateTextEdit(CreateRange(start, end), newText);
-
- public static TextEdit CreateTextEdit((int line, int character) start, (int line, int character) end, string newText)
- => CreateTextEdit(CreateRange(start, end), newText);
-
- public static TextEdit CreateTextEdit(int line, int character, string newText)
- => CreateTextEdit(CreateZeroWidthRange(line, character), newText);
-
- public static TextEdit CreateTextEdit(Position position, string newText)
- => CreateTextEdit(CreateZeroWidthRange(position), newText);
-
- public static TextEdit CreateTextEdit(LinePosition position, string newText)
- => CreateTextEdit(CreateZeroWidthRange(position.Line, position.Character), newText);
-
- public static TextEdit CreateTextEdit((int line, int character) position, string newText)
- => CreateTextEdit(CreateZeroWidthRange(position), newText);
-}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/SolutionExtensions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/SolutionExtensions.cs
index ee91e733f94..80b90e68eeb 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/SolutionExtensions.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/SolutionExtensions.cs
@@ -6,8 +6,8 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Microsoft.AspNetCore.Razor;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor;
+using Microsoft.CodeAnalysis.Razor.ProjectSystem;
namespace Microsoft.CodeAnalysis;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/SourceTextExtensions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/SourceTextExtensions.cs
index 6d0289525e2..390dbf9e25c 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/SourceTextExtensions.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/SourceTextExtensions.cs
@@ -7,7 +7,7 @@
using System.Collections.Immutable;
using Microsoft.AspNetCore.Razor;
using Microsoft.AspNetCore.Razor.Language;
-using Microsoft.AspNetCore.Razor.TextDifferencing;
+using Microsoft.CodeAnalysis.Razor.TextDifferencing;
using Microsoft.CodeAnalysis.Razor.Workspaces;
namespace Microsoft.CodeAnalysis.Text;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_LinePosition.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_LinePosition.cs
deleted file mode 100644
index 8beb8510be0..00000000000
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_LinePosition.cs
+++ /dev/null
@@ -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.Text;
-
-namespace Microsoft.VisualStudio.LanguageServer.Protocol;
-
-internal static partial class VsLspExtensions
-{
- public static Position ToPosition(this LinePosition linePosition)
- => VsLspFactory.CreatePosition(linePosition.Line, linePosition.Character);
-
- public static Range ToZeroWidthRange(this LinePosition position)
- => VsLspFactory.CreateZeroWidthRange(position);
-}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_LinePositionSpan.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_LinePositionSpan.cs
deleted file mode 100644
index 270532bb5ab..00000000000
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_LinePositionSpan.cs
+++ /dev/null
@@ -1,12 +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.Text;
-
-namespace Microsoft.VisualStudio.LanguageServer.Protocol;
-
-internal static partial class VsLspExtensions
-{
- public static Range ToRange(this LinePositionSpan linePositionSpan)
- => VsLspFactory.CreateRange(linePositionSpan);
-}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_Location.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_Location.cs
deleted file mode 100644
index e3d77984aae..00000000000
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/VsLspExtensions_Location.cs
+++ /dev/null
@@ -1,12 +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;
-
-namespace Microsoft.VisualStudio.LanguageServer.Protocol;
-
-internal static partial class VsLspExtensions
-{
- public static void Deconstruct(this Location position, out Uri uri, out Range range)
- => (uri, range) = (position.Uri, position.Range);
-}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/FoldingRanges/AbstractSyntaxNodeFoldingProvider.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/FoldingRanges/AbstractSyntaxNodeFoldingProvider.cs
index 58e81b4112c..7e5faab25e3 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/FoldingRanges/AbstractSyntaxNodeFoldingProvider.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/FoldingRanges/AbstractSyntaxNodeFoldingProvider.cs
@@ -6,7 +6,6 @@
using Microsoft.AspNetCore.Razor.Language.Syntax;
using Microsoft.AspNetCore.Razor.PooledObjects;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.FoldingRanges;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/FoldingRanges/FoldingRangeService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/FoldingRanges/FoldingRangeService.cs
index 194ccb94d8c..3d8fe10f550 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/FoldingRanges/FoldingRangeService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/FoldingRanges/FoldingRangeService.cs
@@ -12,7 +12,6 @@
using Microsoft.CodeAnalysis.Razor.DocumentMapping;
using Microsoft.CodeAnalysis.Razor.Logging;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.FoldingRanges;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/FoldingRanges/IFoldingRangeService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/FoldingRanges/IFoldingRangeService.cs
index 2f28b71db11..681cc651fbb 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/FoldingRanges/IFoldingRangeService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/FoldingRanges/IFoldingRangeService.cs
@@ -4,7 +4,6 @@
using System.Collections.Immutable;
using System.Threading;
using Microsoft.AspNetCore.Razor.Language;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.FoldingRanges;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/FoldingRanges/IRazorFoldingRangeProvider.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/FoldingRanges/IRazorFoldingRangeProvider.cs
index 857d6f4e8bc..e2bba9fb000 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/FoldingRanges/IRazorFoldingRangeProvider.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/FoldingRanges/IRazorFoldingRangeProvider.cs
@@ -3,7 +3,6 @@
using System.Collections.Immutable;
using Microsoft.AspNetCore.Razor.Language;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.FoldingRanges;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/FoldingRanges/RazorFileUsingsFoldingSyntaxWalker.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/FoldingRanges/RazorFileUsingsFoldingSyntaxWalker.cs
index 6dd4a046bf8..6d0618f0535 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/FoldingRanges/RazorFileUsingsFoldingSyntaxWalker.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/FoldingRanges/RazorFileUsingsFoldingSyntaxWalker.cs
@@ -3,7 +3,6 @@
using System.Collections.Generic;
using Microsoft.AspNetCore.Razor.Language;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.FoldingRanges;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/FoldingRanges/UsingsFoldingRangeProvider.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/FoldingRanges/UsingsFoldingRangeProvider.cs
index b04767e106f..925e70e64f2 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/FoldingRanges/UsingsFoldingRangeProvider.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/FoldingRanges/UsingsFoldingRangeProvider.cs
@@ -4,7 +4,6 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using Microsoft.AspNetCore.Razor.Language;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.FoldingRanges;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/AddUsingsHelper.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/AddUsingsHelper.cs
index ca76efbb5cb..e5df454ffcb 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/AddUsingsHelper.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/AddUsingsHelper.cs
@@ -19,7 +19,6 @@
using Microsoft.AspNetCore.Razor.PooledObjects;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
using RazorSyntaxNode = Microsoft.AspNetCore.Razor.Language.Syntax.SyntaxNode;
namespace Microsoft.CodeAnalysis.Razor.Formatting;
@@ -57,7 +56,7 @@ public static async Task GetUsingStatementEditsAsync(RazorCodeDocume
Debug.Assert(codeDocument.Source.FilePath != null);
var identifier = new OptionalVersionedTextDocumentIdentifier { Uri = new Uri(codeDocument.Source.FilePath, UriKind.Relative) };
var workspaceEdit = CreateAddUsingWorkspaceEdit(usingStatement, additionalEdit: null, codeDocument, codeDocumentIdentifier: identifier);
- edits.AddRange(workspaceEdit.DocumentChanges!.Value.First.First().Edits);
+ edits.AddRange(workspaceEdit.DocumentChanges!.Value.First.First().Edits.Select(e => (TextEdit)e));
}
return edits.ToArray();
@@ -174,7 +173,7 @@ private static TextDocumentEdit GenerateSingleUsingEditsInterpolated(
{
Debug.Assert(existingUsingDirectives.Count > 0);
- using var edits = new PooledArrayBuilder();
+ using var edits = new PooledArrayBuilder>();
var newText = $"@using {newUsingNamespace}{Environment.NewLine}";
foreach (var usingDirective in existingUsingDirectives)
@@ -189,7 +188,7 @@ private static TextDocumentEdit GenerateSingleUsingEditsInterpolated(
if (string.CompareOrdinal(newUsingNamespace, usingDirectiveNamespace) < 0)
{
var usingDirectiveLineIndex = codeDocument.Source.Text.GetLinePosition(usingDirective.Node.Span.Start).Line;
- var edit = VsLspFactory.CreateTextEdit(line: usingDirectiveLineIndex, character: 0, newText);
+ var edit = LspFactory.CreateTextEdit(line: usingDirectiveLineIndex, character: 0, newText);
edits.Add(edit);
break;
}
@@ -200,7 +199,7 @@ private static TextDocumentEdit GenerateSingleUsingEditsInterpolated(
{
var endIndex = existingUsingDirectives[^1].Node.Span.End;
var lineIndex = GetLineIndexOrEnd(codeDocument, endIndex - 1) + 1;
- var edit = VsLspFactory.CreateTextEdit(line: lineIndex, character: 0, newText);
+ var edit = LspFactory.CreateTextEdit(line: lineIndex, character: 0, newText);
edits.Add(edit);
}
@@ -234,7 +233,7 @@ private static TextDocumentEdit GenerateSingleUsingEditsAtTop(
return new TextDocumentEdit
{
TextDocument = codeDocumentIdentifier,
- Edits = [VsLspFactory.CreateTextEdit(insertPosition, newText: $"@using {newUsingNamespace}{Environment.NewLine}")]
+ Edits = [LspFactory.CreateTextEdit(insertPosition, newText: $"@using {newUsingNamespace}{Environment.NewLine}")]
};
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/CSharpFormatter.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/CSharpFormatter.cs
index 095f2504df8..2b98430e686 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/CSharpFormatter.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/CSharpFormatter.cs
@@ -14,7 +14,6 @@
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Razor.DocumentMapping;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Formatting;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/FormattingContext.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/FormattingContext.cs
index 14cd4e20f00..f3c0f6eed47 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/FormattingContext.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/FormattingContext.cs
@@ -11,11 +11,9 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.Syntax;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Formatting;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/FormattingUtilities.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/FormattingUtilities.cs
index 53c28cf761b..58602838b5a 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/FormattingUtilities.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/FormattingUtilities.cs
@@ -10,7 +10,6 @@
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.PooledObjects;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Formatting;
@@ -294,9 +293,9 @@ static int GetIndentation(TextLine line)
static bool IsWhitespace(char c)
=> c == ' ' || c == '\t';
- static ImmutableArray GetLineRanges(string text)
+ static ImmutableArray GetLineRanges(string text)
{
- using var builder = new PooledArrayBuilder();
+ using var builder = new PooledArrayBuilder();
var start = 0;
var end = text.IndexOf('\n');
while (true)
@@ -338,4 +337,16 @@ public static TextEdit[] FixHtmlTextEdits(SourceText htmlSourceText, TextEdit[]
var fixedChanges = htmlSourceText.MinimizeTextChanges(changes);
return [.. fixedChanges.Select(htmlSourceText.GetTextEdit)];
}
+
+ internal static SumType[] FixHtmlTextEdits(SourceText htmlSourceText, SumType[] edits)
+ {
+ // Avoid computing a minimal diff if we don't need to
+ if (!edits.Any(static e => ((TextEdit)e).NewText.Contains("~")))
+ return edits;
+
+ var changes = edits.SelectAsArray(e => htmlSourceText.GetTextChange((TextEdit)e));
+
+ var fixedChanges = htmlSourceText.MinimizeTextChanges(changes);
+ return [.. fixedChanges.Select(htmlSourceText.GetTextEdit)];
+ }
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/FormattingVisitor.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/FormattingVisitor.cs
index 112a2694ac3..37bbbfc0290 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/FormattingVisitor.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/FormattingVisitor.cs
@@ -490,8 +490,8 @@ private void WriteSpan(SyntaxNode node, FormattingSpanKind kind)
Assumes.NotNull(_currentBlock);
- var spanSource = new TextSpan(node.Position, node.FullWidth);
- var blockSource = new TextSpan(_currentBlock.Position, _currentBlock.FullWidth);
+ var spanSource = new TextSpan(node.Position, node.Width);
+ var blockSource = new TextSpan(_currentBlock.Position, _currentBlock.Width);
var span = new FormattingSpan(
spanSource,
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/Passes/CSharpFormattingPassBase.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/Passes/CSharpFormattingPassBase.cs
index 63d5d27cdd6..5d1136312c3 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/Passes/CSharpFormattingPassBase.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/Passes/CSharpFormattingPassBase.cs
@@ -18,7 +18,6 @@
using Microsoft.CodeAnalysis.Razor.Logging;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
using RazorSyntaxNode = Microsoft.AspNetCore.Razor.Language.Syntax.SyntaxNode;
namespace Microsoft.CodeAnalysis.Razor.Formatting;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/Passes/CSharpOnTypeFormattingPass.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/Passes/CSharpOnTypeFormattingPass.cs
index 5483dbc8804..41c66e206f3 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/Passes/CSharpOnTypeFormattingPass.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/Passes/CSharpOnTypeFormattingPass.cs
@@ -19,7 +19,6 @@
using Microsoft.CodeAnalysis.Razor.Logging;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Formatting;
@@ -193,11 +192,6 @@ protected async override Task> ExecuteCoreAsync(Forma
private ImmutableArray RemapTextChanges(RazorCodeDocument codeDocument, ImmutableArray projectedTextChanges)
{
- if (codeDocument.IsUnsupported())
- {
- return [];
- }
-
var changes = DocumentMappingService.GetHostDocumentEdits(codeDocument.GetCSharpDocument(), projectedTextChanges);
return changes.ToImmutableArray();
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/Passes/HtmlFormattingPassBase.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/Passes/HtmlFormattingPassBase.cs
index 14220eef2e3..6039a9b00ea 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/Passes/HtmlFormattingPassBase.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/Passes/HtmlFormattingPassBase.cs
@@ -11,7 +11,6 @@
using Microsoft.AspNetCore.Razor.PooledObjects;
using Microsoft.CodeAnalysis.Razor.Logging;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Formatting;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/Passes/New/HtmlFormattingPass.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/Passes/New/HtmlFormattingPass.cs
index 58907d493a1..9df5663a258 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/Passes/New/HtmlFormattingPass.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/Passes/New/HtmlFormattingPass.cs
@@ -9,7 +9,6 @@
using Microsoft.AspNetCore.Razor.PooledObjects;
using Microsoft.CodeAnalysis.Razor.Logging;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Formatting.New;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/Passes/RazorFormattingPass.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/Passes/RazorFormattingPass.cs
index dc3e3eefce3..74a796bcab5 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/Passes/RazorFormattingPass.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/Passes/RazorFormattingPass.cs
@@ -17,7 +17,6 @@
using Microsoft.CodeAnalysis.Razor.Logging;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
using RazorRazorSyntaxNodeList = Microsoft.AspNetCore.Razor.Language.Syntax.SyntaxList;
using RazorSyntaxNode = Microsoft.AspNetCore.Razor.Language.Syntax.SyntaxNode;
using RazorSyntaxNodeList = Microsoft.AspNetCore.Razor.Language.Syntax.SyntaxList;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingOptions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingOptions.cs
index 367639abf22..cf7e9f9f7b1 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingOptions.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingOptions.cs
@@ -3,8 +3,6 @@
using System.Runtime.Serialization;
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
-using RoslynFormattingOptions = Roslyn.LanguageServer.Protocol.FormattingOptions;
namespace Microsoft.CodeAnalysis.Razor.Formatting;
@@ -30,21 +28,13 @@ public static RazorFormattingOptions From(FormattingOptions options, bool codeBl
CodeBlockBraceOnNextLine = codeBlockBraceOnNextLine
};
- public static RazorFormattingOptions From(RoslynFormattingOptions options, bool codeBlockBraceOnNextLine)
- => new()
- {
- InsertSpaces = options.InsertSpaces,
- TabSize = options.TabSize,
- CodeBlockBraceOnNextLine = codeBlockBraceOnNextLine
- };
-
public RazorIndentationOptions ToIndentationOptions()
=> new(
UseTabs: !InsertSpaces,
TabSize: TabSize,
IndentationSize: TabSize);
- public RoslynFormattingOptions ToRoslynFormattingOptions()
+ public FormattingOptions ToLspFormattingOptions()
=> new()
{
InsertSpaces = InsertSpaces,
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingService.cs
index d9ddbc564ca..38166958a2a 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/RazorFormattingService.cs
@@ -10,7 +10,6 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.PooledObjects;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Razor.DocumentMapping;
using Microsoft.CodeAnalysis.Razor.Logging;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/GlobalUsings.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/GlobalUsings.cs
new file mode 100644
index 00000000000..76d80acfa55
--- /dev/null
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/GlobalUsings.cs
@@ -0,0 +1,26 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the MIT license. See License.txt in the project root for license information.
+
+// This file is shared, but not all of the usings are needed for all files, so Roslyn seems keen to flag them as unused in this file
+#pragma warning disable IDE0005 // Using directive is unnecessary.
+
+// Strictly speaking we don't need these aliases in this project, but keeping things consistent with other projects
+// makes for a more pleasant development experience.
+
+// Avoid extern alias in every file that needs to use Range
+global using LspColorPresentation = Roslyn.LanguageServer.Protocol.ColorPresentation;
+global using LspDiagnostic = Roslyn.LanguageServer.Protocol.Diagnostic;
+global using LspDiagnosticSeverity = Roslyn.LanguageServer.Protocol.DiagnosticSeverity;
+global using LspDocumentHighlight = Roslyn.LanguageServer.Protocol.DocumentHighlight;
+global using LspHover = Roslyn.LanguageServer.Protocol.Hover;
+global using LspLocation = Roslyn.LanguageServer.Protocol.Location;
+global using LspRange = Roslyn.LanguageServer.Protocol.Range;
+global using LspSignatureHelp = Roslyn.LanguageServer.Protocol.SignatureHelp;
+
+// Avoid ambiguity errors because of our global using above
+global using Range = System.Range;
+
+// We put our extensions on Roslyn's LSP types in the same namespace, for convenience, but of course without the alias,
+// so to prevent confusion at not needing a using directive to access types, but needing one for extensions, we just
+// global using the our extensions (which of course means they didn't need to be in the same namespace for convenience!)
+global using Roslyn.LanguageServer.Protocol;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/GoToDefinition/AbstractRazorComponentDefinitionService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/GoToDefinition/AbstractRazorComponentDefinitionService.cs
index 56f2c139a33..12f8754cb0d 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/GoToDefinition/AbstractRazorComponentDefinitionService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/GoToDefinition/AbstractRazorComponentDefinitionService.cs
@@ -4,15 +4,11 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.DocumentMapping;
using Microsoft.CodeAnalysis.Razor.Logging;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Protocol;
using Microsoft.CodeAnalysis.Razor.Workspaces;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
-using LspLocation = Microsoft.VisualStudio.LanguageServer.Protocol.Location;
-using LspRange = Microsoft.VisualStudio.LanguageServer.Protocol.Range;
namespace Microsoft.CodeAnalysis.Razor.GoToDefinition;
@@ -38,7 +34,7 @@ internal abstract class AbstractRazorComponentDefinitionService(
return null;
}
- if (!FileKinds.IsComponent(documentSnapshot.FileKind))
+ if (!documentSnapshot.FileKind.IsComponent())
{
_logger.LogInformation($"'{documentSnapshot.FileKind}' is not a component type.");
return null;
@@ -68,7 +64,7 @@ internal abstract class AbstractRazorComponentDefinitionService(
var range = await GetNavigateRangeAsync(componentDocument, boundAttribute, cancellationToken).ConfigureAwait(false);
- return VsLspFactory.CreateLocation(componentFilePath, range);
+ return LspFactory.CreateLocation(componentFilePath, range);
}
private async Task GetNavigateRangeAsync(IDocumentSnapshot documentSnapshot, BoundAttributeDescriptor? attributeDescriptor, CancellationToken cancellationToken)
@@ -91,6 +87,6 @@ private async Task GetNavigateRangeAsync(IDocumentSnapshot documentSna
// If we were trying to navigate to a property, and we couldn't find it, we can at least take
// them to the file for the component. If the property was defined in a partial class they can
// at least then press F7 to go there.
- return VsLspFactory.DefaultRange;
+ return LspFactory.DefaultRange;
}
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/GoToDefinition/IRazorComponentDefinitionService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/GoToDefinition/IRazorComponentDefinitionService.cs
index e5c3114e8c5..737e13794d5 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/GoToDefinition/IRazorComponentDefinitionService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/GoToDefinition/IRazorComponentDefinitionService.cs
@@ -3,10 +3,8 @@
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.DocumentMapping;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
-using LspLocation = Microsoft.VisualStudio.LanguageServer.Protocol.Location;
namespace Microsoft.CodeAnalysis.Razor.GoToDefinition;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/GoToDefinition/RazorComponentDefinitionHelpers.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/GoToDefinition/RazorComponentDefinitionHelpers.cs
index 3a93c429238..307f0100d9d 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/GoToDefinition/RazorComponentDefinitionHelpers.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/GoToDefinition/RazorComponentDefinitionHelpers.cs
@@ -8,13 +8,11 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.Syntax;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Razor.DocumentMapping;
using Microsoft.CodeAnalysis.Razor.Logging;
+using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Workspaces;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
-using LspRange = Microsoft.VisualStudio.LanguageServer.Protocol.Range;
using RazorSyntaxKind = Microsoft.AspNetCore.Razor.Language.SyntaxKind;
using RazorSyntaxNode = Microsoft.AspNetCore.Razor.Language.Syntax.SyntaxNode;
using RazorSyntaxToken = Microsoft.AspNetCore.Razor.Language.Syntax.SyntaxToken;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Hover/HoverDisplayOptions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Hover/HoverDisplayOptions.cs
index 6d56f33edd3..135ec99ecd2 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Hover/HoverDisplayOptions.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Hover/HoverDisplayOptions.cs
@@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
-using Microsoft.VisualStudio.LanguageServer.Protocol;
-
namespace Microsoft.CodeAnalysis.Razor.Hover;
internal readonly record struct HoverDisplayOptions(MarkupKind MarkupKind, bool SupportsVisualStudioExtensions)
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Hover/HoverFactory.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Hover/HoverFactory.cs
index 7d41224c3c4..0cd22df76fb 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Hover/HoverFactory.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Hover/HoverFactory.cs
@@ -17,9 +17,7 @@
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.Editor.Razor;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
-using Microsoft.VisualStudio.Text.Adornments;
-using LspHover = Microsoft.VisualStudio.LanguageServer.Protocol.Hover;
+using Roslyn.Text.Adornments;
namespace Microsoft.CodeAnalysis.Razor.Hover;
@@ -49,7 +47,7 @@ internal static class HoverFactory
owner = owner.Parent;
}
- var tagHelperDocumentContext = codeDocument.GetTagHelperContext();
+ var tagHelperContext = codeDocument.GetRequiredTagHelperContext();
if (HtmlFacts.TryGetElementInfo(owner, out var containingTagNameToken, out var attributes, closingForwardSlashOrCloseAngleToken: out _) &&
containingTagNameToken.Span.IntersectsWith(absoluteIndex))
@@ -73,7 +71,7 @@ internal static class HoverFactory
var (parentTag, parentIsTagHelper) = TagHelperFacts.GetNearestAncestorTagInfo(ancestors);
var stringifiedAttributes = TagHelperFacts.StringifyAttributes(attributes);
var binding = TagHelperFacts.GetTagHelperBinding(
- tagHelperDocumentContext,
+ tagHelperContext,
containingTagNameToken.Content,
stringifiedAttributes,
parentTag: parentTag,
@@ -94,8 +92,10 @@ internal static class HoverFactory
var span = containingTagNameToken.GetLinePositionSpan(codeDocument.Source);
+ var filePath = codeDocument.Source.FilePath.AssumeNotNull();
+
return ElementInfoToHoverAsync(
- codeDocument.Source.FilePath, binding.Descriptors, span, options, componentAvailabilityService, cancellationToken);
+ filePath, binding.Descriptors, span, options, componentAvailabilityService, cancellationToken);
}
if (HtmlFacts.TryGetAttributeInfo(owner, out containingTagNameToken, out _, out var selectedAttributeName, out var selectedAttributeNameLocation, out attributes) &&
@@ -111,7 +111,7 @@ internal static class HoverFactory
var stringifiedAttributes = TagHelperFacts.StringifyAttributes(attributes);
var binding = TagHelperFacts.GetTagHelperBinding(
- tagHelperDocumentContext,
+ tagHelperContext,
containingTagNameToken.Content,
stringifiedAttributes,
parentTag: parentTag,
@@ -125,7 +125,7 @@ internal static class HoverFactory
Debug.Assert(binding.Descriptors.Any());
var tagHelperAttributes = TagHelperFacts.GetBoundTagHelperAttributes(
- tagHelperDocumentContext,
+ tagHelperContext,
selectedAttributeName.AssumeNotNull(),
binding);
@@ -158,13 +158,13 @@ internal static class HoverFactory
{
case SyntaxKind.MarkupTagHelperDirectiveAttribute:
var directiveAttribute = (MarkupTagHelperDirectiveAttributeSyntax)attribute.Parent;
- span = span.WithStart(start => start.WithCharacter(ch => ch - directiveAttribute.Transition.FullWidth));
+ span = span.WithStart(start => start.WithCharacter(ch => ch - directiveAttribute.Transition.Width));
attributeName = "@" + attributeName;
break;
case SyntaxKind.MarkupMinimizedTagHelperDirectiveAttribute:
var minimizedAttribute = (MarkupMinimizedTagHelperDirectiveAttributeSyntax)containingTag;
- span = span.WithStart(start => start.WithCharacter(ch => ch - minimizedAttribute.Transition.FullWidth));
+ span = span.WithStart(start => start.WithCharacter(ch => ch - minimizedAttribute.Transition.Width));
attributeName = "@" + attributeName;
break;
}
@@ -217,7 +217,7 @@ internal static class HoverFactory
}
private static async Task ElementInfoToHoverAsync(
- string? documentFilePath,
+ string documentFilePath,
ImmutableArray descriptors,
LinePositionSpan span,
HoverDisplayOptions options,
@@ -225,7 +225,7 @@ internal static class HoverFactory
CancellationToken cancellationToken)
{
// Filter out attribute descriptors since we're creating an element hover
- var keepAttributeInfo = FileKinds.GetFileKindFromFilePath(documentFilePath) == FileKinds.Legacy;
+ var keepAttributeInfo = FileKinds.GetFileKindFromPath(documentFilePath) == RazorFileKind.Legacy;
var descriptionInfos = descriptors
.Where(d => keepAttributeInfo || !d.IsAttributeDescriptor())
.SelectAsArray(BoundElementDescriptionInfo.From);
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ICapabilitiesProvider.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ICapabilitiesProvider.cs
index e878ebdcd02..1bd61eb7102 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ICapabilitiesProvider.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ICapabilitiesProvider.cs
@@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
-using Microsoft.VisualStudio.LanguageServer.Protocol;
-
namespace Microsoft.AspNetCore.Razor.LanguageServer;
internal interface ICapabilitiesProvider
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/IFilePathService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/IFilePathService.cs
index 7813709d2be..1898cddf503 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/IFilePathService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/IFilePathService.cs
@@ -2,7 +2,7 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
+using Microsoft.CodeAnalysis.Razor.ProjectSystem;
namespace Microsoft.CodeAnalysis.Razor.Workspaces;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/IRazorComponentSearchEngine.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/IRazorComponentSearchEngine.cs
index 3977c48b367..45a998e88c1 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/IRazorComponentSearchEngine.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/IRazorComponentSearchEngine.cs
@@ -4,7 +4,6 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
namespace Microsoft.CodeAnalysis.Razor.Workspaces;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Logging/Handlers/LogMessageInterpolatedStringHandler.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Logging/Handlers/LogMessageInterpolatedStringHandler.cs
index 3725b6662a2..76d81a010fd 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Logging/Handlers/LogMessageInterpolatedStringHandler.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Logging/Handlers/LogMessageInterpolatedStringHandler.cs
@@ -4,8 +4,6 @@
using System.Runtime.CompilerServices;
using System.Text;
using Microsoft.AspNetCore.Razor.PooledObjects;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
-using Roslyn.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Logging;
@@ -52,13 +50,9 @@ public override string ToString()
private static string GetMessage(object? value)
=> value switch
{
- VisualStudio.LanguageServer.Protocol.Range range => range.ToDisplayString(),
- VisualStudio.LanguageServer.Protocol.Position position => position.ToDisplayString(),
- VisualStudio.LanguageServer.Protocol.ISumType sumType => GetMessage(sumType.Value),
-
- Roslyn.LanguageServer.Protocol.Range range => range.ToDisplayString(),
- Roslyn.LanguageServer.Protocol.Position position => position.ToDisplayString(),
- Roslyn.LanguageServer.Protocol.ISumType sumType => GetMessage(sumType.Value),
+ LspRange range => range.ToDisplayString(),
+ Position position => position.ToDisplayString(),
+ ISumType sumType => GetMessage(sumType.Value),
null => "[null]",
_ => value.ToString() ?? "[null]"
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Microsoft.CodeAnalysis.Razor.Workspaces.csproj b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Microsoft.CodeAnalysis.Razor.Workspaces.csproj
index 5cf5e0393f5..08d59580d87 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Microsoft.CodeAnalysis.Razor.Workspaces.csproj
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Microsoft.CodeAnalysis.Razor.Workspaces.csproj
@@ -12,11 +12,8 @@
-
+
-
-
-
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/DefaultProjectEngineFactory.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/DefaultProjectEngineFactory.cs
index 19e898887f5..9bbe818dcf7 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/DefaultProjectEngineFactory.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/DefaultProjectEngineFactory.cs
@@ -3,11 +3,10 @@
using System;
using Microsoft.AspNetCore.Razor.Language;
-using Microsoft.CodeAnalysis.Razor;
-namespace Microsoft.AspNetCore.Razor.ProjectSystem;
+namespace Microsoft.CodeAnalysis.Razor.ProjectEngineHost;
-internal class DefaultProjectEngineFactory : IProjectEngineFactory
+internal sealed class DefaultProjectEngineFactory : IProjectEngineFactory
{
public string ConfigurationName => "Default";
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/EmptyProjectEngineFactory.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/EmptyProjectEngineFactory.cs
index fa13093d499..4a092e7527b 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/EmptyProjectEngineFactory.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/EmptyProjectEngineFactory.cs
@@ -2,24 +2,19 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
+using Microsoft.AspNetCore.Razor;
using Microsoft.AspNetCore.Razor.Language;
-namespace Microsoft.AspNetCore.Razor.ProjectSystem;
+namespace Microsoft.CodeAnalysis.Razor.ProjectEngineHost;
internal sealed class EmptyProjectEngineFactory : IProjectEngineFactory
{
public string ConfigurationName => "Empty";
+
public RazorProjectEngine Create(RazorConfiguration configuration, RazorProjectFileSystem fileSystem, Action? configure)
{
- if (configuration is null)
- {
- throw new ArgumentNullException(nameof(configuration));
- }
-
- if (fileSystem is null)
- {
- throw new ArgumentNullException(nameof(fileSystem));
- }
+ ArgHelper.ThrowIfNull(configuration);
+ ArgHelper.ThrowIfNull(fileSystem);
// This is a very basic implementation that will provide reasonable support without crashing.
// If the user falls into this situation, ideally they can realize that something is wrong and take
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/IProjectEngineFactory.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/IProjectEngineFactory.cs
index ca161df7f5a..ef6caceca7c 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/IProjectEngineFactory.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/IProjectEngineFactory.cs
@@ -4,7 +4,7 @@
using System;
using Microsoft.AspNetCore.Razor.Language;
-namespace Microsoft.AspNetCore.Razor.ProjectSystem;
+namespace Microsoft.CodeAnalysis.Razor.ProjectEngineHost;
internal interface IProjectEngineFactory
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/IProjectEngineFactoryExtensions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/IProjectEngineFactoryExtensions.cs
index a81a89b5c97..3bf046b3663 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/IProjectEngineFactoryExtensions.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/IProjectEngineFactoryExtensions.cs
@@ -4,7 +4,7 @@
using System;
using Microsoft.AspNetCore.Razor.Language;
-namespace Microsoft.AspNetCore.Razor.ProjectSystem;
+namespace Microsoft.CodeAnalysis.Razor.ProjectEngineHost;
internal static class IProjectEngineFactoryExtensions
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/IProjectEngineFactoryProvider.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/IProjectEngineFactoryProvider.cs
index 1e8820866df..3c921d346f4 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/IProjectEngineFactoryProvider.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/IProjectEngineFactoryProvider.cs
@@ -3,7 +3,7 @@
using Microsoft.AspNetCore.Razor.Language;
-namespace Microsoft.AspNetCore.Razor.ProjectSystem;
+namespace Microsoft.CodeAnalysis.Razor.ProjectEngineHost;
internal interface IProjectEngineFactoryProvider
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/ProjectEngineFactories.SimpleFactory.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/ProjectEngineFactories.SimpleFactory.cs
new file mode 100644
index 00000000000..d05c6c8cd11
--- /dev/null
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/ProjectEngineFactories.SimpleFactory.cs
@@ -0,0 +1,29 @@
+// 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;
+using Microsoft.AspNetCore.Razor.Language;
+
+namespace Microsoft.CodeAnalysis.Razor.ProjectEngineHost;
+
+internal static partial class ProjectEngineFactories
+{
+ private sealed class SimpleFactory(string configurationName) : IProjectEngineFactory
+ {
+ public string ConfigurationName => configurationName;
+
+ public RazorProjectEngine Create(
+ RazorConfiguration configuration,
+ RazorProjectFileSystem fileSystem,
+ Action? configure)
+ => RazorProjectEngine.Create(configuration, fileSystem, builder =>
+ {
+ Debug.Assert(configuration.ConfigurationName == ConfigurationName);
+
+ CompilerFeatures.Register(builder);
+ builder.RegisterExtensions();
+ configure?.Invoke(builder);
+ });
+ }
+}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/ProjectEngineFactories.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/ProjectEngineFactories.cs
index 0ca4a603d87..b6fe131ff13 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/ProjectEngineFactories.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/ProjectEngineFactories.cs
@@ -3,7 +3,7 @@
using System.Collections.Immutable;
-namespace Microsoft.AspNetCore.Razor.ProjectSystem;
+namespace Microsoft.CodeAnalysis.Razor.ProjectEngineHost;
internal static partial class ProjectEngineFactories
{
@@ -11,13 +11,11 @@ internal static partial class ProjectEngineFactories
public static IProjectEngineFactory Default { get; } = new DefaultProjectEngineFactory();
- public static IProjectEngineFactory MVC_1_0 { get; } = new ProjectEngineFactory("MVC-1.0");
- public static IProjectEngineFactory MVC_1_1 { get; } = new ProjectEngineFactory("MVC-1.1");
- public static IProjectEngineFactory MVC_2_0 { get; } = new ProjectEngineFactory("MVC-2.0");
- public static IProjectEngineFactory MVC_2_1 { get; } = new ProjectEngineFactory("MVC-2.1");
- public static IProjectEngineFactory MVC_3_0 { get; } = new ProjectEngineFactory("MVC-3.0");
-
- public static IProjectEngineFactory Unsupported { get; } = new ProjectEngineFactory_Unsupported();
+ public static IProjectEngineFactory MVC_1_0 { get; } = new SimpleFactory("MVC-1.0");
+ public static IProjectEngineFactory MVC_1_1 { get; } = new SimpleFactory("MVC-1.1");
+ public static IProjectEngineFactory MVC_2_0 { get; } = new SimpleFactory("MVC-2.0");
+ public static IProjectEngineFactory MVC_2_1 { get; } = new SimpleFactory("MVC-2.1");
+ public static IProjectEngineFactory MVC_3_0 { get; } = new SimpleFactory("MVC-3.0");
public static ImmutableArray All { get; } =
[
@@ -27,10 +25,7 @@ internal static partial class ProjectEngineFactories
MVC_1_1,
MVC_2_0,
MVC_2_1,
- MVC_3_0,
-
- // Unsupported (Legacy/System.Web.Razor)
- Unsupported
+ MVC_3_0
];
public static IProjectEngineFactoryProvider DefaultProvider { get; } = new ProjectEngineFactoryProvider(All);
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/ProjectEngineFactory.InitializerKey.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/ProjectEngineFactory.InitializerKey.cs
deleted file mode 100644
index 20d5774714f..00000000000
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/ProjectEngineFactory.InitializerKey.cs
+++ /dev/null
@@ -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 Microsoft.Extensions.Internal;
-
-namespace Microsoft.AspNetCore.Razor.ProjectSystem;
-
-internal sealed partial class ProjectEngineFactory
-{
- private readonly record struct InitializerKey(string ConfigurationName, string AssemblyName)
- {
- public bool Equals(InitializerKey other)
- => ConfigurationName == other.ConfigurationName &&
- AssemblyName == other.AssemblyName;
-
- public override int GetHashCode()
- {
- var hash = HashCodeCombiner.Start();
- hash.Add(ConfigurationName, StringComparer.Ordinal);
- hash.Add(AssemblyName, StringComparer.Ordinal);
-
- return hash.CombinedHash;
- }
- }
-}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/ProjectEngineFactory.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/ProjectEngineFactory.cs
deleted file mode 100644
index 5a9962a4163..00000000000
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/ProjectEngineFactory.cs
+++ /dev/null
@@ -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 Microsoft.AspNetCore.Razor.Language;
-using Microsoft.CodeAnalysis.Razor;
-
-namespace Microsoft.AspNetCore.Razor.ProjectSystem;
-
-internal sealed partial class ProjectEngineFactory(string configurationName) : IProjectEngineFactory
-{
- public string ConfigurationName => configurationName;
-
- public RazorProjectEngine Create(
- RazorConfiguration configuration,
- RazorProjectFileSystem fileSystem,
- Action? configure)
- => RazorProjectEngine.Create(configuration, fileSystem, builder =>
- {
- CompilerFeatures.Register(builder);
- builder.RegisterExtensions();
- configure?.Invoke(builder);
- });
-}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/ProjectEngineFactoryProvider.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/ProjectEngineFactoryProvider.cs
index 548f0319d1a..18d5e9b42a5 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/ProjectEngineFactoryProvider.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/ProjectEngineFactoryProvider.cs
@@ -4,9 +4,9 @@
using System.Collections.Immutable;
using Microsoft.AspNetCore.Razor.Language;
-namespace Microsoft.AspNetCore.Razor.ProjectSystem;
+namespace Microsoft.CodeAnalysis.Razor.ProjectEngineHost;
-internal class ProjectEngineFactoryProvider(ImmutableArray factories) : IProjectEngineFactoryProvider
+internal sealed class ProjectEngineFactoryProvider(ImmutableArray factories) : IProjectEngineFactoryProvider
{
public IProjectEngineFactory GetFactory(RazorConfiguration configuration)
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/ProjectEngineFactory_Unsupported.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/ProjectEngineFactory_Unsupported.cs
deleted file mode 100644
index 21b61e44395..00000000000
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/ProjectEngineFactory_Unsupported.cs
+++ /dev/null
@@ -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 System.Linq;
-using Microsoft.AspNetCore.Razor.Language;
-
-namespace Microsoft.AspNetCore.Razor.ProjectSystem;
-
-internal class ProjectEngineFactory_Unsupported : IProjectEngineFactory
-{
- public string ConfigurationName => UnsupportedRazorConfiguration.Instance.ConfigurationName;
-
- public RazorProjectEngine Create(RazorConfiguration configuration, RazorProjectFileSystem fileSystem, Action? configure)
- {
- return RazorProjectEngine.Create(configuration, fileSystem, builder =>
- {
- var csharpLoweringIndex = builder.Phases.IndexOf(builder.Phases.OfType().Single());
- builder.Phases[csharpLoweringIndex] = new UnsupportedCSharpLoweringPhase();
- });
- }
-}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/UnsupportedCSharpLoweringPhase.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/UnsupportedCSharpLoweringPhase.cs
deleted file mode 100644
index a02f6422904..00000000000
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/UnsupportedCSharpLoweringPhase.cs
+++ /dev/null
@@ -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.Text;
-using System.Threading;
-using Microsoft.AspNetCore.Razor.Language;
-using Microsoft.CodeAnalysis.Text;
-
-namespace Microsoft.AspNetCore.Razor.ProjectSystem;
-
-internal class UnsupportedCSharpLoweringPhase : RazorEnginePhaseBase, IRazorCSharpLoweringPhase
-{
- internal const string UnsupportedDisclaimer = "// Razor CSharp output is not supported for this project's version of Razor.";
-
- private static readonly SourceText s_disclaimerText = SourceText.From(UnsupportedDisclaimer, Encoding.UTF8);
-
- protected override void ExecuteCore(RazorCodeDocument codeDocument, CancellationToken cancellationToken)
- {
- var documentNode = codeDocument.GetDocumentIntermediateNode();
- ThrowForMissingDocumentDependency(documentNode);
-
- var csharpDocument = new RazorCSharpDocument(codeDocument, s_disclaimerText, documentNode.Options, diagnostics: []);
- codeDocument.SetCSharpDocument(csharpDocument);
- codeDocument.SetUnsupported();
- }
-}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/UnsupportedRazorConfiguration.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/UnsupportedRazorConfiguration.cs
deleted file mode 100644
index ab36442b339..00000000000
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectEngineHost/UnsupportedRazorConfiguration.cs
+++ /dev/null
@@ -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 Microsoft.AspNetCore.Razor.Language;
-
-namespace Microsoft.AspNetCore.Razor.ProjectSystem;
-
-internal static class UnsupportedRazorConfiguration
-{
- public static readonly RazorConfiguration Instance = new(
- RazorLanguageVersion.Version_1_0,
- "UnsupportedRazor",
- [new("UnsupportedRazorExtension")]);
-}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/AbstractRazorProjectInfoDriver.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/AbstractRazorProjectInfoDriver.cs
index b26d502a35a..63b40516f8a 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/AbstractRazorProjectInfoDriver.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/AbstractRazorProjectInfoDriver.cs
@@ -8,9 +8,8 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor;
using Microsoft.AspNetCore.Razor.PooledObjects;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
-using Microsoft.AspNetCore.Razor.Utilities;
using Microsoft.CodeAnalysis.Razor.Logging;
+using Microsoft.CodeAnalysis.Razor.Utilities;
using Microsoft.VisualStudio.Threading;
namespace Microsoft.CodeAnalysis.Razor.ProjectSystem;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/CodeDocumentGenerator.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/CodeDocumentGenerator.cs
index efa7739afed..32f1b0cac45 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/CodeDocumentGenerator.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/CodeDocumentGenerator.cs
@@ -12,7 +12,7 @@ internal readonly struct CodeDocumentGenerator(RazorProjectEngine projectEngine,
{
public RazorCodeDocument Generate(
RazorSourceDocument source,
- string fileKind,
+ RazorFileKind fileKind,
ImmutableArray importSources,
ImmutableArray tagHelpers,
CancellationToken cancellationToken)
@@ -26,7 +26,7 @@ public RazorCodeDocument Generate(
public RazorCodeDocument GenerateDesignTime(
RazorSourceDocument source,
- string fileKind,
+ RazorFileKind fileKind,
ImmutableArray importSources,
ImmutableArray tagHelpers,
CancellationToken cancellationToken)
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/CompilationHelpers.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/CompilationHelpers.cs
index 9796decc4d6..db960f2d816 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/CompilationHelpers.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/CompilationHelpers.cs
@@ -7,7 +7,6 @@
using Microsoft.AspNetCore.Razor;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.PooledObjects;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
namespace Microsoft.CodeAnalysis.Razor.ProjectSystem;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentContext.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentContext.cs
index 70bc53b8b3f..3caaa93fed4 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentContext.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentContext.cs
@@ -8,10 +8,8 @@
using Microsoft.AspNetCore.Razor;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.Syntax;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Protocol;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
using RazorSyntaxNode = Microsoft.AspNetCore.Razor.Language.Syntax.SyntaxNode;
namespace Microsoft.CodeAnalysis.Razor.ProjectSystem;
@@ -25,7 +23,7 @@ internal class DocumentContext(Uri uri, IDocumentSnapshot snapshot, VSProjectCon
public Uri Uri { get; } = uri;
public IDocumentSnapshot Snapshot { get; } = snapshot;
public string FilePath => Snapshot.FilePath;
- public string FileKind => Snapshot.FileKind;
+ public RazorFileKind FileKind => Snapshot.FileKind;
public IProjectSnapshot Project => Snapshot.Project;
public TextDocumentIdentifier GetTextDocumentIdentifier()
@@ -106,7 +104,7 @@ public ValueTask GetTagHelperContextAsync(Cancellation
static TagHelperDocumentContext GetTagHelperContextCore(RazorCodeDocument codeDocument)
{
- return codeDocument.GetTagHelperContext().AssumeNotNull();
+ return codeDocument.GetRequiredTagHelperContext();
}
async ValueTask GetTagHelperContextCoreAsync(CancellationToken cancellationToken)
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentKey.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentKey.cs
index e4b48fe8df8..b20cf283f2d 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentKey.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentKey.cs
@@ -2,10 +2,9 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
-using Microsoft.CodeAnalysis.Razor;
using Microsoft.Extensions.Internal;
-namespace Microsoft.AspNetCore.Razor.ProjectSystem;
+namespace Microsoft.CodeAnalysis.Razor.ProjectSystem;
internal readonly record struct DocumentKey : IComparable
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentSnapshot.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentSnapshot.cs
index 9a31327616c..085592f2d69 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentSnapshot.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentSnapshot.cs
@@ -5,22 +5,31 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.ProjectSystem.Legacy;
+using Microsoft.CodeAnalysis.Razor.ProjectSystem.Sources;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis.Razor.ProjectSystem;
-internal sealed class DocumentSnapshot(ProjectSnapshot project, DocumentState state) : IDocumentSnapshot, ILegacyDocumentSnapshot, IDesignTimeCodeGenerator
+internal sealed class DocumentSnapshot : IDocumentSnapshot, ILegacyDocumentSnapshot, IDesignTimeCodeGenerator
{
- public ProjectSnapshot Project { get; } = project;
+ private readonly GeneratedOutputSource _generatedOutputSource;
- private readonly DocumentState _state = state;
+ public ProjectSnapshot Project { get; }
+
+ private readonly DocumentState _state;
+
+ public DocumentSnapshot(ProjectSnapshot project, DocumentState state)
+ {
+ Project = project;
+ _state = state;
+ _generatedOutputSource = new(this);
+ }
public HostDocument HostDocument => _state.HostDocument;
public DocumentKey Key => new(Project.Key, FilePath);
- public string FileKind => _state.HostDocument.FileKind;
+ public RazorFileKind FileKind => _state.HostDocument.FileKind;
public string FilePath => _state.HostDocument.FilePath;
public string TargetPath => _state.HostDocument.TargetPath;
public int Version => _state.Version;
@@ -40,10 +49,10 @@ public ValueTask GetTextVersionAsync(CancellationToken cancellatio
=> _state.GetTextVersionAsync(cancellationToken);
public bool TryGetGeneratedOutput([NotNullWhen(true)] out RazorCodeDocument? result)
- => _state.TryGetGeneratedOutput(out result);
+ => _generatedOutputSource.TryGetValue(out result);
public ValueTask GetGeneratedOutputAsync(CancellationToken cancellationToken)
- => _state.GetGeneratedOutputAsync(this, cancellationToken);
+ => _generatedOutputSource.GetValueAsync(cancellationToken);
public IDocumentSnapshot WithText(SourceText text)
{
@@ -68,7 +77,7 @@ public Task GenerateDesignTimeOutputAsync(CancellationToken c
#region ILegacyDocumentSnapshot support
- string ILegacyDocumentSnapshot.FileKind => FileKind;
+ RazorFileKind ILegacyDocumentSnapshot.FileKind => FileKind;
#endregion
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentState.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentState.cs
index 91ff97c3e46..e2f589905ef 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentState.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentState.cs
@@ -4,7 +4,6 @@
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.AspNetCore.Razor.Language;
using Microsoft.CodeAnalysis.Razor.ProjectSystem.Sources;
using Microsoft.CodeAnalysis.Text;
@@ -16,14 +15,12 @@ internal sealed partial class DocumentState
public int Version { get; }
private readonly ITextAndVersionSource _textAndVersionSource;
- private readonly GeneratedOutputSource _generatedOutputSource;
private DocumentState(HostDocument hostDocument, ITextAndVersionSource textAndVersionSource)
{
HostDocument = hostDocument;
Version = 1;
_textAndVersionSource = textAndVersionSource;
- _generatedOutputSource = new();
}
private DocumentState(DocumentState oldState, ITextAndVersionSource textAndVersionSource)
@@ -31,7 +28,6 @@ private DocumentState(DocumentState oldState, ITextAndVersionSource textAndVersi
HostDocument = oldState.HostDocument;
Version = oldState.Version + 1;
_textAndVersionSource = textAndVersionSource;
- _generatedOutputSource = new();
}
public static DocumentState Create(HostDocument hostDocument, SourceText text)
@@ -46,12 +42,6 @@ private static ConstantTextAndVersionSource CreateTextAndVersionSource(SourceTex
private static LoadableTextAndVersionSource CreateTextAndVersionSource(TextLoader textLoader)
=> new(textLoader);
- public bool TryGetGeneratedOutput([NotNullWhen(true)] out RazorCodeDocument? result)
- => _generatedOutputSource.TryGetValue(out result);
-
- public ValueTask GetGeneratedOutputAsync(DocumentSnapshot document, CancellationToken cancellationToken)
- => _generatedOutputSource.GetValueAsync(document, cancellationToken);
-
public bool TryGetTextAndVersion([NotNullWhen(true)] out TextAndVersion? result)
=> _textAndVersionSource.TryGetValue(out result);
@@ -110,13 +100,7 @@ async ValueTask GetTextVersionCoreAsync(CancellationToken cancella
}
}
- public DocumentState WithConfigurationChange()
- => new(this, _textAndVersionSource);
-
- public DocumentState WithImportsChange()
- => new(this, _textAndVersionSource);
-
- public DocumentState WithProjectWorkspaceStateChange()
+ public DocumentState UpdateVersion()
=> new(this, _textAndVersionSource);
public DocumentState WithText(SourceText text, VersionStamp textVersion)
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/EmptyTextLoader.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/EmptyTextLoader.cs
index d57c6451e75..658b3fc020e 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/EmptyTextLoader.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/EmptyTextLoader.cs
@@ -1,8 +1,6 @@
// 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.Text;
using System.Threading;
using System.Threading.Tasks;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/Extensions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/Extensions.cs
index 1eee49750d9..3c590cbeee7 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/Extensions.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/Extensions.cs
@@ -6,11 +6,10 @@
#endif
using System.Diagnostics;
-using Microsoft.AspNetCore.Razor.Serialization;
-using Microsoft.AspNetCore.Razor.Utilities;
-using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Razor.Serialization;
+using Microsoft.CodeAnalysis.Razor.Utilities;
-namespace Microsoft.AspNetCore.Razor.ProjectSystem;
+namespace Microsoft.CodeAnalysis.Razor.ProjectSystem;
internal static class Extensions
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/HostDocument.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/HostDocument.cs
index 61f0bbdccc0..260b9cff47c 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/HostDocument.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/HostDocument.cs
@@ -7,14 +7,14 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem;
internal sealed record class HostDocument
{
- public string FileKind { get; init; }
+ public RazorFileKind FileKind { get; init; }
public string FilePath { get; init; }
public string TargetPath { get; init; }
- public HostDocument(string filePath, string targetPath, string? fileKind = null)
+ public HostDocument(string filePath, string targetPath, RazorFileKind? fileKind = null)
{
FilePath = filePath;
TargetPath = targetPath;
- FileKind = fileKind ?? FileKinds.GetFileKindFromFilePath(filePath);
+ FileKind = fileKind ?? FileKinds.GetFileKindFromPath(filePath);
}
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/HostProject.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/HostProject.cs
index f4f00481a0f..2a344a34bcc 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/HostProject.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/HostProject.cs
@@ -3,7 +3,6 @@
using System.IO;
using Microsoft.AspNetCore.Razor.Language;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
using Microsoft.Extensions.Internal;
namespace Microsoft.CodeAnalysis.Razor.ProjectSystem;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IDocumentSnapshot.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IDocumentSnapshot.cs
index a82ec285804..84cf230a744 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IDocumentSnapshot.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IDocumentSnapshot.cs
@@ -5,14 +5,13 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
-using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Text;
-namespace Microsoft.AspNetCore.Razor.ProjectSystem;
+namespace Microsoft.CodeAnalysis.Razor.ProjectSystem;
internal interface IDocumentSnapshot
{
- string FileKind { get; }
+ RazorFileKind FileKind { get; }
string FilePath { get; }
string TargetPath { get; }
IProjectSnapshot Project { get; }
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IDocumentSnapshotExtensions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IDocumentSnapshotExtensions.cs
index 6325c6a0dd9..4d3a574b86b 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IDocumentSnapshotExtensions.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IDocumentSnapshotExtensions.cs
@@ -6,7 +6,6 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
namespace Microsoft.CodeAnalysis.Razor.ProjectSystem;
@@ -28,7 +27,7 @@ public static async Task GetSourceAsync(this IDocumentSnaps
CancellationToken cancellationToken)
{
// No point doing anything if its not a component
- if (documentSnapshot.FileKind != FileKinds.Component)
+ if (documentSnapshot.FileKind != RazorFileKind.Component)
{
return null;
}
@@ -58,7 +57,7 @@ public static async Task GetSourceAsync(this IDocumentSnaps
public static bool IsPathCandidateForComponent(this IDocumentSnapshot documentSnapshot, ReadOnlyMemory path)
{
- if (documentSnapshot.FileKind != FileKinds.Component)
+ if (documentSnapshot.FileKind != RazorFileKind.Component)
{
return false;
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IProjectSnapshot.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IProjectSnapshot.cs
index 9ca0249622f..f01a18a7ef1 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IProjectSnapshot.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IProjectSnapshot.cs
@@ -9,7 +9,7 @@
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.CodeAnalysis.CSharp;
-namespace Microsoft.AspNetCore.Razor.ProjectSystem;
+namespace Microsoft.CodeAnalysis.Razor.ProjectSystem;
internal interface IProjectSnapshot
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IRazorProjectInfoDriver.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IRazorProjectInfoDriver.cs
index c465e309174..8a9127987a7 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IRazorProjectInfoDriver.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IRazorProjectInfoDriver.cs
@@ -3,7 +3,6 @@
using System.Collections.Immutable;
using System.Threading.Tasks;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
namespace Microsoft.CodeAnalysis.Razor.ProjectSystem;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IRazorProjectInfoListener.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IRazorProjectInfoListener.cs
index e0ab8f312db..c047b6b9c88 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IRazorProjectInfoListener.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IRazorProjectInfoListener.cs
@@ -3,7 +3,6 @@
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
namespace Microsoft.CodeAnalysis.Razor.ProjectSystem;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ISolutionQueryOperations.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ISolutionQueryOperations.cs
index 3703a0ee9a7..068a4547d84 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ISolutionQueryOperations.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ISolutionQueryOperations.cs
@@ -3,7 +3,6 @@
using System.Collections.Generic;
using System.Collections.Immutable;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
namespace Microsoft.CodeAnalysis.Razor.ProjectSystem;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/Legacy/ILegacyDocumentSnapshot.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/Legacy/ILegacyDocumentSnapshot.cs
index a8df3962469..0420c28a8a1 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/Legacy/ILegacyDocumentSnapshot.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/Legacy/ILegacyDocumentSnapshot.cs
@@ -1,6 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
+using Microsoft.AspNetCore.Razor.Language;
+
namespace Microsoft.CodeAnalysis.Razor.ProjectSystem.Legacy;
///
@@ -11,5 +13,5 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem.Legacy;
///
internal interface ILegacyDocumentSnapshot
{
- string FileKind { get; }
+ RazorFileKind FileKind { get; }
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectChangeEventArgs.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectChangeEventArgs.cs
index 879600a6945..95422d0f931 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectChangeEventArgs.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectChangeEventArgs.cs
@@ -3,7 +3,6 @@
using System;
using Microsoft.AspNetCore.Razor;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
namespace Microsoft.CodeAnalysis.Razor.ProjectSystem;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectKey.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectKey.cs
index 034f91d6263..33349ec59f4 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectKey.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectKey.cs
@@ -4,10 +4,9 @@
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
-using Microsoft.AspNetCore.Razor.Utilities;
-using Microsoft.CodeAnalysis.Razor;
+using Microsoft.CodeAnalysis.Razor.Utilities;
-namespace Microsoft.AspNetCore.Razor.ProjectSystem;
+namespace Microsoft.CodeAnalysis.Razor.ProjectSystem;
///
/// A very light wrapper around a file path, used to ensure consistency across the code base for what constitutes the unique
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshot.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshot.cs
index 07ba138b574..11a26b5bd89 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshot.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshot.cs
@@ -8,10 +8,9 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.PooledObjects;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
-using Microsoft.AspNetCore.Razor.Utilities;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Razor.ProjectSystem.Legacy;
+using Microsoft.CodeAnalysis.Razor.Utilities;
namespace Microsoft.CodeAnalysis.Razor.ProjectSystem;
@@ -20,7 +19,7 @@ internal sealed class ProjectSnapshot(ProjectState state) : IProjectSnapshot, IL
private readonly ProjectState _state = state;
private readonly object _gate = new();
- private readonly Dictionary _filePathToDocumentMap = new(FilePathNormalizingComparer.Instance);
+ private Dictionary? _filePathToDocumentMap;
public HostProject HostProject => _state.HostProject;
public RazorCompilerOptions CompilerOptions => _state.CompilerOptions;
@@ -53,8 +52,12 @@ public bool ContainsDocument(string filePath)
// ImmutableDictionary<,>, which has O(log n) lookup. So, checking _filePathToDocumentMap
// first is faster if the DocumentSnapshot has already been created.
- return _filePathToDocumentMap.ContainsKey(filePath) ||
- _state.Documents.ContainsKey(filePath);
+ if (_filePathToDocumentMap is not null && _filePathToDocumentMap.ContainsKey(filePath))
+ {
+ return true;
+ }
+
+ return _state.Documents.ContainsKey(filePath);
}
}
@@ -63,7 +66,8 @@ public bool TryGetDocument(string filePath, [NotNullWhen(true)] out DocumentSnap
lock (_gate)
{
// Have we already seen this document? If so, return it!
- if (_filePathToDocumentMap.TryGetValue(filePath, out var snapshot))
+ if (_filePathToDocumentMap is not null &&
+ _filePathToDocumentMap.TryGetValue(filePath, out var snapshot))
{
document = snapshot;
return true;
@@ -78,6 +82,8 @@ public bool TryGetDocument(string filePath, [NotNullWhen(true)] out DocumentSnap
// If we have DocumentState, go ahead and create a new DocumentSnapshot.
snapshot = new DocumentSnapshot(this, state);
+
+ _filePathToDocumentMap ??= new(capacity: _state.Documents.Count, FilePathNormalizingComparer.Instance);
_filePathToDocumentMap.Add(filePath, snapshot);
document = snapshot;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotExtensions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotExtensions.cs
index e0b53cdfbfa..de8f196963b 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotExtensions.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotExtensions.cs
@@ -3,8 +3,7 @@
using Microsoft.AspNetCore.Razor;
using Microsoft.AspNetCore.Razor.PooledObjects;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
-using Microsoft.AspNetCore.Razor.Serialization;
+using Microsoft.CodeAnalysis.Razor.Serialization;
namespace Microsoft.CodeAnalysis.Razor.ProjectSystem;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManager.Updater.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManager.Updater.cs
index ea36430034a..3ec450833c0 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManager.Updater.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManager.Updater.cs
@@ -3,7 +3,6 @@
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis.Razor.ProjectSystem;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManager.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManager.cs
index b92ac3a4bf0..100aac25fe5 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManager.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManager.cs
@@ -9,9 +9,9 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.PooledObjects;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
using Microsoft.AspNetCore.Razor.Threading;
using Microsoft.CodeAnalysis.Razor.Logging;
+using Microsoft.CodeAnalysis.Razor.ProjectEngineHost;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis.Razor.ProjectSystem;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManagerExtensions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManagerExtensions.cs
index 1e9a7fba8ab..e75de0820d5 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManagerExtensions.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshotManagerExtensions.cs
@@ -3,7 +3,6 @@
using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Razor;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
namespace Microsoft.CodeAnalysis.Razor.ProjectSystem;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectState.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectState.cs
index 2a1f79d2d96..c7c77c9d2d4 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectState.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectState.cs
@@ -11,10 +11,9 @@
using Microsoft.AspNetCore.Razor;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.PooledObjects;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
-using Microsoft.AspNetCore.Razor.Utilities;
using Microsoft.CodeAnalysis.CSharp;
-
+using Microsoft.CodeAnalysis.Razor.ProjectEngineHost;
+using Microsoft.CodeAnalysis.Razor.Utilities;
using Microsoft.CodeAnalysis.Text;
using Microsoft.Extensions.ObjectPool;
@@ -259,7 +258,7 @@ public ProjectState WithHostProject(HostProject hostProject)
return this;
}
- var documents = UpdateDocuments(static x => x.WithConfigurationChange());
+ var documents = UpdateDocuments(static x => x.UpdateVersion());
// If the host project has changed then we need to recompute the imports map
var importsToRelatedDocuments = BuildImportsMap(documents.Values, ProjectEngine);
@@ -277,7 +276,7 @@ public ProjectState WithProjectWorkspaceState(ProjectWorkspaceState projectWorks
return this;
}
- var documents = UpdateDocuments(static x => x.WithProjectWorkspaceStateChange());
+ var documents = UpdateDocuments(static x => x.UpdateVersion());
return new(this, HostProject, projectWorkspaceState, documents, ImportsToRelatedDocuments, retainProjectEngine: true);
}
@@ -378,7 +377,7 @@ private ImmutableDictionary UpdateRelatedDocumentsIfNeces
return documents;
}
- var updates = relatedDocuments.Select(x => KeyValuePair.Create(x, documents[x].WithImportsChange()));
+ var updates = relatedDocuments.Select(x => KeyValuePair.Create(x, documents[x].UpdateVersion()));
return documents.SetItems(updates);
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectWorkspaceState.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectWorkspaceState.cs
index f8eb552ce80..ecbc2807360 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectWorkspaceState.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectWorkspaceState.cs
@@ -7,7 +7,7 @@
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.Extensions.Internal;
-namespace Microsoft.AspNetCore.Razor.ProjectSystem;
+namespace Microsoft.CodeAnalysis.Razor.ProjectSystem;
internal sealed class ProjectWorkspaceState : IEquatable
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/RazorProjectInfo.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/RazorProjectInfo.cs
index 86158c6ceb9..af4fbdc65f7 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/RazorProjectInfo.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/RazorProjectInfo.cs
@@ -11,12 +11,12 @@
using MessagePack;
using MessagePack.Resolvers;
using Microsoft.AspNetCore.Razor.Language;
-using Microsoft.AspNetCore.Razor.Serialization;
-using Microsoft.AspNetCore.Razor.Serialization.MessagePack.Resolvers;
using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Razor.Serialization;
+using Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Resolvers;
using Microsoft.Extensions.Internal;
-namespace Microsoft.AspNetCore.Razor.ProjectSystem;
+namespace Microsoft.CodeAnalysis.Razor.ProjectSystem;
internal sealed record class RazorProjectInfo
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/Sources/GeneratedOutputSource.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/Sources/GeneratedOutputSource.cs
index 218a6b5b305..57243cc51d2 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/Sources/GeneratedOutputSource.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/Sources/GeneratedOutputSource.cs
@@ -1,27 +1,38 @@
// 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 System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
-using Microsoft.AspNetCore.Razor.Threading;
+using Microsoft.CodeAnalysis.Razor.Threading;
namespace Microsoft.CodeAnalysis.Razor.ProjectSystem.Sources;
-internal sealed class GeneratedOutputSource
+internal sealed class GeneratedOutputSource(DocumentSnapshot document)
{
+ private readonly DocumentSnapshot _document = document;
private readonly SemaphoreSlim _gate = new(initialCount: 1);
- private RazorCodeDocument? _output;
+ // Hold the output in a WeakReference to avoid memory leaks in the case of a long-lived
+ // document snapshots. In particular, the DynamicFileInfo system results in the Roslyn
+ // workspace holding onto document snapshots.
+ private WeakReference? _output;
public bool TryGetValue([NotNullWhen(true)] out RazorCodeDocument? result)
{
- result = _output;
- return result is not null;
+ var output = _output;
+ if (output is null)
+ {
+ result = null;
+ return false;
+ }
+
+ return output.TryGetTarget(out result);
}
- public async ValueTask GetValueAsync(DocumentSnapshot document, CancellationToken cancellationToken)
+ public async ValueTask GetValueAsync(CancellationToken cancellationToken)
{
if (TryGetValue(out var result))
{
@@ -35,15 +46,24 @@ public async ValueTask GetValueAsync(DocumentSnapshot documen
return result;
}
- var project = document.Project;
+ var project = _document.Project;
var projectEngine = project.ProjectEngine;
var compilerOptions = project.CompilerOptions;
- _output = await CompilationHelpers
- .GenerateCodeDocumentAsync(document, projectEngine, compilerOptions, cancellationToken)
+ result = await CompilationHelpers
+ .GenerateCodeDocumentAsync(_document, projectEngine, compilerOptions, cancellationToken)
.ConfigureAwait(false);
- return _output;
+ if (_output is null)
+ {
+ _output = new(result);
+ }
+ else
+ {
+ _output.SetTarget(result);
+ }
+
+ return result;
}
}
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/AbstractClientCapabilitiesService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/AbstractClientCapabilitiesService.cs
index c79fa014352..c6150c8fc01 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/AbstractClientCapabilitiesService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/AbstractClientCapabilitiesService.cs
@@ -2,7 +2,6 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Protocol;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/AutoInsert/RemoteAutoInsertTextEdit.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/AutoInsert/RemoteAutoInsertTextEdit.cs
index 0a56e5b12c2..acb0073d424 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/AutoInsert/RemoteAutoInsertTextEdit.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/AutoInsert/RemoteAutoInsertTextEdit.cs
@@ -3,10 +3,6 @@
using System.Runtime.Serialization;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
-using static Microsoft.VisualStudio.LanguageServer.Protocol.VsLspExtensions;
-using static Roslyn.LanguageServer.Protocol.RoslynLspExtensions;
-using RoslynInsertTextFormat = Roslyn.LanguageServer.Protocol.InsertTextFormat;
namespace Microsoft.CodeAnalysis.Razor.Protocol.AutoInsert;
@@ -14,19 +10,19 @@ namespace Microsoft.CodeAnalysis.Razor.Protocol.AutoInsert;
internal readonly record struct RemoteAutoInsertTextEdit(
[property: DataMember(Order = 0)] LinePositionSpan LinePositionSpan,
[property: DataMember(Order = 1)] string NewText,
- [property: DataMember(Order = 2)] RoslynInsertTextFormat InsertTextFormat)
+ [property: DataMember(Order = 2)] InsertTextFormat InsertTextFormat)
{
public static RemoteAutoInsertTextEdit FromLspInsertTextEdit(VSInternalDocumentOnAutoInsertResponseItem edit)
=> new(
edit.TextEdit.Range.ToLinePositionSpan(),
edit.TextEdit.NewText,
- (RoslynInsertTextFormat)edit.TextEditFormat);
+ edit.TextEditFormat);
public static VSInternalDocumentOnAutoInsertResponseItem ToLspInsertTextEdit(RemoteAutoInsertTextEdit edit)
=> new()
{
- TextEdit = VsLspFactory.CreateTextEdit(edit.LinePositionSpan, edit.NewText),
- TextEditFormat = (InsertTextFormat)edit.InsertTextFormat,
+ TextEdit = LspFactory.CreateTextEdit(edit.LinePositionSpan, edit.NewText),
+ TextEditFormat = edit.InsertTextFormat,
};
public override string ToString()
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/CodeActions/FormatNewFileParams.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/CodeActions/FormatNewFileParams.cs
index 6c2f5d4b282..4fa3b5b7fbd 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/CodeActions/FormatNewFileParams.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/CodeActions/FormatNewFileParams.cs
@@ -3,7 +3,6 @@
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Protocol.CodeActions;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/CodeActions/RazorResolveCodeActionParams.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/CodeActions/RazorResolveCodeActionParams.cs
index 4ecf43d0505..5e82598af39 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/CodeActions/RazorResolveCodeActionParams.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/CodeActions/RazorResolveCodeActionParams.cs
@@ -2,7 +2,6 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Text.Json.Serialization;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Protocol.CodeActions;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/CodeActions/SimplifyMethodParams.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/CodeActions/SimplifyMethodParams.cs
index 516afa1fd4d..2a25dd30c47 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/CodeActions/SimplifyMethodParams.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/CodeActions/SimplifyMethodParams.cs
@@ -3,7 +3,6 @@
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Protocol.CodeActions;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/CodeActions/VSCodeActionParams.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/CodeActions/VSCodeActionParams.cs
index ae017574b92..6f6c27b574f 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/CodeActions/VSCodeActionParams.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/CodeActions/VSCodeActionParams.cs
@@ -3,7 +3,6 @@
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Protocol.CodeActions;
@@ -22,7 +21,7 @@ internal class VSCodeActionParams
[JsonPropertyName("range")]
[DataMember(Name = "range")]
- public required Range Range { get; set; }
+ public required LspRange Range { get; set; }
[JsonPropertyName("context")]
[DataMember(Name = "context")]
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/ColorPresentation/ColorPresentation.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/ColorPresentation/ColorPresentation.cs
deleted file mode 100644
index d8f678ac6bc..00000000000
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/ColorPresentation/ColorPresentation.cs
+++ /dev/null
@@ -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.
-
-#nullable disable
-
-using System.Text.Json.Serialization;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
-
-namespace Microsoft.CodeAnalysis.Razor.Protocol.ColorPresentation;
-
-// VS doesn't support textDocument/colorPresentation but VSCode does. This class is a workaround until VS adds support.
-internal sealed class ColorPresentation
-{
- [JsonPropertyName("label")]
- public string Label { get; set; }
-
- [JsonPropertyName("textEdit")]
- public TextEdit TextEdit { get; set; }
-
- [JsonPropertyName("additionalTextEdits")]
- public TextEdit[] AdditionalTextEdits { get; set; }
-}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/ColorPresentation/ColorPresentationParams.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/ColorPresentation/ColorPresentationParams.cs
deleted file mode 100644
index e56dfddec45..00000000000
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/ColorPresentation/ColorPresentationParams.cs
+++ /dev/null
@@ -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.
-
-#nullable disable
-
-using System.Text.Json.Serialization;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
-
-namespace Microsoft.CodeAnalysis.Razor.Protocol.ColorPresentation;
-
-// VS doesn't support textDocument/colorPresentation but VSCode does. This class is a workaround until VS adds support.
-internal class ColorPresentationParams
-{
- [JsonPropertyName("textDocument")]
- public TextDocumentIdentifier TextDocument { get; set; }
-
- [JsonPropertyName("color")]
- public Color Color { get; set; }
-
- [JsonPropertyName("range")]
- public Range Range { get; set; }
-}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/ColorPresentation/DelegatedDocumentColorParams.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/ColorPresentation/DelegatedDocumentColorParams.cs
index 89729afc428..6c5709be2a3 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/ColorPresentation/DelegatedDocumentColorParams.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/ColorPresentation/DelegatedDocumentColorParams.cs
@@ -2,7 +2,6 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Text.Json.Serialization;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Protocol.ColorPresentation;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Competion/CompletionPositionInfo.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Completion/CompletionPositionInfo.cs
similarity index 96%
rename from src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Competion/CompletionPositionInfo.cs
rename to src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Completion/CompletionPositionInfo.cs
index 9132419d11b..66788f38f5e 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Competion/CompletionPositionInfo.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Completion/CompletionPositionInfo.cs
@@ -3,7 +3,6 @@
using System.Text.Json.Serialization;
using Microsoft.CodeAnalysis.Razor.DocumentMapping;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Protocol.Completion;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Completion/RazorInlineCompletionRequest.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Completion/RazorInlineCompletionRequest.cs
index 2c4a0a6b689..07aaf76af78 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Completion/RazorInlineCompletionRequest.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Completion/RazorInlineCompletionRequest.cs
@@ -2,7 +2,6 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Text.Json.Serialization;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Protocol.Completion;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Completion/RazorVSInternalCompletionList.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Completion/RazorVSInternalCompletionList.cs
new file mode 100644
index 00000000000..eccf35ebb18
--- /dev/null
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Completion/RazorVSInternalCompletionList.cs
@@ -0,0 +1,45 @@
+// 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 System.Text.Json.Serialization;
+using Microsoft.CodeAnalysis.Razor.Protocol;
+
+namespace Roslyn.LanguageServer.Protocol;
+
+///
+/// A subclass of the LSP protocol that ensures correct serialization between LSP servers.
+///
+///
+/// This is the same as the LSP protocol except that it strongly types the property,
+/// because our custom message target gets handled by a JsonRpc connection set up by the editor, that has no Roslyn converters.
+///
+internal sealed class RazorVSInternalCompletionList : VSInternalCompletionList
+{
+ public RazorVSInternalCompletionList()
+ {
+ }
+
+ [SetsRequiredMembers]
+ public RazorVSInternalCompletionList(VSInternalCompletionList completionList)
+ {
+ this.Data = completionList.Data;
+ this.CommitCharacters = completionList.CommitCharacters;
+ this.ContinueCharacters = completionList.ContinueCharacters;
+ this.IsIncomplete = completionList.IsIncomplete;
+ this.Items = JsonHelpers.ConvertAll(completionList.Items);
+ this.ItemDefaults = completionList.ItemDefaults;
+ this.SuggestionMode = completionList.SuggestionMode;
+ }
+
+ ///
+ /// The completion items.
+ ///
+ [JsonPropertyName("items")]
+ [JsonRequired]
+ public new required VSInternalCompletionItem[] Items
+ {
+ get => (VSInternalCompletionItem[])base.Items;
+ set => base.Items = value;
+ }
+}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Debugging/RazorBreakpointSpanParams.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Debugging/RazorBreakpointSpanParams.cs
index fdf956fc7f4..40db6e9e947 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Debugging/RazorBreakpointSpanParams.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Debugging/RazorBreakpointSpanParams.cs
@@ -3,7 +3,6 @@
using System;
using System.Text.Json.Serialization;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Protocol.Debugging;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Debugging/RazorBreakpointSpanResponse.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Debugging/RazorBreakpointSpanResponse.cs
index c12d63eb605..880ae17e051 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Debugging/RazorBreakpointSpanResponse.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Debugging/RazorBreakpointSpanResponse.cs
@@ -2,12 +2,11 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Text.Json.Serialization;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Protocol.Debugging;
internal class RazorBreakpointSpanResponse
{
[JsonPropertyName("range")]
- public required Range Range { get; init; }
+ public required LspRange Range { get; init; }
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Debugging/RazorProximityExpressionsParams.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Debugging/RazorProximityExpressionsParams.cs
index 8f20b3ff8ac..93b268338a9 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Debugging/RazorProximityExpressionsParams.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Debugging/RazorProximityExpressionsParams.cs
@@ -3,7 +3,6 @@
using System;
using System.Text.Json.Serialization;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Protocol.Debugging;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DelegatedTypes.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DelegatedTypes.cs
index bbfb3dcf1fd..6e974b7c7e3 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DelegatedTypes.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DelegatedTypes.cs
@@ -11,7 +11,6 @@
namespace Microsoft.CodeAnalysis.Razor.Protocol;
using Microsoft.CodeAnalysis.Razor.Completion;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
internal record DelegatedSpellCheckParams(
[property: JsonPropertyName("identifier")] TextDocumentIdentifierAndVersion Identifier);
@@ -27,7 +26,7 @@ internal record DelegatedPositionParams(
internal record DelegatedInlayHintParams(
[property: JsonPropertyName("identifier")] TextDocumentIdentifierAndVersion Identifier,
- [property: JsonPropertyName("projectedRange")] Range ProjectedRange,
+ [property: JsonPropertyName("projectedRange")] LspRange ProjectedRange,
[property: JsonPropertyName("projectedKind")] RazorLanguageKind ProjectedKind) : IDelegatedParams;
internal record DelegatedInlayHintResolveParams(
@@ -37,7 +36,7 @@ internal record DelegatedInlayHintResolveParams(
internal record DelegatedValidateBreakpointRangeParams(
[property: JsonPropertyName("identifier")] TextDocumentIdentifierAndVersion Identifier,
- [property: JsonPropertyName("projectedRange")] Range ProjectedRange,
+ [property: JsonPropertyName("projectedRange")] LspRange ProjectedRange,
[property: JsonPropertyName("projectedKind")] RazorLanguageKind ProjectedKind) : IDelegatedParams;
internal record DelegatedOnAutoInsertParams(
@@ -67,7 +66,7 @@ internal record DelegatedMapCodeParams(
[property: JsonPropertyName("projectedKind")] RazorLanguageKind ProjectedKind,
[property: JsonPropertyName("mapCodeCorrelationId")] Guid MapCodeCorrelationId,
[property: JsonPropertyName("contents")] string[] Contents,
- [property: JsonPropertyName("focusLocations")] Location[][] FocusLocations) : IDelegatedParams;
+ [property: JsonPropertyName("focusLocations")] LspLocation[][] FocusLocations) : IDelegatedParams;
internal record DelegatedCompletionResolutionContext(
[property: JsonPropertyName("originalRequestParams")] DelegatedCompletionParams OriginalRequestParams,
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Diagnostics/RazorPullDiagnosticResponse.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Diagnostics/RazorPullDiagnosticResponse.cs
index 91ee4523003..a619552fde2 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Diagnostics/RazorPullDiagnosticResponse.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Diagnostics/RazorPullDiagnosticResponse.cs
@@ -2,7 +2,6 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Text.Json.Serialization;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Protocol.Diagnostics;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentHighlight/RemoteDocumentHighlight.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentHighlight/RemoteDocumentHighlight.cs
index c40741ebff5..27d88ed9c3e 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentHighlight/RemoteDocumentHighlight.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentHighlight/RemoteDocumentHighlight.cs
@@ -3,10 +3,6 @@
using System.Runtime.Serialization;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
-using static Roslyn.LanguageServer.Protocol.RoslynLspExtensions;
-using RoslynDocumentHighlight = Roslyn.LanguageServer.Protocol.DocumentHighlight;
-using VsDocumentHighlight = Microsoft.VisualStudio.LanguageServer.Protocol.DocumentHighlight;
namespace Microsoft.CodeAnalysis.Razor.Protocol.DocumentHighlight;
@@ -15,13 +11,13 @@ internal readonly record struct RemoteDocumentHighlight(
[property: DataMember(Order = 0)] LinePositionSpan Span,
[property: DataMember(Order = 1)] DocumentHighlightKind Kind)
{
- public static RemoteDocumentHighlight FromRoslynDocumentHighlight(RoslynDocumentHighlight highlight)
- => new(highlight.Range.ToLinePositionSpan(), (DocumentHighlightKind)highlight.Kind);
+ public static RemoteDocumentHighlight FromLspDocumentHighlight(LspDocumentHighlight highlight)
+ => new(highlight.Range.ToLinePositionSpan(), highlight.Kind);
- public static VsDocumentHighlight ToVsDocumentHighlight(RemoteDocumentHighlight highlight)
+ public static LspDocumentHighlight ToLspDocumentHighlight(RemoteDocumentHighlight highlight)
=> new()
{
- Range = VsLspExtensions.ToRange(highlight.Span),
+ Range = highlight.Span.ToRange(),
Kind = highlight.Kind
};
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentMapping/RazorMapToDocumentRangesParams.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentMapping/RazorMapToDocumentRangesParams.cs
index cd9b57edc84..78137566d81 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentMapping/RazorMapToDocumentRangesParams.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentMapping/RazorMapToDocumentRangesParams.cs
@@ -4,7 +4,6 @@
using System;
using System.Text.Json.Serialization;
using Microsoft.CodeAnalysis.Razor.DocumentMapping;
-using Range = Microsoft.VisualStudio.LanguageServer.Protocol.Range;
namespace Microsoft.CodeAnalysis.Razor.Protocol.DocumentMapping;
@@ -17,7 +16,7 @@ internal class RazorMapToDocumentRangesParams
public required Uri RazorDocumentUri { get; init; }
[JsonPropertyName("projectedRanges")]
- public required Range[] ProjectedRanges { get; init; }
+ public required LspRange[] ProjectedRanges { get; init; }
[JsonPropertyName("mappingBehavior")]
public MappingBehavior MappingBehavior { get; init; }
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentMapping/RazorMapToDocumentRangesResponse.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentMapping/RazorMapToDocumentRangesResponse.cs
index 60e5f99fbc4..f82ea528651 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentMapping/RazorMapToDocumentRangesResponse.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentMapping/RazorMapToDocumentRangesResponse.cs
@@ -2,14 +2,13 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Text.Json.Serialization;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Protocol.DocumentMapping;
internal class RazorMapToDocumentRangesResponse
{
[JsonPropertyName("ranges")]
- public required Range[] Ranges { get; init; }
+ public required LspRange[] Ranges { get; init; }
[JsonPropertyName("hostDocumentVersion")]
public int? HostDocumentVersion { get; init; }
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentPresentation/IPresentationParams.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentPresentation/IPresentationParams.cs
index 374c2f7c136..603c3a5c336 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentPresentation/IPresentationParams.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentPresentation/IPresentationParams.cs
@@ -1,14 +1,12 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
-using Microsoft.VisualStudio.LanguageServer.Protocol;
-
namespace Microsoft.CodeAnalysis.Razor.Protocol.DocumentPresentation;
internal interface IPresentationParams
{
TextDocumentIdentifier TextDocument { get; set; }
- Range Range { get; set; }
+ LspRange Range { get; set; }
}
internal interface IRazorPresentationParams : IPresentationParams
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentPresentation/TextPresentationParams.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentPresentation/TextPresentationParams.cs
index 8e5efe7327d..dde9959fc0a 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentPresentation/TextPresentationParams.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentPresentation/TextPresentationParams.cs
@@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
-using Microsoft.VisualStudio.LanguageServer.Protocol;
-
namespace Microsoft.CodeAnalysis.Razor.Protocol.DocumentPresentation;
///
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentPresentation/UriPresentationParams.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentPresentation/UriPresentationParams.cs
index 0bd8aa3fe21..aab83fadf5b 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentPresentation/UriPresentationParams.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentPresentation/UriPresentationParams.cs
@@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
-using Microsoft.VisualStudio.LanguageServer.Protocol;
-
namespace Microsoft.CodeAnalysis.Razor.Protocol.DocumentPresentation;
///
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentSymbols/DocumentSymbolService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentSymbols/DocumentSymbolService.cs
index aafd371c38e..38f148ae0ed 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentSymbols/DocumentSymbolService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentSymbols/DocumentSymbolService.cs
@@ -6,7 +6,6 @@
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.PooledObjects;
using Microsoft.CodeAnalysis.Razor.DocumentMapping;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Protocol.DocumentSymbols;
@@ -26,12 +25,15 @@ internal class DocumentSymbolService(IDocumentMappingService documentMappingServ
foreach (var symbolInformation in symbolInformations)
{
+#pragma warning disable CS0618 // Type or member is obsolete
+ // SymbolInformation is obsolete, but things still return it so we have to handle it
if (_documentMappingService.TryMapToHostDocumentRange(csharpDocument, symbolInformation.Location.Range, out var newRange))
{
symbolInformation.Location.Range = newRange;
symbolInformation.Location.Uri = razorDocumentUri;
mappedSymbols.Add(symbolInformation);
}
+#pragma warning restore CS0618 // Type or member is obsolete
}
return mappedSymbols.ToArray();
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentSymbols/IDocumentSymbolService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentSymbols/IDocumentSymbolService.cs
index e2a579a5c07..5bec48765da 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentSymbols/IDocumentSymbolService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/DocumentSymbols/IDocumentSymbolService.cs
@@ -3,7 +3,6 @@
using System;
using Microsoft.AspNetCore.Razor.Language;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Protocol.DocumentSymbols;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Folding/RazorFoldingRangeRequestParam.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Folding/RazorFoldingRangeRequestParam.cs
index 90b07fe6ad2..6b73e90c6b1 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Folding/RazorFoldingRangeRequestParam.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Folding/RazorFoldingRangeRequestParam.cs
@@ -2,7 +2,6 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Text.Json.Serialization;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Protocol.Folding;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Folding/RazorFoldingRangeResponse.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Folding/RazorFoldingRangeResponse.cs
index b08e8a162c7..c39b0968321 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Folding/RazorFoldingRangeResponse.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Folding/RazorFoldingRangeResponse.cs
@@ -3,7 +3,6 @@
using System.Collections.Immutable;
using System.Text.Json.Serialization;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Protocol.Folding;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Folding/RemoteFoldingRange.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Folding/RemoteFoldingRange.cs
index 59d83bb8603..ea5883997db 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Folding/RemoteFoldingRange.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Folding/RemoteFoldingRange.cs
@@ -2,7 +2,6 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Runtime.Serialization;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Protocol.Folding;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Formatting/RazorDocumentFormattingParams.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Formatting/RazorDocumentFormattingParams.cs
index c4a4f7cceb3..d7b3047ba22 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Formatting/RazorDocumentFormattingParams.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Formatting/RazorDocumentFormattingParams.cs
@@ -2,7 +2,6 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Text.Json.Serialization;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Protocol.Formatting;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Formatting/RazorDocumentFormattingResponse.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Formatting/RazorDocumentFormattingResponse.cs
index b9cb31f7344..4601480b045 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Formatting/RazorDocumentFormattingResponse.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Formatting/RazorDocumentFormattingResponse.cs
@@ -2,7 +2,6 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Text.Json.Serialization;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Protocol.Formatting;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Formatting/RazorDocumentOnTypeFormattingParams.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Formatting/RazorDocumentOnTypeFormattingParams.cs
index 818c49d9197..3162fbec804 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Formatting/RazorDocumentOnTypeFormattingParams.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/Formatting/RazorDocumentOnTypeFormattingParams.cs
@@ -2,7 +2,6 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Text.Json.Serialization;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Protocol.Formatting;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/IClientCapabilitiesService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/IClientCapabilitiesService.cs
index c8d26fd18c6..53c5c1aa096 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/IClientCapabilitiesService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/IClientCapabilitiesService.cs
@@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
-using Microsoft.VisualStudio.LanguageServer.Protocol;
-
namespace Microsoft.CodeAnalysis.Razor.Protocol;
internal interface IClientCapabilitiesService
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/InlayHints/InlayHintDataWrapper.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/InlayHints/InlayHintDataWrapper.cs
index 78dd8b5f351..ab42932d7de 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/InlayHints/InlayHintDataWrapper.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/InlayHints/InlayHintDataWrapper.cs
@@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
-using Roslyn.LanguageServer.Protocol;
-
namespace Microsoft.CodeAnalysis.Razor.Protocol.InlayHints;
internal record class InlayHintDataWrapper(TextDocumentIdentifier TextDocument, object? OriginalData, Position OriginalPosition);
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/JsonHelpers.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/JsonHelpers.cs
index 67fd12b5d1c..7ead0d6947c 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/JsonHelpers.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/JsonHelpers.cs
@@ -2,53 +2,57 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
+using System.Diagnostics;
using System.Text.Json;
+using Microsoft.AspNetCore.Razor.PooledObjects;
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Protocol;
internal static class JsonHelpers
{
- private static readonly Lazy s_roslynLspJsonSerializerOptions = new(CreateRoslynLspJsonSerializerOptions);
- private static readonly Lazy s_vsLspJsonSerializerOptions = new(CreateVsLspJsonSerializerOptions);
+ private static readonly Lazy s_jsonSerializerOptions = new(CreateJsonSerializerOptions);
///
/// Serializer options to use when serializing or deserializing a Roslyn LSP type
///
- internal static JsonSerializerOptions RoslynLspJsonSerializerOptions => s_roslynLspJsonSerializerOptions.Value;
+ internal static JsonSerializerOptions JsonSerializerOptions => s_jsonSerializerOptions.Value;
///
- /// Serializer options to use when serializing or deserializing a VS Platform LSP type
+ /// Converts an LSP object to a different LSP object, either by casting or serializing and deserializing
///
- internal static JsonSerializerOptions VsLspJsonSerializerOptions => s_vsLspJsonSerializerOptions.Value;
-
- ///
- /// Converts a Roslyn LSP object to a VS Platform LSP object via serializing to text and deserializing to VS LSP type
- ///
- internal static TVsLspResult? ToVsLSP(TRoslynLspSource source)
+ internal static TResult? Convert(TSource? source)
{
- return JsonSerializer.Deserialize(JsonSerializer.SerializeToDocument(source, RoslynLspJsonSerializerOptions), VsLspJsonSerializerOptions);
- }
+ if (source is TResult result)
+ {
+ return result;
+ }
- ///
- /// Converts a VS Platform LSP object to a Roslyn LSP object via serializing to text and deserializing to Roslyn LSP type
- ///
- internal static TRoslynLspResult? ToRoslynLSP(TVsLspSource? source)
- {
- return JsonSerializer.Deserialize(JsonSerializer.SerializeToDocument(source, VsLspJsonSerializerOptions), RoslynLspJsonSerializerOptions);
+ return JsonSerializer.Deserialize(JsonSerializer.SerializeToDocument(source, JsonSerializerOptions), JsonSerializerOptions);
}
///
- /// Adds VS Platform LSP converters for VSInternal variation of types (e.g. VSInternalClientCapability from ClientCapability)
+ /// Converts an array of LSP objects to a different LSP object, either by casting or serializing and deserializing
///
- internal static void AddVSInternalExtensionConverters(JsonSerializerOptions serializerOptions)
+ internal static TResult[] ConvertAll(TSource[] source)
{
- // In its infinite wisdom, the LSP client has a public method that takes Newtonsoft.Json types, but an internal method that takes System.Text.Json types.
- typeof(VSInternalExtensionUtilities).GetMethod("AddVSInternalExtensionConverters", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic)!.Invoke(null, [serializerOptions]);
+ using var results = new PooledArrayBuilder(source.Length);
+ foreach (var item in source)
+ {
+ if (Convert(item) is { } converted)
+ {
+ results.Add(converted);
+ }
+ else
+ {
+ Debug.Fail("Could not convert item to expected type.");
+ }
+ }
+
+ return results.ToArray();
}
- private static JsonSerializerOptions CreateRoslynLspJsonSerializerOptions()
+ private static JsonSerializerOptions CreateJsonSerializerOptions()
{
var serializerOptions = new JsonSerializerOptions();
@@ -59,12 +63,4 @@ private static JsonSerializerOptions CreateRoslynLspJsonSerializerOptions()
return serializerOptions;
}
-
- private static JsonSerializerOptions CreateVsLspJsonSerializerOptions()
- {
- var serializerOptions = new JsonSerializerOptions();
-
- AddVSInternalExtensionConverters(serializerOptions);
- return serializerOptions;
- }
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/SemanticTokens/ProvideSemanticTokensRangesParams.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/SemanticTokens/ProvideSemanticTokensRangesParams.cs
index b1f7082ecbe..de4b8175176 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/SemanticTokens/ProvideSemanticTokensRangesParams.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/SemanticTokens/ProvideSemanticTokensRangesParams.cs
@@ -3,8 +3,6 @@
using System;
using System.Text.Json.Serialization;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
-using Range = Microsoft.VisualStudio.LanguageServer.Protocol.Range;
namespace Microsoft.CodeAnalysis.Razor.Workspaces.Protocol.SemanticTokens;
@@ -14,12 +12,12 @@ internal class ProvideSemanticTokensRangesParams : SemanticTokensParams
public int RequiredHostDocumentVersion { get; }
[JsonPropertyName("ranges")]
- public Range[] Ranges { get; }
+ public LspRange[] Ranges { get; }
[JsonPropertyName("correlationId")]
public Guid CorrelationId { get; }
- public ProvideSemanticTokensRangesParams(TextDocumentIdentifier textDocument, int requiredHostDocumentVersion, Range[] ranges, Guid correlationId)
+ public ProvideSemanticTokensRangesParams(TextDocumentIdentifier textDocument, int requiredHostDocumentVersion, LspRange[] ranges, Guid correlationId)
{
TextDocument = textDocument;
RequiredHostDocumentVersion = requiredHostDocumentVersion;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/SemanticTokens/SemanticTokensRangesParams.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/SemanticTokens/SemanticTokensRangesParams.cs
index 10864b93015..6f17bab2471 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/SemanticTokens/SemanticTokensRangesParams.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/SemanticTokens/SemanticTokensRangesParams.cs
@@ -2,12 +2,11 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Text.Json.Serialization;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Workspaces.Protocol.SemanticTokens;
-internal class SemanticTokensRangesParams : SemanticTokensParams
+internal class SemanticTokensRangesParams : SemanticTokensRangeParams
{
[JsonPropertyName("ranges")]
- public required Range[] Ranges { get; set; }
+ public required LspRange[] Ranges { get; set; }
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/TextDocumentIdentifierAndVersion.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/TextDocumentIdentifierAndVersion.cs
index 14ba06b25a8..80fab7d2d60 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/TextDocumentIdentifierAndVersion.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/TextDocumentIdentifierAndVersion.cs
@@ -2,7 +2,6 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Text.Json.Serialization;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Protocol;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/UpdateBufferRequest.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/UpdateBufferRequest.cs
index 41da2755228..20d919e88c4 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/UpdateBufferRequest.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/UpdateBufferRequest.cs
@@ -11,6 +11,9 @@ internal sealed class UpdateBufferRequest
[JsonPropertyName("hostDocumentVersion")]
public int? HostDocumentVersion { get; set; }
+ [JsonPropertyName("previousHostDocumentVersion")]
+ public int? PreviousHostDocumentVersion { get; set; }
+
[JsonPropertyName("projectKeyId")]
public string? ProjectKeyId { get; set; }
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/RazorComponentSearchEngine.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/RazorComponentSearchEngine.cs
index 3dd695c253c..070970f6b65 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/RazorComponentSearchEngine.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/RazorComponentSearchEngine.cs
@@ -5,7 +5,6 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Logging;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteCodeActionsService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteCodeActionsService.cs
index 16dc36c7828..62c7f5a3378 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteCodeActionsService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteCodeActionsService.cs
@@ -7,7 +7,6 @@
using Microsoft.CodeAnalysis.Razor.CodeActions.Models;
using Microsoft.CodeAnalysis.Razor.Formatting;
using Microsoft.CodeAnalysis.Razor.Protocol.CodeActions;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Remote;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteCompletionService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteCompletionService.cs
index 1f371d4a92d..9ed8c840bb3 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteCompletionService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteCompletionService.cs
@@ -7,8 +7,7 @@
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
using Microsoft.CodeAnalysis.Razor.Completion;
using Microsoft.CodeAnalysis.Razor.Protocol.Completion;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
-using Response = Microsoft.CodeAnalysis.Razor.Remote.RemoteResponse;
+using Response = Microsoft.CodeAnalysis.Razor.Remote.RemoteResponse;
namespace Microsoft.CodeAnalysis.Razor.Remote;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteDiagnosticsService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteDiagnosticsService.cs
index 3aa6be1954c..60fd4fc3f32 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteDiagnosticsService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteDiagnosticsService.cs
@@ -5,20 +5,19 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
-using RoslynLspDiagnostic = Microsoft.VisualStudio.LanguageServer.Protocol.Diagnostic;
namespace Microsoft.CodeAnalysis.Razor.Remote;
internal interface IRemoteDiagnosticsService : IRemoteJsonService
{
- ValueTask> GetDiagnosticsAsync(
+ ValueTask> GetDiagnosticsAsync(
JsonSerializableRazorPinnedSolutionInfoWrapper solutionInfo,
JsonSerializableDocumentId documentId,
- RoslynLspDiagnostic[] csharpDiagnostics,
- RoslynLspDiagnostic[] htmlDiagnostics,
+ LspDiagnostic[] csharpDiagnostics,
+ LspDiagnostic[] htmlDiagnostics,
CancellationToken cancellationToken);
- ValueTask> GetTaskListDiagnosticsAsync(
+ ValueTask> GetTaskListDiagnosticsAsync(
JsonSerializableRazorPinnedSolutionInfoWrapper solutionInfo,
JsonSerializableDocumentId documentId,
ImmutableArray taskListDescriptors,
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteDocumentSymbolService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteDocumentSymbolService.cs
index 095033d8932..e1a3785d215 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteDocumentSymbolService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteDocumentSymbolService.cs
@@ -4,7 +4,6 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Remote;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteFindAllReferencesService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteFindAllReferencesService.cs
index 156601890c5..21f03cc8aa6 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteFindAllReferencesService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteFindAllReferencesService.cs
@@ -4,8 +4,6 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
-using Roslyn.LanguageServer.Protocol;
-using LspLocation = Roslyn.LanguageServer.Protocol.Location;
namespace Microsoft.CodeAnalysis.Razor.Remote;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteGoToDefinitionService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteGoToDefinitionService.cs
index b8e91db72c5..ae88daac58c 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteGoToDefinitionService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteGoToDefinitionService.cs
@@ -4,16 +4,14 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
-using RoslynLocation = Roslyn.LanguageServer.Protocol.Location;
-using RoslynPosition = Roslyn.LanguageServer.Protocol.Position;
namespace Microsoft.CodeAnalysis.Razor.Remote;
internal interface IRemoteGoToDefinitionService : IRemoteJsonService
{
- ValueTask> GetDefinitionAsync(
+ ValueTask> GetDefinitionAsync(
JsonSerializableRazorPinnedSolutionInfoWrapper solutionInfo,
JsonSerializableDocumentId razorDocumentId,
- RoslynPosition position,
+ Position position,
CancellationToken cancellationToken);
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteGoToImplementationService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteGoToImplementationService.cs
index 41311404578..7036cc58073 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteGoToImplementationService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteGoToImplementationService.cs
@@ -4,16 +4,14 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
-using RoslynLocation = Roslyn.LanguageServer.Protocol.Location;
-using RoslynPosition = Roslyn.LanguageServer.Protocol.Position;
namespace Microsoft.CodeAnalysis.Razor.Remote;
internal interface IRemoteGoToImplementationService : IRemoteJsonService
{
- ValueTask> GetImplementationAsync(
+ ValueTask> GetImplementationAsync(
JsonSerializableRazorPinnedSolutionInfoWrapper solutionInfo,
JsonSerializableDocumentId razorDocumentId,
- RoslynPosition position,
+ Position position,
CancellationToken cancellationToken);
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteHoverService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteHoverService.cs
index 9a47dc792b9..d0d8dc8772a 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteHoverService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteHoverService.cs
@@ -4,16 +4,14 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
-using RoslynHover = Roslyn.LanguageServer.Protocol.Hover;
-using RoslynPosition = Roslyn.LanguageServer.Protocol.Position;
namespace Microsoft.CodeAnalysis.Razor.Remote;
internal interface IRemoteHoverService : IRemoteJsonService
{
- ValueTask> GetHoverAsync(
+ ValueTask> GetHoverAsync(
JsonSerializableRazorPinnedSolutionInfoWrapper solutionInfo,
JsonSerializableDocumentId documentId,
- RoslynPosition position,
+ Position position,
CancellationToken cancellationToken);
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteInlayHintService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteInlayHintService.cs
index 978e8d0ecb8..b27def1f0f1 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteInlayHintService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteInlayHintService.cs
@@ -4,7 +4,6 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
-using Roslyn.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Remote;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteRenameService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteRenameService.cs
index 0ccaf327c37..1a2cdf02ab1 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteRenameService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteRenameService.cs
@@ -4,7 +4,6 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Remote;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteSignatureHelpService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteSignatureHelpService.cs
index 82163933eef..5092f5cdfbd 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteSignatureHelpService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteSignatureHelpService.cs
@@ -4,13 +4,10 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
-using Roslyn.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Remote;
-using SignatureHelp = Roslyn.LanguageServer.Protocol.SignatureHelp;
-
internal interface IRemoteSignatureHelpService : IRemoteJsonService
{
- ValueTask GetSignatureHelpAsync(JsonSerializableRazorPinnedSolutionInfoWrapper solutionInfo, JsonSerializableDocumentId documentId, Position linePosition, CancellationToken cancellationToken);
+ ValueTask GetSignatureHelpAsync(JsonSerializableRazorPinnedSolutionInfoWrapper solutionInfo, JsonSerializableDocumentId documentId, Position linePosition, CancellationToken cancellationToken);
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteTagHelperProviderService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteTagHelperProviderService.cs
index eb17de0887c..d9899bec3d6 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteTagHelperProviderService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/IRemoteTagHelperProviderService.cs
@@ -4,9 +4,9 @@
using System.Collections.Immutable;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.AspNetCore.Razor.Serialization;
using Microsoft.AspNetCore.Razor.Utilities;
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
+using Microsoft.CodeAnalysis.Razor.Serialization;
namespace Microsoft.CodeAnalysis.Razor.Remote;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/RazorServices.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/RazorServices.cs
index 8d8b0a05d00..046e49b8eb2 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/RazorServices.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/RazorServices.cs
@@ -3,8 +3,8 @@
using System;
using System.Collections.Generic;
-using Microsoft.AspNetCore.Razor.Serialization.MessagePack.Resolvers;
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
+using Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Resolvers;
namespace Microsoft.CodeAnalysis.Razor.Remote;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/RemoteClientLSPInitializationOptions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/RemoteClientLSPInitializationOptions.cs
index 5c74a839ecc..f179b3d92a7 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/RemoteClientLSPInitializationOptions.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/RemoteClientLSPInitializationOptions.cs
@@ -2,7 +2,6 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Text.Json.Serialization;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Remote;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/TagHelperResultCache.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/TagHelperResultCache.cs
index c24e623bf4f..a0bb918a00b 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/TagHelperResultCache.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/TagHelperResultCache.cs
@@ -3,6 +3,7 @@
using System.Collections.Immutable;
using Microsoft.AspNetCore.Razor.Utilities;
+using Microsoft.CodeAnalysis.Razor.Utilities;
namespace Microsoft.CodeAnalysis.Razor.Remote;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Rename/IRenameService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Rename/IRenameService.cs
index 0c2f6b6044c..d22718840e1 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Rename/IRenameService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Rename/IRenameService.cs
@@ -5,7 +5,6 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Razor.DocumentMapping;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Rename;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Rename/RenameService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Rename/RenameService.cs
index ba8493f85c9..230ace81fbb 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Rename/RenameService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Rename/RenameService.cs
@@ -14,12 +14,10 @@
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.Syntax;
using Microsoft.AspNetCore.Razor.PooledObjects;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.DocumentMapping;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Protocol;
using Microsoft.CodeAnalysis.Razor.Workspaces;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
using RazorSyntaxKind = Microsoft.AspNetCore.Razor.Language.SyntaxKind;
using RazorSyntaxNode = Microsoft.AspNetCore.Razor.Language.Syntax.SyntaxNode;
@@ -40,7 +38,7 @@ internal class RenameService(
CancellationToken cancellationToken)
{
// We only support renaming of .razor components, not .cshtml tag helpers
- if (!FileKinds.IsComponent(documentContext.FileKind))
+ if (!documentContext.FileKind.IsComponent())
{
return null;
}
@@ -148,7 +146,7 @@ private Uri BuildUri(string filePath)
var updatedPath = _languageServerFeatureOptions.ReturnCodeActionAndRenamePathsWithPrefixedSlash && !filePath.StartsWith("/")
? '/' + filePath
: filePath;
- return VsLspFactory.CreateFilePathUri(updatedPath);
+ return LspFactory.CreateFilePathUri(updatedPath);
}
private static string MakeNewPath(string originalPath, string newName)
@@ -165,16 +163,12 @@ private async Task AddEditsForCodeDocumentAsync(
IDocumentSnapshot documentSnapshot,
CancellationToken cancellationToken)
{
- if (!FileKinds.IsComponent(documentSnapshot.FileKind))
+ if (!documentSnapshot.FileKind.IsComponent())
{
return;
}
var codeDocument = await documentSnapshot.GetGeneratedOutputAsync(cancellationToken).ConfigureAwait(false);
- if (codeDocument.IsUnsupported())
- {
- return;
- }
// VS Code in Windows expects path to start with '/'
var uri = BuildUri(documentSnapshot.FilePath);
@@ -226,13 +220,13 @@ private static void AddEditsForCodeDocument(
}
}
- private static TextEdit[] CreateEditsForMarkupTagHelperElement(MarkupTagHelperElementSyntax element, RazorCodeDocument codeDocument, string newName)
+ private static SumType[] CreateEditsForMarkupTagHelperElement(MarkupTagHelperElementSyntax element, RazorCodeDocument codeDocument, string newName)
{
- var startTagEdit = VsLspFactory.CreateTextEdit(element.StartTag.Name.GetRange(codeDocument.Source), newName);
+ var startTagEdit = LspFactory.CreateTextEdit(element.StartTag.Name.GetRange(codeDocument.Source), newName);
if (element.EndTag is MarkupTagHelperEndTagSyntax endTag)
{
- var endTagEdit = VsLspFactory.CreateTextEdit(endTag.Name.GetRange(codeDocument.Source), newName);
+ var endTagEdit = LspFactory.CreateTextEdit(endTag.Name.GetRange(codeDocument.Source), newName);
return [startTagEdit, endTagEdit];
}
@@ -295,7 +289,7 @@ private static bool TryGetTagHelperBinding(RazorSyntaxNode owner, int absoluteIn
// Ensure the rename action was invoked on the component name instead of a component parameter. This serves as an issue
// mitigation till `textDocument/prepareRename` is supported and we can ensure renames aren't triggered in unsupported
// contexts. (https://github.com/dotnet/razor/issues/4285)
- if (!tagHelperStartTag.Name.FullSpan.IntersectsWith(absoluteIndex))
+ if (!tagHelperStartTag.Name.Span.IntersectsWith(absoluteIndex))
{
binding = null;
return false;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.cs.xlf b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.cs.xlf
index 8230976e64a..adc26227836 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.cs.xlf
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.cs.xlf
@@ -136,22 +136,22 @@
Unsupported Razor extension: '{0}'.
- Unsupported Razor extension: '{0}'.
+ Nepodporované rozšíření Razor: {0}.
Unsupported argument kind: '{0}'.
- Unsupported argument kind: '{0}'.
+ Nepodporovaný druh argumentu: {0}.
Unsupported argument type: '{0}'.
- Unsupported argument type: '{0}'.
+ Nepodporovaný typ argumentu: {0}.
Unsupported razor project info version encounted.
- Unsupported razor project info version encounted.
+ Byla započítána nepodporovaná verze informací o projektu Razor.
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.de.xlf b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.de.xlf
index 6acf0573fa2..e81caa55514 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.de.xlf
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.de.xlf
@@ -136,22 +136,22 @@
Unsupported Razor extension: '{0}'.
- Unsupported Razor extension: '{0}'.
+ Nicht unterstützte Razor-Erweiterung: „{0}“.
Unsupported argument kind: '{0}'.
- Unsupported argument kind: '{0}'.
+ Nicht unterstützte Argumentart: "{0}".
Unsupported argument type: '{0}'.
- Unsupported argument type: '{0}'.
+ Nicht unterstützter Argumenttyp: "{0}".
Unsupported razor project info version encounted.
- Unsupported razor project info version encounted.
+ Nicht unterstützte Razor-Projektinformationen werden gezählt.
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.es.xlf b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.es.xlf
index 57367bbae63..1f122ad7355 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.es.xlf
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.es.xlf
@@ -136,22 +136,22 @@
Unsupported Razor extension: '{0}'.
- Unsupported Razor extension: '{0}'.
+ Extensión Razor no admitida: '{0}'.
Unsupported argument kind: '{0}'.
- Unsupported argument kind: '{0}'.
+ Variante de argumento no admitida: ''{0}''.
Unsupported argument type: '{0}'.
- Unsupported argument type: '{0}'.
+ Tipo de argumento no admitido: ''{0}''.
Unsupported razor project info version encounted.
- Unsupported razor project info version encounted.
+ Se ha encontrado una versión de información de proyecto de Razor no admitida.
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.fr.xlf b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.fr.xlf
index 7d0b7273d14..0971a4344fd 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.fr.xlf
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.fr.xlf
@@ -136,22 +136,22 @@
Unsupported Razor extension: '{0}'.
- Unsupported Razor extension: '{0}'.
+ Extension Razor non prise en charge : « {0} ».
Unsupported argument kind: '{0}'.
- Unsupported argument kind: '{0}'.
+ Genre d’argument non pris en charge : « {0} ».
Unsupported argument type: '{0}'.
- Unsupported argument type: '{0}'.
+ Type d’argument non pris en charge : « {0} ».
Unsupported razor project info version encounted.
- Unsupported razor project info version encounted.
+ Version des informations de projet Razor non prise en charge.
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.it.xlf b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.it.xlf
index 29fb9dc57bb..a06ac238ca0 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.it.xlf
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.it.xlf
@@ -136,22 +136,22 @@
Unsupported Razor extension: '{0}'.
- Unsupported Razor extension: '{0}'.
+ Estensione Razor non supportata: '{0}'.
Unsupported argument kind: '{0}'.
- Unsupported argument kind: '{0}'.
+ Genere di argomento non supportato: '{0}'.
Unsupported argument type: '{0}'.
- Unsupported argument type: '{0}'.
+ Tipo di argomento non supportato: '{0}'.
Unsupported razor project info version encounted.
- Unsupported razor project info version encounted.
+ Incontrata versione delle informazioni sul progetto Razor non supportata.
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.ja.xlf b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.ja.xlf
index 00656ea8d2f..26f480da60b 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.ja.xlf
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.ja.xlf
@@ -136,22 +136,22 @@
Unsupported Razor extension: '{0}'.
- Unsupported Razor extension: '{0}'.
+ サポートされていない Razor 拡張機能: '{0}'。
Unsupported argument kind: '{0}'.
- Unsupported argument kind: '{0}'.
+ サポートされていない引数の種類: '{0}'。
Unsupported argument type: '{0}'.
- Unsupported argument type: '{0}'.
+ サポートされていない引数の型: '{0}'。
Unsupported razor project info version encounted.
- Unsupported razor project info version encounted.
+ サポートされていない Razor プロジェクト情報バージョンを検出しました。
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.ko.xlf b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.ko.xlf
index 5ba1c067127..e29e6acd3bd 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.ko.xlf
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.ko.xlf
@@ -136,22 +136,22 @@
Unsupported Razor extension: '{0}'.
- Unsupported Razor extension: '{0}'.
+ 지원되지 않는 Razor 확장: '{0}'.
Unsupported argument kind: '{0}'.
- Unsupported argument kind: '{0}'.
+ 지원되지 않는 인수 종류: '{0}'.
Unsupported argument type: '{0}'.
- Unsupported argument type: '{0}'.
+ 지원되지 않는 인수 유형: '{0}'.
Unsupported razor project info version encounted.
- Unsupported razor project info version encounted.
+ 지원되지 않는 Razor 프로젝트 정보 버전이 발견되었습니다.
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.pl.xlf b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.pl.xlf
index 5b31a239beb..8ac0ae41f62 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.pl.xlf
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.pl.xlf
@@ -136,22 +136,22 @@
Unsupported Razor extension: '{0}'.
- Unsupported Razor extension: '{0}'.
+ Nieobsługiwane rozszerzenie Razor: „{0}”.
Unsupported argument kind: '{0}'.
- Unsupported argument kind: '{0}'.
+ Nieobsługiwany rodzaj argumentu: „{0}”.
Unsupported argument type: '{0}'.
- Unsupported argument type: '{0}'.
+ Nieobsługiwany typ argumentu: „{0}”.
Unsupported razor project info version encounted.
- Unsupported razor project info version encounted.
+ Napotkano nieobsługiwaną wersję informacji o projekcie Razor.
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.pt-BR.xlf b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.pt-BR.xlf
index c5f4ca4b226..250102fc9b8 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.pt-BR.xlf
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.pt-BR.xlf
@@ -136,22 +136,22 @@
Unsupported Razor extension: '{0}'.
- Unsupported Razor extension: '{0}'.
+ Extensão Razor sem suporte: '{0}'.
Unsupported argument kind: '{0}'.
- Unsupported argument kind: '{0}'.
+ Tipo de argumento sem suporte: '{0}'.
Unsupported argument type: '{0}'.
- Unsupported argument type: '{0}'.
+ Tipo de argumento sem suporte: '{0}'.
Unsupported razor project info version encounted.
- Unsupported razor project info version encounted.
+ Foi encontrada uma versão de informações do projeto Razor sem suporte.
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.ru.xlf b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.ru.xlf
index 1aba54a459e..a4d2418b483 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.ru.xlf
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.ru.xlf
@@ -136,22 +136,22 @@
Unsupported Razor extension: '{0}'.
- Unsupported Razor extension: '{0}'.
+ Неподдерживаемое расширение Razor: "{0}".
Unsupported argument kind: '{0}'.
- Unsupported argument kind: '{0}'.
+ Неподдерживаемый вид аргумента: "{0}".
Unsupported argument type: '{0}'.
- Unsupported argument type: '{0}'.
+ Неподдерживаемый тип аргумента: "{0}".
Unsupported razor project info version encounted.
- Unsupported razor project info version encounted.
+ Неподдерживаемая версия сведений о проекте Razor
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.tr.xlf b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.tr.xlf
index 682f4fba0ac..ca6d55c9a37 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.tr.xlf
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.tr.xlf
@@ -136,22 +136,22 @@
Unsupported Razor extension: '{0}'.
- Unsupported Razor extension: '{0}'.
+ Desteklenmeyen Razor uzantısı: '{0}'.
Unsupported argument kind: '{0}'.
- Unsupported argument kind: '{0}'.
+ Desteklenmeyen bağımsız değişken tipi: '{0}'.
Unsupported argument type: '{0}'.
- Unsupported argument type: '{0}'.
+ Desteklenmeyen bağımsız değişken türü: '{0}'.
Unsupported razor project info version encounted.
- Unsupported razor project info version encounted.
+ Desteklenmeyen razor proje bilgileri sürümüyle karşılaşıldı.
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.zh-Hans.xlf b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.zh-Hans.xlf
index 4bc9b40a208..966f449d33c 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.zh-Hans.xlf
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.zh-Hans.xlf
@@ -136,22 +136,22 @@
Unsupported Razor extension: '{0}'.
- Unsupported Razor extension: '{0}'.
+ 不支持的 Razor 扩展:“{0}”。
Unsupported argument kind: '{0}'.
- Unsupported argument kind: '{0}'.
+ 不支持的参数类型: "{0}"。
Unsupported argument type: '{0}'.
- Unsupported argument type: '{0}'.
+ 不支持的参数类型: "{0}"。
Unsupported razor project info version encounted.
- Unsupported razor project info version encounted.
+ razor 项目信息版本计数不受支持。
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.zh-Hant.xlf b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.zh-Hant.xlf
index a3d930f6dd6..2ab6a430f3e 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.zh-Hant.xlf
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Resources/xlf/SR.zh-Hant.xlf
@@ -136,22 +136,22 @@
Unsupported Razor extension: '{0}'.
- Unsupported Razor extension: '{0}'.
+ 不支援的 Razor 延伸模組: '{0}'。
Unsupported argument kind: '{0}'.
- Unsupported argument kind: '{0}'.
+ 不支援的引數種類: '{0}'。
Unsupported argument type: '{0}'.
- Unsupported argument type: '{0}'.
+ 不支援的引數類型: '{0}'。
Unsupported razor project info version encounted.
- Unsupported razor project info version encounted.
+ 不支援的 razor 專案資訊版本已列舉。
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/DocumentSnapshotHandle.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/DocumentSnapshotHandle.cs
index 9b4bafb1f27..87e7ecbd4cb 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/DocumentSnapshotHandle.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/DocumentSnapshotHandle.cs
@@ -1,6 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
-namespace Microsoft.AspNetCore.Razor.Serialization;
+using Microsoft.AspNetCore.Razor.Language;
-internal record DocumentSnapshotHandle(string FilePath, string TargetPath, string FileKind);
+namespace Microsoft.CodeAnalysis.Razor.Serialization;
+
+internal record DocumentSnapshotHandle(string FilePath, string TargetPath, RazorFileKind FileKind);
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/FetchTagHelpersResult.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/FetchTagHelpersResult.cs
index fb2429947fa..ab95fb67f90 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/FetchTagHelpersResult.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/FetchTagHelpersResult.cs
@@ -4,7 +4,7 @@
using System.Collections.Immutable;
using Microsoft.AspNetCore.Razor.Language;
-namespace Microsoft.AspNetCore.Razor.Serialization;
+namespace Microsoft.CodeAnalysis.Razor.Serialization;
internal sealed record FetchTagHelpersResult(ImmutableArray TagHelpers)
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/ArgKind.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/ArgKind.cs
index a54bd88567c..31e58ca1f50 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/ArgKind.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/ArgKind.cs
@@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack;
internal enum ArgKind
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/DocumentationKind.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/DocumentationKind.cs
index d6ca105fb83..8e758ffbdbf 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/DocumentationKind.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/DocumentationKind.cs
@@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack;
internal enum DocumentationKind
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/CachedStringFormatter.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/CachedStringFormatter.cs
index 243c31af545..c1c369f8b08 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/CachedStringFormatter.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/CachedStringFormatter.cs
@@ -3,7 +3,7 @@
using MessagePack;
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters;
internal sealed class CachedStringFormatter : ValueFormatter
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/ChecksumFormatter.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/ChecksumFormatter.cs
index 7e1cd220e70..a9f1324b642 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/ChecksumFormatter.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/ChecksumFormatter.cs
@@ -4,7 +4,7 @@
using MessagePack;
using Microsoft.AspNetCore.Razor.Utilities;
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters;
internal sealed class ChecksumFormatter : NonCachingFormatter
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/DocumentSnapshotFormatter.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/DocumentSnapshotFormatter.cs
index 6cf7401e9df..275f5444b2f 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/DocumentSnapshotFormatter.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/DocumentSnapshotFormatter.cs
@@ -2,8 +2,10 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using MessagePack;
+using Microsoft.AspNetCore.Razor;
+using Microsoft.AspNetCore.Razor.Language;
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters;
internal sealed class DocumentSnapshotHandleFormatter : ValueFormatter
{
@@ -19,7 +21,7 @@ public override DocumentSnapshotHandle Deserialize(ref MessagePackReader reader,
var filePath = CachedStringFormatter.Instance.Deserialize(ref reader, options).AssumeNotNull();
var targetPath = CachedStringFormatter.Instance.Deserialize(ref reader, options).AssumeNotNull();
- var fileKind = CachedStringFormatter.Instance.Deserialize(ref reader, options).AssumeNotNull();
+ var fileKind = (RazorFileKind)reader.ReadByte();
return new DocumentSnapshotHandle(filePath, targetPath, fileKind);
}
@@ -30,6 +32,6 @@ public override void Serialize(ref MessagePackWriter writer, DocumentSnapshotHan
CachedStringFormatter.Instance.Serialize(ref writer, value.FilePath, options);
CachedStringFormatter.Instance.Serialize(ref writer, value.TargetPath, options);
- CachedStringFormatter.Instance.Serialize(ref writer, value.FileKind, options);
+ writer.Write((byte)value.FileKind);
}
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/Extensions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/Extensions.cs
index 44b41db9183..af3a6a828ea 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/Extensions.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/Extensions.cs
@@ -3,7 +3,7 @@
using MessagePack;
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters;
internal static class Extensions
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/FetchTagHelpersResultFormatter.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/FetchTagHelpersResultFormatter.cs
index aa41f45a054..4dd330f8f24 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/FetchTagHelpersResultFormatter.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/FetchTagHelpersResultFormatter.cs
@@ -5,7 +5,7 @@
using MessagePack;
using Microsoft.AspNetCore.Razor.Language;
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters;
internal sealed class FetchTagHelpersResultFormatter : TopLevelFormatter
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/NonCachingFormatter.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/NonCachingFormatter.cs
index 8615c3403ae..3f18f835d71 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/NonCachingFormatter.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/NonCachingFormatter.cs
@@ -5,7 +5,7 @@
using MessagePack;
using MessagePack.Formatters;
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters;
internal abstract partial class NonCachingFormatter : IMessagePackFormatter
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/ProjectSnapshotHandleFormatter.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/ProjectSnapshotHandleFormatter.cs
index 52763e77807..9c058f7592d 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/ProjectSnapshotHandleFormatter.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/ProjectSnapshotHandleFormatter.cs
@@ -4,9 +4,8 @@
using MessagePack;
using MessagePack.Formatters;
using Microsoft.AspNetCore.Razor.Language;
-using Microsoft.CodeAnalysis;
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters;
internal sealed class ProjectSnapshotHandleFormatter : TopLevelFormatter
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/ProjectWorkspaceStateFormatter.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/ProjectWorkspaceStateFormatter.cs
index 156c443958e..3a69251b662 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/ProjectWorkspaceStateFormatter.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/ProjectWorkspaceStateFormatter.cs
@@ -5,11 +5,12 @@
using MessagePack;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.PooledObjects;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
-using Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters.TagHelpers;
using Microsoft.AspNetCore.Razor.Utilities;
+using Microsoft.CodeAnalysis.Razor.ProjectSystem;
+using Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters.TagHelpers;
+using Microsoft.CodeAnalysis.Razor.Utilities;
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters;
internal sealed class ProjectWorkspaceStateFormatter : ValueFormatter
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/RazorConfigurationFormatter.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/RazorConfigurationFormatter.cs
index 211dc350e79..05e82b9a163 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/RazorConfigurationFormatter.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/RazorConfigurationFormatter.cs
@@ -3,11 +3,12 @@
using System.Collections.Immutable;
using MessagePack;
+using Microsoft.AspNetCore.Razor;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.PooledObjects;
using Microsoft.CodeAnalysis.CSharp;
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters;
internal sealed class RazorConfigurationFormatter : ValueFormatter
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/RazorDiagnosticFormatter.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/RazorDiagnosticFormatter.cs
index 6bd2a2a0b71..e63866a46cc 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/RazorDiagnosticFormatter.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/RazorDiagnosticFormatter.cs
@@ -3,9 +3,10 @@
using System.Globalization;
using MessagePack;
+using Microsoft.AspNetCore.Razor;
using Microsoft.AspNetCore.Razor.Language;
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters;
internal sealed class RazorDiagnosticFormatter : ValueFormatter
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/RazorProjectInfoFormatter.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/RazorProjectInfoFormatter.cs
index 6cafb011c69..c1952d09a11 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/RazorProjectInfoFormatter.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/RazorProjectInfoFormatter.cs
@@ -3,10 +3,11 @@
using System.Collections.Immutable;
using MessagePack;
+using Microsoft.AspNetCore.Razor;
using Microsoft.AspNetCore.Razor.Language;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
+using Microsoft.CodeAnalysis.Razor.ProjectSystem;
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters;
internal sealed class RazorProjectInfoFormatter : TopLevelFormatter
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/SerializerCachingOptions.ReferenceMap`1.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/SerializerCachingOptions.ReferenceMap`1.cs
index 4e7073428ac..ff733006588 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/SerializerCachingOptions.ReferenceMap`1.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/SerializerCachingOptions.ReferenceMap`1.cs
@@ -6,7 +6,7 @@
using Microsoft.AspNetCore.Razor.PooledObjects;
using Microsoft.Extensions.ObjectPool;
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters;
internal partial class SerializerCachingOptions
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/SerializerCachingOptions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/SerializerCachingOptions.cs
index 89ba51917cb..df01ef45efa 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/SerializerCachingOptions.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/SerializerCachingOptions.cs
@@ -8,7 +8,7 @@
using Microsoft.AspNetCore.Razor.PooledObjects;
using Microsoft.Extensions.ObjectPool;
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters;
internal partial class SerializerCachingOptions(MessagePackSerializerOptions copyFrom) : MessagePackSerializerOptions(copyFrom), IDisposable
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelperDeltaResultFormatter.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelperDeltaResultFormatter.cs
index a6bd0df1684..f01799245e2 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelperDeltaResultFormatter.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelperDeltaResultFormatter.cs
@@ -5,7 +5,7 @@
using MessagePack;
using Microsoft.AspNetCore.Razor.Utilities;
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters;
internal sealed class TagHelperDeltaResultFormatter : TopLevelFormatter
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/AllowChildTagFormatter.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/AllowChildTagFormatter.cs
index 3673151a2af..e5c4df4ad71 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/AllowChildTagFormatter.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/AllowChildTagFormatter.cs
@@ -3,9 +3,10 @@
using System.Collections.Immutable;
using MessagePack;
+using Microsoft.AspNetCore.Razor;
using Microsoft.AspNetCore.Razor.Language;
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters.TagHelpers;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters.TagHelpers;
internal sealed class AllowedChildTagFormatter : ValueFormatter
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/BoundAttributeFormatter.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/BoundAttributeFormatter.cs
index 2c1b574fa3c..aca548001dd 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/BoundAttributeFormatter.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/BoundAttributeFormatter.cs
@@ -3,9 +3,10 @@
using System.Collections.Immutable;
using MessagePack;
+using Microsoft.AspNetCore.Razor;
using Microsoft.AspNetCore.Razor.Language;
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters.TagHelpers;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters.TagHelpers;
internal sealed class BoundAttributeFormatter : ValueFormatter
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/BoundAttributeParameterFormatter.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/BoundAttributeParameterFormatter.cs
index 396c68f1cb9..fca63974b20 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/BoundAttributeParameterFormatter.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/BoundAttributeParameterFormatter.cs
@@ -3,9 +3,10 @@
using System.Collections.Immutable;
using MessagePack;
+using Microsoft.AspNetCore.Razor;
using Microsoft.AspNetCore.Razor.Language;
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters.TagHelpers;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters.TagHelpers;
internal sealed class BoundAttributeParameterFormatter : ValueFormatter
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/DocumentationObjectFormatter.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/DocumentationObjectFormatter.cs
index 0eb3d47e9d6..9fc58133a69 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/DocumentationObjectFormatter.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/DocumentationObjectFormatter.cs
@@ -5,10 +5,11 @@
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using MessagePack;
+using Microsoft.AspNetCore.Razor;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.PooledObjects;
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters.TagHelpers;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters.TagHelpers;
internal sealed class DocumentationObjectFormatter : ValueFormatter
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/MetadataCollectionFormatter.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/MetadataCollectionFormatter.cs
index 122ed466178..ce68385ae4c 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/MetadataCollectionFormatter.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/MetadataCollectionFormatter.cs
@@ -2,13 +2,14 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using MessagePack;
+using Microsoft.AspNetCore.Razor;
using Microsoft.AspNetCore.Razor.Language;
#if !NET
using System.Collections.Generic;
#endif
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters.TagHelpers;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters.TagHelpers;
internal sealed class MetadataCollectionFormatter : ValueFormatter
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/RequiredAttributeFormatter.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/RequiredAttributeFormatter.cs
index a4f1c41dc35..59c52b8e88f 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/RequiredAttributeFormatter.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/RequiredAttributeFormatter.cs
@@ -3,10 +3,11 @@
using System.Collections.Immutable;
using MessagePack;
+using Microsoft.AspNetCore.Razor;
using Microsoft.AspNetCore.Razor.Language;
using static Microsoft.AspNetCore.Razor.Language.RequiredAttributeDescriptor;
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters.TagHelpers;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters.TagHelpers;
internal sealed class RequiredAttributeFormatter : ValueFormatter
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/TagHelperFormatter.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/TagHelperFormatter.cs
index 4191c4ab04d..eb3905398dd 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/TagHelperFormatter.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/TagHelperFormatter.cs
@@ -3,9 +3,10 @@
using System.Collections.Immutable;
using MessagePack;
+using Microsoft.AspNetCore.Razor;
using Microsoft.AspNetCore.Razor.Language;
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters.TagHelpers;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters.TagHelpers;
internal sealed class TagHelperFormatter : ValueFormatter
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/TagMatchingRuleFormatter.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/TagMatchingRuleFormatter.cs
index 37276cddb01..9309af46ced 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/TagMatchingRuleFormatter.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TagHelpers/TagMatchingRuleFormatter.cs
@@ -3,9 +3,10 @@
using System.Collections.Immutable;
using MessagePack;
+using Microsoft.AspNetCore.Razor;
using Microsoft.AspNetCore.Razor.Language;
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters.TagHelpers;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters.TagHelpers;
internal sealed class TagMatchingRuleFormatter : ValueFormatter
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TopLevelFormatter`1.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TopLevelFormatter`1.cs
index 93dd18a71d2..df351a41590 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TopLevelFormatter`1.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/TopLevelFormatter`1.cs
@@ -5,7 +5,7 @@
using MessagePack;
using MessagePack.Formatters;
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters;
///
/// A message pack formatter that can be serialized at the top-level.
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/ValueFormatter`1.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/ValueFormatter`1.cs
index f9b86708b2c..fe96c6b3ed5 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/ValueFormatter`1.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Formatters/ValueFormatter`1.cs
@@ -6,7 +6,7 @@
using MessagePack;
using MessagePack.Formatters;
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters;
///
/// A message package formatter that cannot be serialized at the top-level. It expects a
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Resolvers/ChecksumResolver.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Resolvers/ChecksumResolver.cs
index 6eeff228aeb..09289a2d43a 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Resolvers/ChecksumResolver.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Resolvers/ChecksumResolver.cs
@@ -3,10 +3,10 @@
using MessagePack;
using MessagePack.Formatters;
-using Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
using Microsoft.AspNetCore.Razor.Utilities;
+using Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters;
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Resolvers;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Resolvers;
internal sealed class ChecksumResolver : IFormatterResolver
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Resolvers/Extensions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Resolvers/Extensions.cs
index d0a10a2774a..0a0a5d8efb4 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Resolvers/Extensions.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Resolvers/Extensions.cs
@@ -3,9 +3,9 @@
using System;
using System.Collections.Generic;
-using Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
+using Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters;
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Resolvers;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Resolvers;
internal static class Extensions
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Resolvers/FetchTagHelpersResultResolver.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Resolvers/FetchTagHelpersResultResolver.cs
index 3eec0f3d74a..fb489d20ce5 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Resolvers/FetchTagHelpersResultResolver.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Resolvers/FetchTagHelpersResultResolver.cs
@@ -5,10 +5,10 @@
using System.Collections.Generic;
using MessagePack;
using MessagePack.Formatters;
-using Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
-using Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters.TagHelpers;
+using Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters;
+using Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters.TagHelpers;
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Resolvers;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Resolvers;
internal sealed class FetchTagHelpersResultResolver : IFormatterResolver
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Resolvers/ProjectSnapshotHandleResolver.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Resolvers/ProjectSnapshotHandleResolver.cs
index 06ab5169141..f99bee14f04 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Resolvers/ProjectSnapshotHandleResolver.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Resolvers/ProjectSnapshotHandleResolver.cs
@@ -5,9 +5,9 @@
using System.Collections.Generic;
using MessagePack;
using MessagePack.Formatters;
-using Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
+using Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters;
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Resolvers;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Resolvers;
internal sealed class ProjectSnapshotHandleResolver : IFormatterResolver
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Resolvers/RazorProjectInfoResolver.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Resolvers/RazorProjectInfoResolver.cs
index 5eff22396b9..fb764bb8fe3 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Resolvers/RazorProjectInfoResolver.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Resolvers/RazorProjectInfoResolver.cs
@@ -5,10 +5,10 @@
using System.Collections.Generic;
using MessagePack;
using MessagePack.Formatters;
-using Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
-using Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters.TagHelpers;
+using Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters;
+using Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters.TagHelpers;
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Resolvers;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Resolvers;
internal sealed class RazorProjectInfoResolver : IFormatterResolver
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Resolvers/TagHelperDeltaResultResolver.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Resolvers/TagHelperDeltaResultResolver.cs
index bb42f23c2ff..36e985eceda 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Resolvers/TagHelperDeltaResultResolver.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Resolvers/TagHelperDeltaResultResolver.cs
@@ -5,9 +5,9 @@
using System.Collections.Generic;
using MessagePack;
using MessagePack.Formatters;
-using Microsoft.AspNetCore.Razor.Serialization.MessagePack.Formatters;
+using Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Formatters;
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Resolvers;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Resolvers;
internal sealed class TagHelperDeltaResultResolver : IFormatterResolver
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Resolvers/TopLevelResolvers.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Resolvers/TopLevelResolvers.cs
index eff4e3d4d30..2dfadadf8b9 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Resolvers/TopLevelResolvers.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/Resolvers/TopLevelResolvers.cs
@@ -4,7 +4,7 @@
using System.Collections.Immutable;
using MessagePack;
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack.Resolvers;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack.Resolvers;
internal static class TopLevelResolvers
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/SerializationFormat.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/SerializationFormat.cs
index bb7d6524f7b..8502239657e 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/SerializationFormat.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/MessagePack/SerializationFormat.cs
@@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
-namespace Microsoft.AspNetCore.Razor.Serialization.MessagePack;
+namespace Microsoft.CodeAnalysis.Razor.Serialization.MessagePack;
internal static class SerializationFormat
{
@@ -9,5 +9,5 @@ internal static class SerializationFormat
// or any of the types that compose it changes. This includes: RazorConfiguration,
// ProjectWorkspaceState, TagHelperDescriptor, and DocumentSnapshotHandle.
// NOTE: If this version is changed, a coordinated insertion is required between Roslyn and Razor for the C# extension.
- public const int Version = 7;
+ public const int Version = 8;
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/ProjectSnapshotHandle.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/ProjectSnapshotHandle.cs
index cf8de7e3bc9..ed6c79aa8ec 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/ProjectSnapshotHandle.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/ProjectSnapshotHandle.cs
@@ -3,9 +3,8 @@
using System;
using Microsoft.AspNetCore.Razor.Language;
-using Microsoft.CodeAnalysis;
-namespace Microsoft.AspNetCore.Razor.Serialization;
+namespace Microsoft.CodeAnalysis.Razor.Serialization;
internal record ProjectSnapshotHandle
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/RazorProjectInfoSerializationException.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/RazorProjectInfoSerializationException.cs
index 44496b2162b..d9ad1360628 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/RazorProjectInfoSerializationException.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/RazorProjectInfoSerializationException.cs
@@ -3,7 +3,7 @@
using System;
-namespace Microsoft.AspNetCore.Razor.Serialization;
+namespace Microsoft.CodeAnalysis.Razor.Serialization;
internal class RazorProjectInfoSerializationException(string? message) : Exception(message)
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/TagHelperDeltaResult.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/TagHelperDeltaResult.cs
index fa3d92045fe..48553a95a0c 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/TagHelperDeltaResult.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Serialization/TagHelperDeltaResult.cs
@@ -6,12 +6,13 @@
using Microsoft.AspNetCore.Razor.PooledObjects;
using Microsoft.AspNetCore.Razor.Utilities;
using Microsoft.Extensions.Internal;
+using Microsoft.AspNetCore.Razor;
#if DEBUG
using System.Diagnostics;
#endif
-namespace Microsoft.AspNetCore.Razor.Serialization;
+namespace Microsoft.CodeAnalysis.Razor.Serialization;
internal sealed record TagHelperDeltaResult(
bool IsDelta,
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/SpellCheck/SpellCheckService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/SpellCheck/SpellCheckService.cs
index 0ab6c5ac690..34a1d02b765 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/SpellCheck/SpellCheckService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/SpellCheck/SpellCheckService.cs
@@ -9,7 +9,6 @@
using Microsoft.AspNetCore.Razor.PooledObjects;
using Microsoft.CodeAnalysis.Razor.DocumentMapping;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.SpellCheck;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/ITelemetryReporter.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/ITelemetryReporter.cs
index cfd87d36b2d..948c7441359 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/ITelemetryReporter.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/ITelemetryReporter.cs
@@ -3,7 +3,7 @@
using System;
-namespace Microsoft.AspNetCore.Razor.Telemetry;
+namespace Microsoft.CodeAnalysis.Razor.Telemetry;
internal interface ITelemetryReporter
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/ITelemetryReporterExtensions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/ITelemetryReporterExtensions.cs
index fb21f9c2328..a12358f7926 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/ITelemetryReporterExtensions.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/ITelemetryReporterExtensions.cs
@@ -3,7 +3,7 @@
using System;
-namespace Microsoft.AspNetCore.Razor.Telemetry;
+namespace Microsoft.CodeAnalysis.Razor.Telemetry;
internal static class ITelemetryReporterExtensions
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/ITelemetryReporterInitializer.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/ITelemetryReporterInitializer.cs
index bce5e6bf77b..f4ce6a02262 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/ITelemetryReporterInitializer.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/ITelemetryReporterInitializer.cs
@@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
-namespace Microsoft.AspNetCore.Razor.Telemetry;
+namespace Microsoft.CodeAnalysis.Razor.Telemetry;
internal interface ITelemetryReporterInitializer
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/NoOpTelemetryReporter.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/NoOpTelemetryReporter.cs
index eca3dedebbb..a4aa2e385e0 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/NoOpTelemetryReporter.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/NoOpTelemetryReporter.cs
@@ -3,9 +3,9 @@
using System;
-namespace Microsoft.AspNetCore.Razor.Telemetry;
+namespace Microsoft.CodeAnalysis.Razor.Telemetry;
-internal class NoOpTelemetryReporter : ITelemetryReporter
+internal sealed class NoOpTelemetryReporter : ITelemetryReporter
{
public static readonly NoOpTelemetryReporter Instance = new();
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/Property.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/Property.cs
index 152858edc08..841ef81ad36 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/Property.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/Property.cs
@@ -1,6 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
-namespace Microsoft.AspNetCore.Razor.Telemetry;
+namespace Microsoft.CodeAnalysis.Razor.Telemetry;
internal readonly record struct Property(string Name, object? Value);
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/Severity.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/Severity.cs
index 6eb118f8383..5c6b5c57762 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/Severity.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/Severity.cs
@@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
-namespace Microsoft.AspNetCore.Razor.Telemetry;
+namespace Microsoft.CodeAnalysis.Razor.Telemetry;
internal enum Severity
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/TelemetryResult.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/TelemetryResult.cs
index 4e642467f80..6f10d7af582 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/TelemetryResult.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/TelemetryResult.cs
@@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
-namespace Microsoft.AspNetCore.Razor.Telemetry;
+namespace Microsoft.CodeAnalysis.Razor.Telemetry;
internal enum TelemetryResult
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/TelemetryScope.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/TelemetryScope.cs
index ae5f4537575..2d49416f2dd 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/TelemetryScope.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/TelemetryScope.cs
@@ -5,7 +5,7 @@
using System.Diagnostics;
using Microsoft.AspNetCore.Razor.PooledObjects;
-namespace Microsoft.AspNetCore.Razor.Telemetry;
+namespace Microsoft.CodeAnalysis.Razor.Telemetry;
internal sealed class TelemetryScope : IDisposable
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/TelemetryThresholds.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/TelemetryThresholds.cs
index 636dc392c83..c4a06c07fba 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/TelemetryThresholds.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Telemetry/TelemetryThresholds.cs
@@ -3,7 +3,7 @@
using System;
-namespace Microsoft.CodeAnalysis.Razor.Workspaces.Telemetry;
+namespace Microsoft.CodeAnalysis.Razor.Telemetry;
///
/// A set of constants used to reduce the telemetry emitted to the set that help us understand
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/DiffKind.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/DiffKind.cs
index d68974149fb..55e0efca90c 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/DiffKind.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/DiffKind.cs
@@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
-namespace Microsoft.AspNetCore.Razor.TextDifferencing;
+namespace Microsoft.CodeAnalysis.Razor.TextDifferencing;
internal enum DiffKind : byte
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/SourceTextDiffer.CharDiffer.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/SourceTextDiffer.CharDiffer.cs
index 2a19c7a313c..3939e1ebb1a 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/SourceTextDiffer.CharDiffer.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/SourceTextDiffer.CharDiffer.cs
@@ -7,7 +7,7 @@
using System.Text;
using Microsoft.CodeAnalysis.Text;
-namespace Microsoft.AspNetCore.Razor.TextDifferencing;
+namespace Microsoft.CodeAnalysis.Razor.TextDifferencing;
internal partial class SourceTextDiffer
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/SourceTextDiffer.LineDiffer.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/SourceTextDiffer.LineDiffer.cs
index b9f0502ef88..ece81b9818c 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/SourceTextDiffer.LineDiffer.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/SourceTextDiffer.LineDiffer.cs
@@ -4,7 +4,7 @@
using System.Text;
using Microsoft.CodeAnalysis.Text;
-namespace Microsoft.AspNetCore.Razor.TextDifferencing;
+namespace Microsoft.CodeAnalysis.Razor.TextDifferencing;
internal partial class SourceTextDiffer
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/SourceTextDiffer.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/SourceTextDiffer.cs
index 34d63963afa..2a84400545c 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/SourceTextDiffer.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/SourceTextDiffer.cs
@@ -11,7 +11,7 @@
using Microsoft.AspNetCore.Razor.PooledObjects;
using Microsoft.CodeAnalysis.Text;
-namespace Microsoft.AspNetCore.Razor.TextDifferencing;
+namespace Microsoft.CodeAnalysis.Razor.TextDifferencing;
internal abstract partial class SourceTextDiffer : TextDiffer, IDisposable
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/TextDiffer.DiffEdit.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/TextDiffer.DiffEdit.cs
index 806a1ed2425..568551b9adc 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/TextDiffer.DiffEdit.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/TextDiffer.DiffEdit.cs
@@ -3,7 +3,7 @@
using Microsoft.AspNetCore.Razor.PooledObjects;
-namespace Microsoft.AspNetCore.Razor.TextDifferencing;
+namespace Microsoft.CodeAnalysis.Razor.TextDifferencing;
internal abstract partial class TextDiffer
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/TextDiffer.DiffEditBuilder.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/TextDiffer.DiffEditBuilder.cs
index 1726fdbd9eb..5f805269a89 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/TextDiffer.DiffEditBuilder.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/TextDiffer.DiffEditBuilder.cs
@@ -4,7 +4,7 @@
using System;
using System.Collections.Generic;
-namespace Microsoft.AspNetCore.Razor.TextDifferencing;
+namespace Microsoft.CodeAnalysis.Razor.TextDifferencing;
internal abstract partial class TextDiffer
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/TextDiffer.DiffEditKind.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/TextDiffer.DiffEditKind.cs
index 7d47378d85c..aa07bf06dad 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/TextDiffer.DiffEditKind.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/TextDiffer.DiffEditKind.cs
@@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
-namespace Microsoft.AspNetCore.Razor.TextDifferencing;
+namespace Microsoft.CodeAnalysis.Razor.TextDifferencing;
internal abstract partial class TextDiffer
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/TextDiffer.IntArray.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/TextDiffer.IntArray.cs
index 120685d419f..60b39206eb7 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/TextDiffer.IntArray.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/TextDiffer.IntArray.cs
@@ -5,7 +5,7 @@
using System.Buffers;
using System.Runtime.CompilerServices;
-namespace Microsoft.AspNetCore.Razor.TextDifferencing;
+namespace Microsoft.CodeAnalysis.Razor.TextDifferencing;
internal abstract partial class TextDiffer
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/TextDiffer.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/TextDiffer.cs
index 9dc51c1c326..c18d124bc96 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/TextDiffer.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/TextDiffer.cs
@@ -4,7 +4,7 @@
using System;
using System.Collections.Generic;
-namespace Microsoft.AspNetCore.Razor.TextDifferencing;
+namespace Microsoft.CodeAnalysis.Razor.TextDifferencing;
//
// This class implements the linear space variation of the difference algorithm described in
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Threading/CancellationSeries.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Threading/CancellationSeries.cs
index 3003774fdf0..80d9e941cda 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Threading/CancellationSeries.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Threading/CancellationSeries.cs
@@ -4,7 +4,7 @@
using System;
using System.Threading;
-namespace Microsoft.AspNetCore.Razor.Threading;
+namespace Microsoft.CodeAnalysis.Razor.Threading;
// NOTE: This code is copied from dotnet/roslyn:
// https://github.com/dotnet/roslyn/blob/98cd097bf122677378692ebe952b71ab6e5bb013/src/Workspaces/Core/Portable/Utilities/CancellationSeries.cs
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Threading/SemaphoreSlimExtensions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Threading/SemaphoreSlimExtensions.cs
index 89ff9360f54..f61b97f2fa3 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Threading/SemaphoreSlimExtensions.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Threading/SemaphoreSlimExtensions.cs
@@ -6,7 +6,7 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Utilities;
-namespace Microsoft.AspNetCore.Razor.Threading;
+namespace Microsoft.CodeAnalysis.Razor.Threading;
internal static class SemaphoreSlimExtensions
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Threading/TaskExtensions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Threading/TaskExtensions.cs
index 36038bec832..b66d988bbc5 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Threading/TaskExtensions.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Threading/TaskExtensions.cs
@@ -2,8 +2,9 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Threading.Tasks;
+using Microsoft.AspNetCore.Razor;
-namespace Microsoft.AspNetCore.Razor.Threading;
+namespace Microsoft.CodeAnalysis.Razor.Threading;
internal static class TaskExtensions
{
@@ -20,7 +21,10 @@ public static void VerifyCompleted(this ValueTask task)
Assumed.True(task.IsCompleted);
// Propagate any exceptions that may have been thrown.
+
+#pragma warning disable VSTHRD002 // Avoid problematic synchronous waits
task.GetAwaiter().GetResult();
+#pragma warning restore VSTHRD002 // Avoid problematic synchronous waits
}
///
@@ -36,6 +40,9 @@ public static TResult VerifyCompleted(this ValueTask task)
Assumed.True(task.IsCompleted);
// Propagate any exceptions that may have been thrown.
+
+#pragma warning disable VSTHRD002 // Avoid problematic synchronous waits
return task.GetAwaiter().GetResult();
+#pragma warning restore VSTHRD002 // Avoid problematic synchronous waits
}
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Tooltip/AbstractComponentAvailabilityService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Tooltip/AbstractComponentAvailabilityService.cs
index a754879bdc2..49d910c2888 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Tooltip/AbstractComponentAvailabilityService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Tooltip/AbstractComponentAvailabilityService.cs
@@ -6,7 +6,7 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.PooledObjects;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
+using Microsoft.CodeAnalysis.Razor.ProjectSystem;
namespace Microsoft.CodeAnalysis.Razor.Tooltip;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Tooltip/ClassifiedTagHelperTooltipFactory.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Tooltip/ClassifiedTagHelperTooltipFactory.cs
index b5e4f7440f3..93a4289c9a7 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Tooltip/ClassifiedTagHelperTooltipFactory.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Tooltip/ClassifiedTagHelperTooltipFactory.cs
@@ -12,8 +12,8 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.PooledObjects;
using Microsoft.CodeAnalysis.Classification;
-using Microsoft.VisualStudio.Core.Imaging;
-using Microsoft.VisualStudio.Text.Adornments;
+using Roslyn.Core.Imaging;
+using Roslyn.Text.Adornments;
namespace Microsoft.CodeAnalysis.Razor.Tooltip;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Tooltip/IComponentAvailabilityService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Tooltip/IComponentAvailabilityService.cs
index 3259c4c67ab..048226d4294 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Tooltip/IComponentAvailabilityService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Tooltip/IComponentAvailabilityService.cs
@@ -4,7 +4,7 @@
using System.Collections.Immutable;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
+using Microsoft.CodeAnalysis.Razor.ProjectSystem;
namespace Microsoft.CodeAnalysis.Razor.Tooltip;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Tooltip/MarkupTagHelperTooltipFactory.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Tooltip/MarkupTagHelperTooltipFactory.cs
index 3d9b6ab7ade..805d5e0caaf 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Tooltip/MarkupTagHelperTooltipFactory.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Tooltip/MarkupTagHelperTooltipFactory.cs
@@ -8,7 +8,6 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.PooledObjects;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Razor.Tooltip;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/UriExtensions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/UriExtensions.cs
index b1ae800478f..f2cf6458933 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/UriExtensions.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/UriExtensions.cs
@@ -3,8 +3,8 @@
using System;
using System.Net;
-using Microsoft.AspNetCore.Razor.Utilities;
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
+using Microsoft.CodeAnalysis.Razor.Utilities;
namespace Microsoft.CodeAnalysis.Razor;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/AsyncBatchingWorkQueue.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/AsyncBatchingWorkQueue.cs
index d34eac98049..c4b47b864d5 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/AsyncBatchingWorkQueue.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/AsyncBatchingWorkQueue.cs
@@ -6,8 +6,9 @@
using System.Collections.Immutable;
using System.Threading;
using System.Threading.Tasks;
+using Microsoft.AspNetCore.Razor;
-namespace Microsoft.AspNetCore.Razor.Utilities;
+namespace Microsoft.CodeAnalysis.Razor.Utilities;
// NOTE: This code is copied and modified slightly from dotnet/roslyn:
// https://github.com/dotnet/roslyn/blob/98cd097bf122677378692ebe952b71ab6e5bb013/src/Workspaces/Core/Portable/Shared/Utilities/AsyncBatchingWorkQueue%600.cs
@@ -22,5 +23,5 @@ private static Func, CancellationToken, ValueTask> Co
=> (items, ct) => processBatchAsync(ct);
public void AddWork(bool cancelExistingWork = false)
- => base.AddWork(default(VoidResult), cancelExistingWork);
+ => AddWork(default(VoidResult), cancelExistingWork);
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/AsyncBatchingWorkQueue`1.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/AsyncBatchingWorkQueue`1.cs
index 5d36d279774..1dbdc13fc16 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/AsyncBatchingWorkQueue`1.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/AsyncBatchingWorkQueue`1.cs
@@ -6,8 +6,9 @@
using System.Collections.Immutable;
using System.Threading;
using System.Threading.Tasks;
+using Microsoft.AspNetCore.Razor;
-namespace Microsoft.AspNetCore.Razor.Utilities;
+namespace Microsoft.CodeAnalysis.Razor.Utilities;
// NOTE: This code is copied and modified slightly from dotnet/roslyn:
// https://github.com/dotnet/roslyn/blob/98cd097bf122677378692ebe952b71ab6e5bb013/src/Workspaces/Core/Portable/Shared/Utilities/AsyncBatchingWorkQueue%601.cs
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/AsyncBatchingWorkQueue`2.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/AsyncBatchingWorkQueue`2.cs
index cccdd28d1db..2079cd71c63 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/AsyncBatchingWorkQueue`2.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/AsyncBatchingWorkQueue`2.cs
@@ -6,11 +6,13 @@
using System.Collections.Immutable;
using System.Threading;
using System.Threading.Tasks;
+using Microsoft.AspNetCore.Razor;
using Microsoft.AspNetCore.Razor.PooledObjects;
using Microsoft.AspNetCore.Razor.Threading;
+using Microsoft.CodeAnalysis.Razor.Threading;
using Microsoft.VisualStudio.Threading;
-namespace Microsoft.AspNetCore.Razor.Utilities;
+namespace Microsoft.CodeAnalysis.Razor.Utilities;
// NOTE: This code is derived from dotnet/roslyn:
// https://github.com/dotnet/roslyn/blob/98cd097bf122677378692ebe952b71ab6e5bb013/src/Workspaces/Core/Portable/Shared/Utilities/AsyncBatchingWorkQueue%602.cs
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/FilePathNormalizer.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/FilePathNormalizer.cs
index ec419431db0..d28208ad9a5 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/FilePathNormalizer.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/FilePathNormalizer.cs
@@ -5,10 +5,11 @@
using System.Buffers;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
-using Microsoft.CodeAnalysis.Razor;
+using Microsoft.AspNetCore.Razor;
+using Microsoft.AspNetCore.Razor.Utilities;
using Microsoft.Extensions.Internal;
-namespace Microsoft.AspNetCore.Razor.Utilities;
+namespace Microsoft.CodeAnalysis.Razor.Utilities;
internal static class FilePathNormalizer
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/FilePathNormalizingComparer.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/FilePathNormalizingComparer.cs
index 7bf93173c2a..e7f2d01507a 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/FilePathNormalizingComparer.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/FilePathNormalizingComparer.cs
@@ -3,7 +3,7 @@
using System.Collections.Generic;
-namespace Microsoft.AspNetCore.Razor.Utilities;
+namespace Microsoft.CodeAnalysis.Razor.Utilities;
internal sealed class FilePathNormalizingComparer : IEqualityComparer
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/MemoryCache.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/MemoryCache`2.cs
similarity index 97%
rename from src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/MemoryCache.cs
rename to src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/MemoryCache`2.cs
index edbabdfaca2..21dbfda4149 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/MemoryCache.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/MemoryCache`2.cs
@@ -7,7 +7,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
-namespace Microsoft.AspNetCore.Razor.Utilities;
+namespace Microsoft.CodeAnalysis.Razor.Utilities;
// We've created our own MemoryCache here, ideally we would use the one in Microsoft.Extensions.Caching.Memory,
// but until we update O# that causes an Assembly load problem.
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/ProjectInfoAction.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/RazorProjectInfoAction.cs
similarity index 67%
rename from src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/ProjectInfoAction.cs
rename to src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/RazorProjectInfoAction.cs
index d5faca0a5b9..ae08bb230f0 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/ProjectInfoAction.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/RazorProjectInfoAction.cs
@@ -1,9 +1,9 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
-namespace Microsoft.AspNetCore.Razor.Utilities;
+namespace Microsoft.CodeAnalysis.Razor.Utilities;
-internal enum ProjectInfoAction
+internal enum RazorProjectInfoAction
{
Update,
Remove
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/RazorProjectInfoFactory.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/RazorProjectInfoFactory.cs
index 6f04f75b435..bc872b9f071 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/RazorProjectInfoFactory.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/RazorProjectInfoFactory.cs
@@ -7,16 +7,18 @@
using System.IO;
using System.Threading;
using System.Threading.Tasks;
+using Microsoft.AspNetCore.Razor;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.PooledObjects;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
-using Microsoft.AspNetCore.Razor.Serialization;
-using Microsoft.AspNetCore.Razor.Telemetry;
-using Microsoft.CodeAnalysis;
+using Microsoft.AspNetCore.Razor.Utilities;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Razor.Compiler.CSharp;
+using Microsoft.CodeAnalysis.Razor.ProjectEngineHost;
+using Microsoft.CodeAnalysis.Razor.ProjectSystem;
+using Microsoft.CodeAnalysis.Razor.Serialization;
+using Microsoft.CodeAnalysis.Razor.Telemetry;
-namespace Microsoft.AspNetCore.Razor.Utilities;
+namespace Microsoft.CodeAnalysis.Razor.Utilities;
internal static class RazorProjectInfoFactory
{
@@ -148,7 +150,7 @@ internal static ImmutableArray GetDocuments(Project proj
foreach (var document in project.AdditionalDocuments)
{
if (document.FilePath is { } filePath &&
- TryGetFileKind(filePath, out var kind))
+ FileKinds.TryGetFileKindFromPath(filePath, out var kind))
{
documents.Add(new DocumentSnapshotHandle(filePath, GetTargetPath(filePath, normalizedProjectPath), kind));
}
@@ -163,7 +165,7 @@ internal static ImmutableArray GetDocuments(Project proj
foreach (var document in project.Documents)
{
if (TryGetRazorFileName(document.FilePath, out var razorFilePath) &&
- TryGetFileKind(razorFilePath, out var kind))
+ FileKinds.TryGetFileKindFromPath(razorFilePath, out var kind))
{
documents.Add(new DocumentSnapshotHandle(razorFilePath, GetTargetPath(razorFilePath, normalizedProjectPath), kind));
}
@@ -188,25 +190,6 @@ private static string GetTargetPath(string documentFilePath, string normalizedPr
return normalizedTargetFilePath;
}
- private static bool TryGetFileKind(string filePath, [NotNullWhen(true)] out string? fileKind)
- {
- var extension = Path.GetExtension(filePath);
-
- if (extension.Equals(".cshtml", s_stringComparison))
- {
- fileKind = FileKinds.Legacy;
- return true;
- }
- else if (extension.Equals(".razor", s_stringComparison))
- {
- fileKind = FileKinds.GetComponentFileKindFromFilePath(filePath);
- return true;
- }
-
- fileKind = null;
- return false;
- }
-
private static bool TryGetRazorFileName(string? filePath, [NotNullWhen(true)] out string? razorFilePath)
{
if (filePath is null)
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/StreamExtensions.NetCore.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/StreamExtensions.NetCore.cs
index ebde4991abc..c1c6d837e18 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/StreamExtensions.NetCore.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/StreamExtensions.NetCore.cs
@@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
-using Microsoft.AspNetCore.Razor.ProjectSystem;
using System;
using System.Buffers;
using System.Diagnostics;
@@ -9,8 +8,10 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
+using Microsoft.AspNetCore.Razor;
+using Microsoft.CodeAnalysis.Razor.ProjectSystem;
-namespace Microsoft.AspNetCore.Razor.Utilities;
+namespace Microsoft.CodeAnalysis.Razor.Utilities;
internal static class StreamExtensions
{
@@ -24,7 +25,7 @@ public static Task WriteStringAsync(this Stream stream, string text, Encoding? e
var usedBytes = encoding.GetBytes(text, byteArray);
- WriteSize(stream, usedBytes);
+ stream.WriteSize(usedBytes);
return stream.WriteAsync(byteArray, 0, usedBytes, cancellationToken);
}
@@ -33,7 +34,7 @@ public static async Task ReadStringAsync(this Stream stream, Encoding? e
Debug.Assert(stream.CanRead);
encoding ??= Encoding.UTF8;
- var length = ReadSize(stream);
+ var length = stream.ReadSize();
using var _ = ArrayPool.Shared.GetPooledArray(length, out var encodedBytes);
@@ -41,30 +42,30 @@ public static async Task ReadStringAsync(this Stream stream, Encoding? e
return encoding.GetString(encodedBytes, 0, length);
}
- public static ProjectInfoAction ReadProjectInfoAction(this Stream stream)
+ public static RazorProjectInfoAction ReadProjectInfoAction(this Stream stream)
{
var action = stream.ReadByte();
return action switch
{
- 0 => ProjectInfoAction.Update,
- 1 => ProjectInfoAction.Remove,
+ 0 => RazorProjectInfoAction.Update,
+ 1 => RazorProjectInfoAction.Remove,
_ => throw Assumes.NotReachable()
};
}
- public static void WriteProjectInfoAction(this Stream stream, ProjectInfoAction projectInfoAction)
+ public static void WriteProjectInfoAction(this Stream stream, RazorProjectInfoAction projectInfoAction)
{
stream.WriteByte(projectInfoAction switch
{
- ProjectInfoAction.Update => 0,
- ProjectInfoAction.Remove => 1,
+ RazorProjectInfoAction.Update => 0,
+ RazorProjectInfoAction.Remove => 1,
_ => throw Assumes.NotReachable()
});
}
public static Task WriteProjectInfoRemovalAsync(this Stream stream, string intermediateOutputPath, CancellationToken cancellationToken)
{
- WriteProjectInfoAction(stream, ProjectInfoAction.Remove);
+ stream.WriteProjectInfoAction(RazorProjectInfoAction.Remove);
return stream.WriteStringAsync(intermediateOutputPath, encoding: null, cancellationToken);
}
@@ -76,13 +77,13 @@ public static Task ReadProjectInfoRemovalAsync(this Stream stream, Cance
public static async Task WriteProjectInfoAsync(this Stream stream, RazorProjectInfo projectInfo, CancellationToken cancellationToken)
{
var bytes = projectInfo.Serialize();
- WriteSize(stream, bytes.Length);
+ stream.WriteSize(bytes.Length);
await stream.WriteAsync(bytes, cancellationToken).ConfigureAwait(false);
}
public static async Task ReadProjectInfoAsync(this Stream stream, CancellationToken cancellationToken)
{
- var sizeToRead = ReadSize(stream);
+ var sizeToRead = stream.ReadSize();
using var _ = ArrayPool.Shared.GetPooledArray(sizeToRead, out var projectInfoBytes);
await stream.ReadExactlyAsync(projectInfoBytes, 0, sizeToRead, cancellationToken).ConfigureAwait(false);
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/TagHelperCache.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/TagHelperCache.cs
index 9c1fe1a3df2..a03227b57a0 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/TagHelperCache.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/TagHelperCache.cs
@@ -6,8 +6,9 @@
using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.PooledObjects;
+using Microsoft.AspNetCore.Razor.Utilities;
-namespace Microsoft.AspNetCore.Razor.Utilities;
+namespace Microsoft.CodeAnalysis.Razor.Utilities;
internal sealed class TagHelperCache
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/UrlDecoder.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/UrlDecoder.cs
index 84ea8161ed5..abe8e19eb3a 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/UrlDecoder.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Utilities/UrlDecoder.cs
@@ -10,8 +10,9 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
+using Microsoft.AspNetCore.Razor;
-namespace Microsoft.AspNetCore.Razor.Utilities;
+namespace Microsoft.CodeAnalysis.Razor.Utilities;
internal static class UrlDecoder
{
@@ -126,7 +127,7 @@ public static void Decode(ReadOnlySpan source, Span destination, out
if ((h1 | h2) != 0xff)
{
// Valid 2 hex character
- var b = (byte)((h1 << 4) | h2);
+ var b = (byte)(h1 << 4 | h2);
i += 2;
// Add to our byte buffer.
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor.CoreComponents/Microsoft.CodeAnalysis.Remote.Razor.CoreComponents.csproj b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor.CoreComponents/Microsoft.CodeAnalysis.Remote.Razor.CoreComponents.csproj
index 709694915b4..358f5f2ed54 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor.CoreComponents/Microsoft.CodeAnalysis.Remote.Razor.CoreComponents.csproj
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor.CoreComponents/Microsoft.CodeAnalysis.Remote.Razor.CoreComponents.csproj
@@ -30,8 +30,6 @@
<_PublishedFiles Include="$(PublishDir)**\Microsoft.AspNetCore.*" />
<_PublishedFiles Include="$(PublishDir)**\Microsoft.Extensions.ObjectPool.dll" />
- <_PublishedFiles Include="$(PublishDir)**\Microsoft.VisualStudio.LanguageServer.Protocol.*" />
-
<_PublishedFiles Remove="@(_PublishedFiles)" Condition="'%(Extension)' == '.pdb'" />
<_PublishedFiles Remove="@(_PublishedFiles)" Condition="'%(Extension)' == '.xml'" />
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/AutoInsert/RemoteAutoInsertService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/AutoInsert/RemoteAutoInsertService.cs
index 4aae34ae003..d6a8cdeacbb 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/AutoInsert/RemoteAutoInsertService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/AutoInsert/RemoteAutoInsertService.cs
@@ -15,10 +15,7 @@
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CodeAnalysis.Remote.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
-using Roslyn.LanguageServer.Protocol;
using Response = Microsoft.CodeAnalysis.Razor.Remote.RemoteResponse;
-using RoslynInsertTextFormat = Roslyn.LanguageServer.Protocol.InsertTextFormat;
namespace Microsoft.CodeAnalysis.Remote.Razor;
@@ -74,7 +71,7 @@ private async ValueTask TryResolveInsertionAsync(
// that adds closing tag instead of HTML even though we are in HTML
if (_autoInsertService.TryResolveInsertion(
codeDocument,
- VsLspExtensions.ToPosition(linePosition),
+ linePosition.ToPosition(),
character,
options.EnableAutoClosingTags,
out var insertTextEdit))
@@ -145,7 +142,7 @@ private async ValueTask TryResolveInsertionInCSharpAsync(
generatedDocument,
mappedPosition,
character,
- options.FormattingOptions.ToRoslynFormattingOptions(),
+ options.FormattingOptions.ToLspFormattingOptions(),
cancellationToken
).ConfigureAwait(false);
@@ -158,7 +155,7 @@ private async ValueTask TryResolveInsertionInCSharpAsync(
var csharpSourceText = await remoteDocumentContext.GetCSharpSourceTextAsync(cancellationToken).ConfigureAwait(false);
var csharpTextChange = new TextChange(csharpSourceText.GetTextSpan(autoInsertResponseItem.TextEdit.Range), autoInsertResponseItem.TextEdit.NewText);
- var mappedChange = autoInsertResponseItem.TextEditFormat == RoslynInsertTextFormat.Snippet
+ var mappedChange = autoInsertResponseItem.TextEditFormat == InsertTextFormat.Snippet
? await _razorFormattingService.TryGetCSharpSnippetFormattingEditAsync(
remoteDocumentContext,
[csharpTextChange],
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/CodeActions/RemoteCodeActionsService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/CodeActions/RemoteCodeActionsService.cs
index 9fabf787caf..1de432143e1 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/CodeActions/RemoteCodeActionsService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/CodeActions/RemoteCodeActionsService.cs
@@ -12,7 +12,6 @@
using Microsoft.CodeAnalysis.Razor.Protocol.CodeActions;
using Microsoft.CodeAnalysis.Razor.Remote;
using Microsoft.CodeAnalysis.Remote.Razor.ProjectSystem;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.CodeAnalysis.Remote.Razor;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/CodeActions/RoslynCodeActionHelpers.cs b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/CodeActions/RoslynCodeActionHelpers.cs
index dd9273321d7..6b5d85d2392 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/CodeActions/RoslynCodeActionHelpers.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/CodeActions/RoslynCodeActionHelpers.cs
@@ -7,16 +7,11 @@
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.AspNetCore.Razor;
-using Microsoft.AspNetCore.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
using Microsoft.CodeAnalysis.Razor.CodeActions;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
-using Microsoft.CodeAnalysis.Razor.Protocol;
using Microsoft.CodeAnalysis.Remote.Razor.ProjectSystem;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
using ExternalHandlers = Microsoft.CodeAnalysis.ExternalAccess.Razor.Cohost.Handlers;
-using RoslynTextEdit = Roslyn.LanguageServer.Protocol.TextEdit;
namespace Microsoft.CodeAnalysis.Remote.Razor;
@@ -57,10 +52,6 @@ public Task GetFormattedNewFileContentsAsync(IProjectSnapshot projectSna
document = solution.GetRequiredDocument(documentIds.First(d => d.ProjectId == context.TextDocument.Project.Id));
}
- var convertedEdit = JsonHelpers.ToRoslynLSP(edit).AssumeNotNull();
-
- var edits = await ExternalHandlers.CodeActions.GetSimplifiedEditsAsync(document, convertedEdit, cancellationToken).ConfigureAwait(false);
-
- return JsonHelpers.ToVsLSP(edits);
+ return await ExternalHandlers.CodeActions.GetSimplifiedEditsAsync(document, edit, cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Completion/RemoteCompletionService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Completion/RemoteCompletionService.cs
index 8ac661d9c3a..325d4743cba 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Completion/RemoteCompletionService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Completion/RemoteCompletionService.cs
@@ -15,11 +15,7 @@
using Microsoft.CodeAnalysis.Razor.Remote;
using Microsoft.CodeAnalysis.Remote.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.LanguageServer.Protocol;
-using Response = Microsoft.CodeAnalysis.Razor.Remote.RemoteResponse;
-using RoslynCompletionContext = Roslyn.LanguageServer.Protocol.CompletionContext;
-using RoslynCompletionList = Roslyn.LanguageServer.Protocol.CompletionList;
-using RoslynCompletionSetting = Roslyn.LanguageServer.Protocol.CompletionSetting;
+using Response = Microsoft.CodeAnalysis.Razor.Remote.RemoteResponse;
namespace Microsoft.CodeAnalysis.Remote.Razor;
@@ -121,7 +117,7 @@ private async ValueTask GetCompletionAsync(
var codeDocument = await documentSnapshot.GetGeneratedOutputAsync(cancellationToken).ConfigureAwait(false);
- VSInternalCompletionList? csharpCompletionList = null;
+ RazorVSInternalCompletionList? csharpCompletionList = null;
if (isCSharpTrigger)
{
var mappedPosition = documentPositionInfo.Position;
@@ -146,7 +142,7 @@ private async ValueTask GetCompletionAsync(
}
}
- VSInternalCompletionList? razorCompletionList = null;
+ RazorVSInternalCompletionList? razorCompletionList = null;
if (isRazorTrigger)
{
@@ -169,7 +165,7 @@ private async ValueTask GetCompletionAsync(
return Response.Results(mergedCompletionList);
}
- private async ValueTask GetCSharpCompletionAsync(
+ private async ValueTask