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

Switch Razor to using clasp as a source package #10139

Merged
merged 3 commits into from
Mar 26, 2024
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
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ while [[ -h $source ]]; do
done

scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
. "$scriptroot/eng/nuget-workaround.sh" $@
"$scriptroot/eng/common/build.sh" --restore --build --pack $@
38 changes: 19 additions & 19 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,80 +11,80 @@
<Sha>c0b5d69a1a1513528c77fffff708c7502d57c35c</Sha>
<SourceBuild RepoName="source-build-reference-packages" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="4.10.0-3.24169.7">
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="4.10.0-3.24170.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>98cd097bf122677378692ebe952b71ab6e5bb013</Sha>
</Dependency>
<Dependency Name="Microsoft.CommonLanguageServerProtocol.Framework" Version="4.10.0-3.24169.7">
<Dependency Name="Microsoft.CommonLanguageServerProtocol.Framework" Version="4.10.0-3.24170.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>98cd097bf122677378692ebe952b71ab6e5bb013</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.ExternalAccess.Razor" Version="4.10.0-3.24169.7">
<Dependency Name="Microsoft.CodeAnalysis.ExternalAccess.Razor" Version="4.10.0-3.24170.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>98cd097bf122677378692ebe952b71ab6e5bb013</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Common" Version="4.10.0-3.24169.7">
<Dependency Name="Microsoft.CodeAnalysis.Common" Version="4.10.0-3.24170.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>98cd097bf122677378692ebe952b71ab6e5bb013</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp" Version="4.10.0-3.24169.7">
<Dependency Name="Microsoft.CodeAnalysis.CSharp" Version="4.10.0-3.24170.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>98cd097bf122677378692ebe952b71ab6e5bb013</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp.EditorFeatures" Version="4.10.0-3.24169.7">
<Dependency Name="Microsoft.CodeAnalysis.CSharp.EditorFeatures" Version="4.10.0-3.24170.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>98cd097bf122677378692ebe952b71ab6e5bb013</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Features" Version="4.10.0-3.24169.7">
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Features" Version="4.10.0-3.24170.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>98cd097bf122677378692ebe952b71ab6e5bb013</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.10.0-3.24169.7">
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.10.0-3.24170.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>98cd097bf122677378692ebe952b71ab6e5bb013</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures" Version="4.10.0-3.24169.7">
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures" Version="4.10.0-3.24170.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>98cd097bf122677378692ebe952b71ab6e5bb013</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Common" Version="4.10.0-3.24169.7">
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Common" Version="4.10.0-3.24170.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>98cd097bf122677378692ebe952b71ab6e5bb013</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Text" Version="4.10.0-3.24169.7">
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Text" Version="4.10.0-3.24170.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>98cd097bf122677378692ebe952b71ab6e5bb013</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Wpf" Version="4.10.0-3.24169.7">
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Wpf" Version="4.10.0-3.24170.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>98cd097bf122677378692ebe952b71ab6e5bb013</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Remote.ServiceHub" Version="4.10.0-3.24169.7">
<Dependency Name="Microsoft.CodeAnalysis.Remote.ServiceHub" Version="4.10.0-3.24170.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>98cd097bf122677378692ebe952b71ab6e5bb013</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="4.10.0-3.24169.7">
<Dependency Name="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="4.10.0-3.24170.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>98cd097bf122677378692ebe952b71ab6e5bb013</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.10.0-3.24169.7">
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.10.0-3.24170.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>98cd097bf122677378692ebe952b71ab6e5bb013</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.10.0-3.24169.7">
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.10.0-3.24170.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>98cd097bf122677378692ebe952b71ab6e5bb013</Sha>
</Dependency>
<Dependency Name="Microsoft.VisualStudio.LanguageServices" Version="4.10.0-3.24169.7">
<Dependency Name="Microsoft.VisualStudio.LanguageServices" Version="4.10.0-3.24170.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>98cd097bf122677378692ebe952b71ab6e5bb013</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Test.Utilities" Version="4.10.0-3.24169.7">
<Dependency Name="Microsoft.CodeAnalysis.Test.Utilities" Version="4.10.0-3.24170.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>98cd097bf122677378692ebe952b71ab6e5bb013</Sha>
</Dependency>
<!-- Intermediate is necessary for source build. -->
<Dependency Name="Microsoft.SourceBuild.Intermediate.roslyn" Version="4.10.0-3.24169.7">
<Dependency Name="Microsoft.SourceBuild.Intermediate.roslyn" Version="4.10.0-3.24170.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>98cd097bf122677378692ebe952b71ab6e5bb013</Sha>
<SourceBuild RepoName="roslyn" ManagedOnly="true" />
Expand Down
38 changes: 19 additions & 19 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,25 @@
<MicrosoftSourceBuildIntermediatearcadePackageVersion>8.0.0-beta.24165.4</MicrosoftSourceBuildIntermediatearcadePackageVersion>
<MicrosoftDotNetXliffTasksPackageVersion>1.0.0-beta.23475.1</MicrosoftDotNetXliffTasksPackageVersion>
<MicrosoftSourceBuildIntermediatexlifftasksPackageVersion>1.0.0-beta.23475.1</MicrosoftSourceBuildIntermediatexlifftasksPackageVersion>
<MicrosoftNetCompilersToolsetPackageVersion>4.10.0-3.24169.7</MicrosoftNetCompilersToolsetPackageVersion>
<MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>4.10.0-3.24169.7</MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>
<MicrosoftCodeAnalysisExternalAccessRazorPackageVersion>4.10.0-3.24169.7</MicrosoftCodeAnalysisExternalAccessRazorPackageVersion>
<MicrosoftCodeAnalysisCommonPackageVersion>4.10.0-3.24169.7</MicrosoftCodeAnalysisCommonPackageVersion>
<MicrosoftCodeAnalysisCSharpPackageVersion>4.10.0-3.24169.7</MicrosoftCodeAnalysisCSharpPackageVersion>
<MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>4.10.0-3.24169.7</MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>
<MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>4.10.0-3.24169.7</MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>
<MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>4.10.0-3.24169.7</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesPackageVersion>4.10.0-3.24169.7</MicrosoftCodeAnalysisEditorFeaturesPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>4.10.0-3.24169.7</MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>4.10.0-3.24169.7</MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesWpfPackageVersion>4.10.0-3.24169.7</MicrosoftCodeAnalysisEditorFeaturesWpfPackageVersion>
<MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>4.10.0-3.24169.7</MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>
<MicrosoftCodeAnalysisTestUtilitiesPackageVersion>4.10.0-3.24169.7</MicrosoftCodeAnalysisTestUtilitiesPackageVersion>
<MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>4.10.0-3.24169.7</MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>
<MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>4.10.0-3.24169.7</MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>
<MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>4.10.0-3.24169.7</MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>
<MicrosoftSourceBuildIntermediateroslynPackageVersion>4.10.0-3.24169.7</MicrosoftSourceBuildIntermediateroslynPackageVersion>
<MicrosoftVisualStudioLanguageServicesPackageVersion>4.10.0-3.24169.7</MicrosoftVisualStudioLanguageServicesPackageVersion>
<MicrosoftNetCompilersToolsetPackageVersion>4.10.0-3.24170.4</MicrosoftNetCompilersToolsetPackageVersion>
<MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>4.10.0-3.24170.4</MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>
Copy link
Contributor

