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

[Editor] Upgrade RolsynPad.Roslyn to v4.8.0 #2124

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
17 changes: 16 additions & 1 deletion build/Stride.sln
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stride.NuGetResolver", "..\
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuGetResolver", "NuGetResolver", "{158087CF-AF74-44E9-AA20-A6AEB1E398A9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Stride.Core.Presentation", "..\sources\presentation\Stride.Core.Presentation\Stride.Core.Presentation.csproj", "{0C63EF8B-26F9-4511-9FC5-7431DE9657D6}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stride.Core.Presentation", "..\sources\presentation\Stride.Core.Presentation\Stride.Core.Presentation.csproj", "{0C63EF8B-26F9-4511-9FC5-7431DE9657D6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stride.RestoreHelper", "..\sources\editor\Stride.RestoreHelper\Stride.RestoreHelper.csproj", "{B2AE0143-AAB5-42F3-9214-E678E6393C53}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -1493,6 +1495,18 @@ Global
{0C63EF8B-26F9-4511-9FC5-7431DE9657D6}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{0C63EF8B-26F9-4511-9FC5-7431DE9657D6}.Release|Win32.ActiveCfg = Release|Any CPU
{0C63EF8B-26F9-4511-9FC5-7431DE9657D6}.Release|Win32.Build.0 = Release|Any CPU
{B2AE0143-AAB5-42F3-9214-E678E6393C53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B2AE0143-AAB5-42F3-9214-E678E6393C53}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B2AE0143-AAB5-42F3-9214-E678E6393C53}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{B2AE0143-AAB5-42F3-9214-E678E6393C53}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{B2AE0143-AAB5-42F3-9214-E678E6393C53}.Debug|Win32.ActiveCfg = Debug|Any CPU
{B2AE0143-AAB5-42F3-9214-E678E6393C53}.Debug|Win32.Build.0 = Debug|Any CPU
{B2AE0143-AAB5-42F3-9214-E678E6393C53}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B2AE0143-AAB5-42F3-9214-E678E6393C53}.Release|Any CPU.Build.0 = Release|Any CPU
{B2AE0143-AAB5-42F3-9214-E678E6393C53}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{B2AE0143-AAB5-42F3-9214-E678E6393C53}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{B2AE0143-AAB5-42F3-9214-E678E6393C53}.Release|Win32.ActiveCfg = Release|Any CPU
{B2AE0143-AAB5-42F3-9214-E678E6393C53}.Release|Win32.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1619,6 +1633,7 @@ Global
{02FD0BDE-4293-414F-97E6-69FF71105420} = {158087CF-AF74-44E9-AA20-A6AEB1E398A9}
{158087CF-AF74-44E9-AA20-A6AEB1E398A9} = {1AE1AC60-5D2F-4CA7-AE20-888F44551185}
{0C63EF8B-26F9-4511-9FC5-7431DE9657D6} = {75A820AB-0F21-40F2-9448-5D7F495B97A0}
{B2AE0143-AAB5-42F3-9214-E678E6393C53} = {5D2D3BE8-9910-45CA-8E45-95660DA4C563}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FF877973-604D-4EA7-B5F5-A129961F9EF2}
Expand Down
22 changes: 13 additions & 9 deletions sources/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<PropertyGroup>
<RoslynPrivateVersion>4.8.0-7.23558.1</RoslynPrivateVersion>
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't be needed if the <PackageVersion>version is defined in this file.

Copy link
Author

@a-tsymbal a-tsymbal Jan 25, 2024

Choose a reason for hiding this comment

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

It is not defined in this file but we could move this to Stride.RestoreHelper.csproj and set it directly there.

</PropertyGroup>
<!-- Runtime dependencies -->
<ItemGroup>
<PackageVersion Include="FFmpeg.AutoGen" Version="3.4.0.2" />
Expand Down Expand Up @@ -34,14 +37,15 @@
</ItemGroup>
<!-- Other dependencies -->
<ItemGroup>
<PackageVersion Include="IgnoresAccessChecksToGenerator" Version="0.6.0" />
<PackageVersion Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
<PackageVersion Include="Microsoft.Build" Version="17.8.3" />
<PackageVersion Include="Microsoft.Build.Locator" Version="1.6.10" />
<PackageVersion Include="Microsoft.Build.Utilities.Core" Version="17.8.3" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Features" Version="3.6.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="3.6.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.6.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="3.6.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Features" Version="4.8.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.8.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.8.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.8.0" />
<PackageVersion Include="Microsoft.CSharp" Version="4.7.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyModel" Version="8.0.0" />
<PackageVersion Include="Microsoft.VisualStudio.Setup.Configuration.Interop" Version="3.8.2112" />
Expand Down Expand Up @@ -122,14 +126,14 @@
<PackageVersion Include="Stride.CrashReport" Version="1.0.2" />
<PackageVersion Include="Stride.GraphX.WPF.Controls" Version="2.4.0" />
<PackageVersion Include="Stride.Metrics" Version="1.0.3" />
<PackageVersion Include="RoslynPad.Editor.Windows" Version="1.2.0" />
<PackageVersion Include="RoslynPad.Roslyn" Version="3.6.0" />
<PackageVersion Include="RoslynPad.Roslyn.Windows" Version="3.6.0" />
<PackageVersion Include="RoslynPad.Editor.Windows" Version="4.8.0" />
<PackageVersion Include="RoslynPad.Roslyn" Version="4.8.0" />
<PackageVersion Include="RoslynPad.Roslyn.Windows" Version="4.8.0" />
</ItemGroup>
<!-- Analyzers -->
<ItemGroup>
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" PrivateAssets="all" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.7.0" PrivateAssets="all" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" PrivateAssets="all" />
<PackageVersion Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public RoslynHost()

