Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix EA layering for Razor.ExternalAccess #77927

Merged
merged 9 commits into from
Apr 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.Text.Adornments;
using Roslyn.LanguageServer.Protocol;
using Roslyn.Test.Utilities;
using Roslyn.Text.Adornments;
using Xunit;
using Xunit.Abstractions;
using LSP = Roslyn.LanguageServer.Protocol;
Expand Down Expand Up @@ -423,7 +423,7 @@ private static VSInternalCompletionItem CreateResolvedCompletionItem(
};
}

expectedCompletionItem.Description = description.ToLSPElement();
expectedCompletionItem.Description = description;
return expectedCompletionItem;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<ProjectReference Include="..\..\Compilers\Core\Portable\Microsoft.CodeAnalysis.csproj" />
<ProjectReference Include="..\..\Compilers\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.csproj" />
<ProjectReference Include="..\..\Compilers\VisualBasic\Portable\Microsoft.CodeAnalysis.VisualBasic.vbproj" />
<ProjectReference Include="..\..\EditorFeatures\Core\Microsoft.CodeAnalysis.EditorFeatures.csproj" />
Copy link
Member

Choose a reason for hiding this comment

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

@dibarbet / @tmat / @CyrusNajmabadi is this a layering violation? Language Server is in "features", but not sure if it matters since it's just tests.

Copy link
Member

Choose a reason for hiding this comment

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

yes this is a violation - if we didn't have the reference before we should avoid adding it if possible. What triggered the inclusion here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It already existed. You can see I fixed some of the violation code in src/LanguageServer/ProtocolUnitTests/Completion/CompletionResolveTests.cs that was referencing Microsoft.VisualStudio.Text.Adornments

I don't immediately remember how this was included transitively before but I can get a binlog from main and look

Copy link
Member

Choose a reason for hiding this comment

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

It was probably Microsoft.CodeAnalysis.Remote.ServiceHub.csproj referencing Microsoft.CodeAnalysis.ExternalAccess.Razor.csproj which references Microsoft.CodeAnalysis.EditorFeatures.csproj

I'm fine with this then as it is a pre-existing violation then

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah yea that's definitely it