Choose a reason for hiding this comment

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

Firstly, assume I know nothing about our infra, but do we want to change things so that this is no longer automatically updated by our darc subscriptions? Seems like if we don't do that, you're just as likely to break us if you make changes to things.

Having said that, I've no idea if these ever actually automatically update, as I've just been doing it manually when I need to :)

Copy link
Member Author

Choose a reason for hiding this comment

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

I have no idea if roslyn ide packages can be upgraded by darc subscriptions. But either way you don't have any subscriptions in Razor from Roslyn for any of your normal branches, so I don't know why you have versions in version.details.xml
From darc:

PS C:\Users\dabarbet\source\repos\razor> darc get-subscriptions --source-repo roslyn --target-repo razor
https://github.com/dotnet/roslyn (General Testing) ==> 'https://github.com/dotnet/razor' ('demo/lexer')
  - Id: a20bdf0a-4619-4e57-3a2c-08dc325cea30
  - Update Frequency: None
  - Enabled: True
  - Batchable: False
  - PR Failure Notification tags:
  - Merge Policies: []
PS C:\Users\dabarbet\source\repos\razor>

Copy link
Member Author

Choose a reason for hiding this comment

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

I updated the version details file as well since CI was complaining. I assume there must be some other reason for having the versions listed there too, but there aren't any subscriptions using it as far as I can tell.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I have no idea either, I just always update both files 🤷‍♂️