// Create default workspace
workspace = new RoslynWorkspace(this);
workspace.EnableDiagnostics(DiagnosticOptions.Semantic | DiagnosticOptions.Syntax);
workspace.EnableDiagnostics();

GetService<IDiagnosticService>().DiagnosticsUpdated += OnDiagnosticsUpdated;

Expand All @@ -64,14 +64,17 @@ private static CompositionHost CreateCompositionContext()
Assembly.Load("Microsoft.CodeAnalysis.Features"),
Assembly.Load("Microsoft.CodeAnalysis.CSharp.Features"),
Assembly.Load("Microsoft.CodeAnalysis.Workspaces.MSBuild"),
Assembly.Load("Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost"), // because the file extension '.csproj' is not associated with a language.
typeof(IRoslynHost).Assembly, // RoslynPad.Roslyn
typeof(SymbolDisplayPartExtensions).Assembly, // RoslynPad.Roslyn.Windows
typeof(AvalonEditTextContainer).Assembly, // RoslynPad.Editor.Windows
};

var partTypes = assemblies
.SelectMany(x => x.DefinedTypes)
.Select(x => x.AsType());
.Select(x => x.AsType())
.Where(x => x != typeof(DocumentTrackingServiceFactory))
.Concat(MetadataUtil.LoadTypesByNamespaces(typeof(Microsoft.CodeAnalysis.Diagnostics.IDiagnosticService).Assembly, "Microsoft.CodeAnalysis.Diagnostics", "Microsoft.CodeAnalysis.CodeFixes"));

return new ContainerConfiguration()
.WithParts(partTypes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,20 @@ private void ProcessDiagnosticsOnUiThread(DiagnosticsUpdatedArgs args)
return;
}

var document = workspace.Host.GetDocument(documentId);
if (document == null || !document.TryGetText(out var text))
{
return;
}