<ProjectReference Include="..\..\Interactive\Host\Microsoft.CodeAnalysis.InteractiveHost.csproj" />
<ProjectReference Include="..\..\Scripting\Core\Microsoft.CodeAnalysis.Scripting.csproj" />
<ProjectReference Include="..\..\Scripting\CSharp\Microsoft.CodeAnalysis.CSharp.Scripting.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Microsoft.CodeAnalysis.ExternalAccess.Razor
[Shared]
[ExportMetadata("Extensions", new string[] { "cshtml", "razor", })]
[Export(typeof(IDynamicFileInfoProvider))]
internal sealed class RazorDynamicFileInfoProviderWrapper : IDynamicFileInfoProvider
internal class RazorDynamicFileInfoProviderWrapper : IDynamicFileInfoProvider
{
private readonly Lazy<IRazorDynamicFileInfoProvider> _innerDynamicFileInfoProvider;
private readonly object _attachLock = new object();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Microsoft.CodeAnalysis.LanguageServer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.LanguageServer.Handler;

namespace Microsoft.CodeAnalysis.ExternalAccess.Razor.Features;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.LanguageServer.Handler;
using Microsoft.CommonLanguageServerProtocol.Framework;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Composition;
using Microsoft.CodeAnalysis.LanguageServer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Composition;
using Microsoft.CodeAnalysis.LanguageServer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;

namespace Microsoft.CodeAnalysis.ExternalAccess.Razor.Features;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Threading;
using System.Threading.Tasks;

namespace Microsoft.CodeAnalysis.ExternalAccess.Razor.Features;

internal interface IRazorRequestWrapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

<PropertyGroup>
<RootNamespace>Microsoft.CodeAnalysis.ExternalAccess.Razor.Features</RootNamespace>
<TargetFramework>$(NetVSCode)</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<TargetFrameworks>$(NetVSCode);$(NetVS);netstandard2.0</TargetFrameworks>
<Nullable>enable</Nullable>

<!-- NuGet -->
Expand All @@ -25,6 +24,9 @@
This is used to load in the language server so it gets special treatment. Otherwise only razor assemblies should be added.
-->
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.LanguageServer" />

<!-- OOP references -->
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.Remote.ServiceHub" />

<!--
⚠ ONLY RAZOR ASSEMBLIES MAY BE ADDED HERE ⚠
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Threading;
using System.Threading.Tasks;

namespace Microsoft.CodeAnalysis.ExternalAccess.Razor.Features;

internal abstract class RazorLspDynamicFileInfoProvider : AbstractRazorLspService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using Microsoft.CodeAnalysis.LanguageServer;
using Microsoft.CodeAnalysis.LanguageServer.Handler;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Roslyn.LanguageServer.Protocol;
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.LanguageServer;
using Roslyn.LanguageServer.Protocol;

namespace Microsoft.CodeAnalysis.ExternalAccess.Razor.Features;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,93 @@
<Import_RootNamespace>Microsoft.CodeAnalysis.ExternalAccess.Razor.Shared</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)ChecksumWrapper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Cohost\AbstractRazorCohostDocumentRequestHandler.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Cohost\AbstractRazorLspService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Cohost\AbstractRazorRequestHandler.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Cohost\Constants.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Cohost\ExportCohostLspServiceFactoryAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Cohost\ExportCohostStatelessLspServiceAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Cohost\Handlers\CodeActions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Cohost\Handlers\Completion.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Cohost\Handlers\Diagnostics.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Cohost\Handlers\DocumentHighlights.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Cohost\Handlers\DocumentSpellCheck.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Cohost\Handlers\DocumentSymbols.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Cohost\Handlers\FindAllReferences.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Cohost\Handlers\FoldingRanges.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Cohost\Handlers\GoToDefinition.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Cohost\Handlers\GoToImplementation.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Cohost\Handlers\Hover.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Cohost\Handlers\InlayHints.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Cohost\Handlers\OnAutoInsert.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Cohost\Handlers\Rename.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Cohost\Handlers\SemanticTokensRange.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Cohost\Handlers\SignatureHelp.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Cohost\Handlers\ValidateBreakableRange.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Cohost\IRazorCohostDynamicRegistrationService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Cohost\IRazorCustomMessageTarget.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Cohost\IRazorSemanticTokensRefreshQueue.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Cohost\RazorClientLanguageServerManagerFactory.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Cohost\RazorCohostClientLanguageServerManagerFactory.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Cohost\RazorCohostRequestContext.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Cohost\RazorMethodAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Cohost\RazorSemanticTokensRefreshQueueWrapper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Constants.cs" />
<Compile Include="$(MSBuildThisFileDirectory)IMefHostServicesExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)IRazorAsynchronousOperationListenerProviderAccessor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)IRazorClientLanguageServerManager.cs" />
<Compile Include="$(MSBuildThisFileDirectory)IRazorDocumentExcerptService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)IRazorDocumentOperationService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)IRazorDocumentPropertiesService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)IRazorDocumentServiceProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)IRazorDynamicFileInfoProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)IRazorLanguageServerTarget.cs" />
<Compile Include="$(MSBuildThisFileDirectory)IRazorMappingService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)IRazorSpanMappingService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RazorAnalyzerAssemblyResolver.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RazorAsynchronousOperationListenerProviderAccessor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RazorAsynchronousOperationListenerWrapper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RazorAutoFormattingOptions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RazorBreakpointSpans.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RazorClassificationOptionsWrapper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RazorClassifierAccessor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RazorClientLanguageServerManager.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RazorCSharpFormattingInteractionService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RazorCSharpProximityExpressionResolverService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RazorDocumentExcerptServiceWrapper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RazorDocumentPropertiesServiceWrapper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RazorDocumentServiceProviderWrapper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RazorDynamicFileInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RazorExcerptMode.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RazorExcerptResult.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RazorGlobalOptions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RazorIndentationOptions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RazorLanguageServerTargetWrapper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RazorMappedSpanResult.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RazorMappingServiceWrapper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RazorPredefinedCodeFixProviderNames.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RazorPredefinedCodeRefactoringProviderNames.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RazorProjectExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RazorSemanticTokensAccessor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RazorUri.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Remote\JsonSerializableDocumentId.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Remote\JsonSerializableRazorPinnedSolutionInfoWrapper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Remote\RazorPinnedSolutionInfoWrapper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Remote\RazorRemoteCallbackWrapper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Remote\RazorRemoteHostClient.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Remote\RazorRemoteServiceCallbackDispatcher.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Remote\RazorRemoteServiceCallbackDispatcherRegistry.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Remote\RazorRemoteServiceCallbackIdWrapper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Remote\RazorRemoteServiceConnectionWrapper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Remote\RazorServiceDescriptorsWrapper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SolutionExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Testing\AbstractRazorLanguageServerFactoryWrapper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Testing\IRazorTestCapabilitiesProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Testing\RazorTestAnalyzerLoader.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Testing\RazorTestLanguageServerFactory.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Testing\RazorTestWorkspaceRegistrationService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Testing\TestSolutionStore.cs" />
<Compile Include="$(MSBuildThisFileDirectory)TextDocumentExtensions.cs" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.Workspaces.Test.Utilities" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.Completion.Tests" Key="$(IntelliCodeCSharpKey)" WorkItem="https://github.com/dotnet/roslyn/issues/35081" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.AspNetCore" />
<!-- Razor is transitioning to using the correct EA structure. In the meantime add IVT for both until Razor moves to the correct layer -->
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.Razor" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.Razor.Features" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.VisualDiagnostics" />
<RestrictedInternalsVisibleTo Include="Microsoft.VisualStudio.IntelliCode.CSharp" Partner="Pythia" Key="$(IntelliCodeCSharpKey)" />
<RestrictedInternalsVisibleTo Include="Microsoft.VisualStudio.IntelliCode.CSharp.Extraction" Partner="Pythia" Key="$(IntelliCodeCSharpKey)" />
Expand Down
Loading