<MicrosoftCodeAnalysisExternalAccessRazorPackageVersion>4.10.0-3.24170.4</MicrosoftCodeAnalysisExternalAccessRazorPackageVersion>
<MicrosoftCodeAnalysisCommonPackageVersion>4.10.0-3.24170.4</MicrosoftCodeAnalysisCommonPackageVersion>
<MicrosoftCodeAnalysisCSharpPackageVersion>4.10.0-3.24170.4</MicrosoftCodeAnalysisCSharpPackageVersion>
<MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>4.10.0-3.24170.4</MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>
<MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>4.10.0-3.24170.4</MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>
<MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>4.10.0-3.24170.4</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesPackageVersion>4.10.0-3.24170.4</MicrosoftCodeAnalysisEditorFeaturesPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>4.10.0-3.24170.4</MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>4.10.0-3.24170.4</MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesWpfPackageVersion>4.10.0-3.24170.4</MicrosoftCodeAnalysisEditorFeaturesWpfPackageVersion>
<MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>4.10.0-3.24170.4</MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>
<MicrosoftCodeAnalysisTestUtilitiesPackageVersion>4.10.0-3.24170.4</MicrosoftCodeAnalysisTestUtilitiesPackageVersion>
<MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>4.10.0-3.24170.4</MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>
<MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>4.10.0-3.24170.4</MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>
<MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>4.10.0-3.24170.4</MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>
<MicrosoftSourceBuildIntermediateroslynPackageVersion>4.10.0-3.24170.4</MicrosoftSourceBuildIntermediateroslynPackageVersion>
<MicrosoftVisualStudioLanguageServicesPackageVersion>4.10.0-3.24170.4</MicrosoftVisualStudioLanguageServicesPackageVersion>
<!--
Exception - Microsoft.Extensions.ObjectPool and System.Collections.Immutable packages are not updated by automation,
but are present in Version.Details.xml for source-build PVP flow. See the comment in Version.Details.xml for more information.
Expand Down
1 change: 1 addition & 0 deletions eng/cibuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ while [[ -h $source ]]; do
done
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"

. "$scriptroot/nuget-workaround.sh" --ci $@
. "$scriptroot/common/build.sh" --ci $@
30 changes: 30 additions & 0 deletions eng/nuget-workaround.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

# This works around an issue where .editorconfigs in nuget packages are not respected if the NUGET_PACKAGES
# environment variable does not end with a slash. We copy the logic for setting the NUGET_PACKAGES variable from the eng/common/tools.sh
# script as we cannot modify the script itself (its arcade managed).
# This workaround is only required for non-windows builds as the powershell versions of the arcade scripts already ensure a trailing slash is present.
# Tracking https://github.com/dotnet/roslyn/issues/72657
ci=false
while [[ $# > 0 ]]; do
opt="$(echo "${1/#--/-}" | tr "[:upper:]" "[:lower:]")"
case "$opt" in
-ci)
ci=true
break
;;
*)
shift
;;
esac
done
if [[ "$ci" == true ]]; then
if [[ -z ${NUGET_PACKAGES:-} ]]; then
if [[ "$ci" == true ]]; then
export NUGET_PACKAGES="$HOME/.nuget/packages/"
else
export NUGET_PACKAGES="$repo_root/.packages/"
export RESTORENOCACHE=true
fi
fi
fi
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<ItemGroup>
<!-- Need this reference to avoid 'The C# language is not supported' error during formatting. -->
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="$(MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion)" />
<PackageReference Include="Microsoft.CommonLanguageServerProtocol.Framework" Version="$(MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion)" />
<PackageReference Include="Microsoft.CommonLanguageServerProtocol.Framework" Version="$(MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion)" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="$(MicrosoftExtensionsPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="$(MicrosoftExtensionsPackageVersion)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,12 @@ internal T GetRequiredService<T>() where T : notnull
}

// Internal for testing
internal TestAccessor GetTestAccessor()
internal new TestAccessor GetTestAccessor()
{
return new TestAccessor(this);
}

internal class TestAccessor
internal new class TestAccessor
{
private RazorLanguageServer _server;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ private CultureInfo GetCultureForRequest()
}

