Skip to content

Commit

Permalink
Switch Razor to using clasp as a source package (#10139)
Browse files Browse the repository at this point in the history
### Summary of the changes
Now that dotnet/roslyn#72237 has merged on the
Roslyn side, we need to update Razor to consume the source package
version. This will allow us to delete the nuget package version

-

Fixes:
  • Loading branch information
dibarbet authored Mar 26, 2024
2 parents e7584eb + 0317025 commit e832b1d
Show file tree
Hide file tree
Showing 13 changed files with 120 additions and 47 deletions.
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.24170.6</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>
<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
{
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

0 comments on commit e832b1d

Please sign in to comment.