foreach (var diagnosticData in args.Diagnostics)
{
if (diagnosticData.Severity == DiagnosticSeverity.Hidden || diagnosticData.IsSuppressed)
{
continue;
}

if (diagnosticData.GetTextSpan() is Microsoft.CodeAnalysis.Text.TextSpan diag == false)
if (diagnosticData.GetTextSpan(text) is Microsoft.CodeAnalysis.Text.TextSpan diag == false)
{
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,29 @@
<UseWPF>true</UseWPF>
<EnableDefaultPageItems>false</EnableDefaultPageItems>
</PropertyGroup>
<PropertyGroup>
<!-- warning CS0436: IgnoresAccessChecksTo conflict with same attribute from RolsynPad -->
<NoWarn>$(NoWarn);CS0436</NoWarn>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Stride.RestoreHelper\Stride.RestoreHelper.csproj" Targets="GetLibReferences" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Build" ExcludeAssets="runtime" />
<PackageReference Include="AvalonEdit" />
<PackageReference Include="System.Reactive.Linq" />
<PackageReference Include="System.Reactive" />
<PackageReference Include="IgnoresAccessChecksToGenerator" PrivateAssets="All" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Features" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" />
<PackageReference Include="RoslynPad.Editor.Windows" />
<PackageReference Include="RoslynPad.Roslyn.Windows" />
<PackageReference Include="RoslynPad.Roslyn" />
</ItemGroup>
<ItemGroup>
<InternalsAssemblyName Include="Microsoft.CodeAnalysis.LanguageServer.Protocol" />
<InternalsAssemblyName Include="RoslynPad.Roslyn" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\shared\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
Expand Down
24 changes: 24 additions & 0 deletions sources/editor/Stride.RestoreHelper/Stride.RestoreHelper.csproj
Copy link
Member

Choose a reason for hiding this comment

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

What is this file? It seems unrelated to Roslyn.

Copy link
Author

Choose a reason for hiding this comment

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

https://github.com/microsoft/MSBuildSdks/blob/main/src/NoTargets/README.md ("This can be useful for utility projects that just copy files, ...")

This is a helper project to copy requred dll from nuget folder
~.nuget\packages\microsoft.codeanalysis.languageserver.protocol\4.8.0-7.23558.1\lib\net7.0\Microsoft.CodeAnalysis.LanguageServer.Protocol.dll

We use it because now this dll is deprecated on nuget
https://www.nuget.org/packages/Microsoft.CodeAnalysis.LanguageServer.Protocol/3.9.0-5.21120.8

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.Build.NoTargets/3.7.56">
<Import Project="..\..\targets\Stride.Core.props" />
<PropertyGroup>
<TargetFramework>$(StrideFramework)</TargetFramework>
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
a-tsymbal marked this conversation as resolved.
Show resolved Hide resolved
<RestoreSources>
https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json;
https://pkgs.dev.azure.com/azure-public/vside/_packaging/vssdk/nuget/v3/index.json;
https://pkgs.dev.azure.com/azure-public/vside/_packaging/vs-impl/nuget/v3/index.json;
https://api.nuget.org/v3/index.json
</RestoreSources>
Comment on lines +6 to +11
Copy link
Member

Choose a reason for hiding this comment

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

What are those sources?

Copy link
Author

Choose a reason for hiding this comment

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

<NoWarn>$(NoWarn);NU1603;NU1605</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.LanguageServer.Protocol" Version="4.8.0-7.23558.1" GeneratePathProperty="true" IncludeAssets="none" PrivateAssets="all" />
</ItemGroup>
<Target Name="GetLibReferences" Outputs="@(Reference)">
<ItemGroup>
<Reference Include="$(PkgMicrosoft_CodeAnalysis_LanguageServer_Protocol)/lib/net7.0/*.dll" />
</ItemGroup>
</Target>
Comment on lines +18 to +22
Copy link
Member

Choose a reason for hiding this comment

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

How does it work? Where is the reference (documentation) for this trick?

Copy link
Author

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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


</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
<DefineConstants>STRIDE_NUGET_RESOLVER_UI;$(DefineConstants)</DefineConstants>
</PropertyGroup>

<Target Name="GetLibReferences" AfterTargets="ResolveFrameworkReferences">
<MSBuild Projects="@(ProjectReference)" Targets="GetLibReferences">
<Output ItemName="LibReference" TaskParameter="TargetOutputs" />
</MSBuild>
<ItemGroup>
<Reference Include="@(LibReference)" />
<Content Include="@(LibReference)" PackagePath="lib/$(TargetFramework)" Pack="true" />
</ItemGroup>
</Target>

<ItemGroup>
<Compile Include="..\Stride.NuGetResolver\NuGetAssemblyResolver.cs" Link="NuGetAssemblyResolver.cs" />
<Compile Include="..\Stride.NuGetResolver\RestoreHelper.cs" Link="RestoreHelper.cs" />
Expand Down
10 changes: 10 additions & 0 deletions sources/shared/Stride.NuGetResolver/Stride.NuGetResolver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,14 @@
<PackageReference Include="NuGet.Commands" />
</ItemGroup>

<Target Name="GetLibReferences" AfterTargets="ResolveFrameworkReferences">
<MSBuild Projects="@(ProjectReference)" Targets="GetLibReferences">
<Output ItemName="LibReference" TaskParameter="TargetOutputs" />
</MSBuild>
<ItemGroup>
<Reference Include="@(LibReference)" />
<Content Include="@(LibReference)" PackagePath="lib/$(TargetFramework)" Pack="true" />
</ItemGroup>
</Target>

</Project>
10 changes: 10 additions & 0 deletions sources/targets/Stride.Core.props
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,16 @@
</ItemGroup>
</Target>

<Target Name="GetLibReferences" AfterTargets="ResolveFrameworkReferences">
<MSBuild Projects="@(ProjectReference)" Targets="GetLibReferences">
<Output ItemName="LibReference" TaskParameter="TargetOutputs" />
</MSBuild>
<ItemGroup>
<Reference Include="@(LibReference)" />
<Content Include="@(LibReference)" PackagePath="lib/$(TargetFramework)" Pack="true" />
</ItemGroup>
</Target>

<!-- Include Stride analyzer/code generator -->
<Import Project="$(MSBuildThisFileDirectory)Stride.Core.CompilerServices.props"/>

Expand Down
10 changes: 10 additions & 0 deletions sources/targets/Stride.props
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,14 @@
</ItemGroup>
</Target>

<Target Name="GetLibReferences" AfterTargets="ResolveFrameworkReferences">
<MSBuild Projects="@(ProjectReference)" Targets="GetLibReferences">
<Output ItemName="LibReference" TaskParameter="TargetOutputs" />
</MSBuild>
<ItemGroup>
<Reference Include="@(LibReference)" />
<Content Include="@(LibReference)" PackagePath="lib/$(TargetFramework)" Pack="true" />
</ItemGroup>
</Target>

</Project>
11 changes: 11 additions & 0 deletions sources/tools/Stride.PackageInstall/Stride.PackageInstall.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,15 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<Target Name="GetLibReferences" AfterTargets="ResolveFrameworkReferences">
<MSBuild Projects="@(ProjectReference)" Targets="GetLibReferences">
<Output ItemName="LibReference" TaskParameter="TargetOutputs" />
</MSBuild>
<ItemGroup>
<Reference Include="@(LibReference)" />
<Content Include="@(LibReference)" PackagePath="lib/$(TargetFramework)" Pack="true" />
</ItemGroup>
</Target>

</Project>