// Internal for testing
internal TestAccessor GetTestAccessor()
internal new TestAccessor GetTestAccessor()
{
return new TestAccessor(this);
}

internal class TestAccessor
internal new class TestAccessor
{
private RazorRequestExecutionQueue _queue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using Microsoft.VisualStudio.Shell;

[assembly: ProvideCodeBase(CodeBase = @"$PackageFolder$\Microsoft.CommonLanguageServerProtocol.Framework.dll")]
[assembly: ProvideCodeBase(CodeBase = @"$PackageFolder$\Microsoft.Extensions.ObjectPool.dll")]
[assembly: ProvideCodeBase(CodeBase = @"$PackageFolder$\Microsoft.Extensions.Options.dll")]
[assembly: ProvideCodeBase(CodeBase = @"$PackageFolder$\Microsoft.Extensions.Primitives.dll")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@
<!-- Include our Razor package dependency dlls in our extension -->
<ItemGroup>
<RazorNgendVSIXSourceItem Include="$(OutputPath)Microsoft.CodeAnalysis.Razor.Compiler.dll" />
<RazorNgendVSIXSourceItem Include="$(OutputPath)Microsoft.CommonLanguageServerProtocol.Framework.dll" />

<VSIXSourceItem Include="@(RazorNgendVSIXSourceItem)">
<Ngen>$(Ngen)</Ngen>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
<Asset Type="Microsoft.ServiceHub.Service" d:Source="File" Path="ServiceHubCore\Microsoft.VisualStudio.Razor.ClientInitializationCore64.servicehub.service.json" />
<Asset Type="Microsoft.ServiceHub.Service" d:Source="File" Path="ServiceHubCore\Microsoft.VisualStudio.Razor.ClientInitializationCore64S.servicehub.service.json" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.CodeAnalysis.Razor.Compiler.dll" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.CommonLanguageServerProtocol.Framework.dll" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.Extensions.ObjectPool.dll" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.Extensions.Options.dll" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.Extensions.Primitives.dll" />
Expand Down
Original file line number Diff line number Diff line change
@@ -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.

extern alias LegacyClasp;

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
Expand Down Expand Up @@ -240,8 +242,27 @@ public static ApplyFormatEditsHandler New(
BufferManager bufferManager,
ILspLogger logger)
{
var instance = CreateInstance(Type, textBufferFactoryService, bufferManager.Instance, logger);
var instance = CreateInstance(Type, textBufferFactoryService, bufferManager.Instance, new LegacyClaspILspLogger(logger));
return new(instance);
}

/// <summary>
/// Wraps the razor logger (from the clasp source package) into the binary clasp logger that webtools uses.
/// </summary>
/// <param name="logger"></param>
private class LegacyClaspILspLogger(ILspLogger logger) : LegacyClasp.Microsoft.CommonLanguageServerProtocol.Framework.ILspLogger
Copy link
Member

Choose a reason for hiding this comment

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

I'm guessing that this is necessary until Web Tools is updated and then we pull in new Web Tools assemblies for tests? If so, could you please be sure to file an issue for us so we remember to get back to this?

Copy link
Member Author

@dibarbet dibarbet Mar 25, 2024

Choose a reason for hiding this comment

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

Yeah we can remove the code that ships the legacy clasp package. I filed #10160 for that.

However I expect this particular bit of code will actually need to change to a reflection instantiation of the ILspLogger from the webtools package (since the razor source package type isn't the same type as the webtools source package type). Its unfortunate that the clasp type is exposed across boundaries here - maybe there is a possibility on the webtools side to retrieve the logger in another way (that Razor wouldn't need to know about).

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, that makes sense. Of course, we use so much reflection for the WebTools code here that's really just business as usual. 😄

{
public void LogEndContext(string message, params object[] @params) => logger.LogEndContext(message, @params);

public void LogError(string message, params object[] @params) => logger.LogError(message, @params);

public void LogException(Exception exception, string? message = null, params object[] @params) => logger.LogException(exception, message, @params);

public void LogInformation(string message, params object[] @params) => logger.LogInformation(message, @params);

public void LogStartContext(string message, params object[] @params) => logger.LogStartContext(message, @params);

public void LogWarning(string message, params object[] @params) => logger.LogWarning(message, @params);
}
}
}
Loading