Skip to content

Commit 29e5e7d

Browse files
Merge pull request icsharpcode#3500 from icsharpcode/net10upgrade-future
Upgrade dotnet target framework to net10
2 parents 0bfe222 + 2fb90b4 commit 29e5e7d

File tree

68 files changed

+609
-281
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+609
-281
lines changed

.github/workflows/build-frontends.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ jobs:
2121

2222
- uses: actions/setup-dotnet@v4
2323
with:
24-
dotnet-version: '8.0.x'
25-
dotnet-quality: 'ga'
24+
dotnet-version: '10.0.x'
25+
dotnet-quality: 'preview'
2626

2727
- name: Install dependencies
28-
run: dotnet restore ILSpy.XPlat.slnf
28+
run: dotnet restore ILSpy.XPlat.slnf -p:RestoreEnablePackagePruning=false
2929

3030
- name: Build Debug
3131
run: dotnet msbuild ILSpy.XPlat.slnf -p:Configuration=Debug -bl:Debug.binlog

.github/workflows/build-ilspy.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ jobs:
3434

3535
- uses: actions/setup-dotnet@v4
3636
with:
37-
dotnet-version: '8.0.x'
38-
dotnet-quality: 'ga'
37+
dotnet-version: '10.0.x'
38+
dotnet-quality: 'preview'
3939
env:
4040
DOTNET_INSTALL_DIR: ${{ runner.temp }}/.dotnet
4141
DOTNET_ROOT: ${{ runner.temp }}/.dotnet
@@ -44,7 +44,7 @@ jobs:
4444
uses: microsoft/setup-msbuild@v2
4545

4646
- name: Install dotnet-format
47-
run: dotnet tool install -g dotnet-format --version "8.3.546805" --add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json
47+
run: dotnet tool install -g dotnet-format --version "9.0.520307" --add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json
4848

4949
- name: Install wix (locked version)
5050
run: dotnet tool install --global wix --version 6.0.0
@@ -57,17 +57,17 @@ jobs:
5757
Get-ChildItem Env: | Where-Object {$_.Name -Match "^ILSPY_"} | %{ echo "$($_.Name)=$($_.Value)" } | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf8 -Append
5858
5959
- name: Restore the application
60-
run: msbuild ILSpy.sln /t:Restore /p:Configuration=${{ matrix.configuration }} /p:Platform=$env:BuildPlatform
60+
run: msbuild ILSpy.sln /t:Restore /p:RestoreEnablePackagePruning=false /p:Configuration=${{ matrix.configuration }} /p:Platform=$env:BuildPlatform
6161

6262
- name: Build
6363
run: msbuild ILSpy.sln /p:Configuration=${{ matrix.configuration }} /p:Platform=$env:BuildPlatform /m
6464

6565
- name: Execute unit tests
6666
run: dotnet test --logger "trx;LogFileName=${{ matrix.configuration }}.trx" --results-directory test-results $env:Tests1 $env:Tests2 $env:Tests3
6767
env:
68-
Tests1: ICSharpCode.Decompiler.Tests\bin\${{ matrix.configuration }}\net8.0-windows\win-x64\ICSharpCode.Decompiler.Tests.dll
69-
Tests2: ILSpy.Tests\bin\${{ matrix.configuration }}\net8.0-windows\ILSpy.Tests.dll
70-
Tests3: ILSpy.BamlDecompiler.Tests\bin\${{ matrix.configuration }}\net8.0-windows\win-x64\ILSpy.BamlDecompiler.Tests.dll
68+
Tests1: ICSharpCode.Decompiler.Tests\bin\${{ matrix.configuration }}\net10.0-windows\win-x64\ICSharpCode.Decompiler.Tests.dll
69+
Tests2: ILSpy.Tests\bin\${{ matrix.configuration }}\net10.0-windows\ILSpy.Tests.dll
70+
Tests3: ILSpy.BamlDecompiler.Tests\bin\${{ matrix.configuration }}\net10.0-windows\win-x64\ILSpy.BamlDecompiler.Tests.dll
7171

7272
- name: Upload Test Logs
7373
uses: actions/upload-artifact@v4
@@ -94,19 +94,19 @@ jobs:
9494
git diff --exit-code
9595
9696
- name: Zip ILSpy (framework-dependent)
97-
run: 7z a -tzip $env:StagingDirectory\ILSpy_binaries.zip .\ILSpy\bin\${{ matrix.configuration }}\net8.0-windows\*.dll .\ILSpy\bin\${{ matrix.configuration }}\net8.0-windows\*.exe .\ILSpy\bin\${{ matrix.configuration }}\net8.0-windows\*.config .\ILSpy\bin\${{ matrix.configuration }}\net8.0-windows\*.json .\ILSpy\bin\${{ matrix.configuration }}\net8.0-windows\*\ILSpy.resources.dll .\ILSpy\bin\${{ matrix.configuration }}\net8.0-windows\*\ILSpy.ReadyToRun.Plugin.resources.dll
97+
run: 7z a -tzip $env:StagingDirectory\ILSpy_binaries.zip .\ILSpy\bin\${{ matrix.configuration }}\net10.0-windows\*.dll .\ILSpy\bin\${{ matrix.configuration }}\net10.0-windows\*.exe .\ILSpy\bin\${{ matrix.configuration }}\net10.0-windows\*.config .\ILSpy\bin\${{ matrix.configuration }}\net10.0-windows\*.json .\ILSpy\bin\${{ matrix.configuration }}\net10.0-windows\*\ILSpy.resources.dll .\ILSpy\bin\${{ matrix.configuration }}\net10.0-windows\*\ILSpy.ReadyToRun.Plugin.resources.dll
9898

9999
- name: Publish x64/arm64 framework-dependent/self-contained
100100
shell: pwsh
101101
run: .\publish.ps1
102102

103103
- name: Zip ILSpy Release (x64 self-contained)
104104
if: matrix.configuration == 'release'
105-
run: 7z a -tzip $env:StagingDirectory\ILSpy_selfcontained_x64.zip .\ILSpy\bin\Release\net8.0-windows\win-x64\publish\selfcontained\*
105+
run: 7z a -tzip $env:StagingDirectory\ILSpy_selfcontained_x64.zip .\ILSpy\bin\Release\net10.0-windows\win-x64\publish\selfcontained\*
106106

107107
- name: Zip ILSpy Release (arm64 framework-dependent)
108108
if: matrix.configuration == 'release'
109-
run: 7z a -tzip $env:StagingDirectory\ILSpy_binaries_arm64.zip .\ILSpy\bin\Release\net8.0-windows\win-arm64\publish\fwdependent\*
109+
run: 7z a -tzip $env:StagingDirectory\ILSpy_binaries_arm64.zip .\ILSpy\bin\Release\net10.0-windows\win-arm64\publish\fwdependent\*
110110

111111
- name: Pack NuGets
112112
if: matrix.configuration == 'release'

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ jobs:
3737

3838
- uses: actions/setup-dotnet@v4
3939
with:
40-
dotnet-version: '8.0.x'
41-
dotnet-quality: 'ga'
40+
dotnet-version: '10.0.x'
41+
dotnet-quality: 'preview'
4242

4343
- name: Build
44-
run: dotnet build ILSpy.XPlat.slnf --configuration Release
44+
run: dotnet build ILSpy.XPlat.slnf --configuration Release -p:RestoreEnablePackagePruning=false
4545

4646
- name: Perform CodeQL Analysis
4747
uses: github/codeql-action/analyze@v3

.gitmodules

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[submodule "ILSpy-tests"]
22
path = ILSpy-tests
33
url = https://github.com/icsharpcode/ILSpy-tests
4+
branch = master

BuildTools/pre-commit

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
set -eu
77

8-
DOTNET_FORMAT_VERSION=8.3.546805
8+
DOTNET_FORMAT_VERSION=9.0.520307
99
DOTNET_PATH="$LOCALAPPDATA/ICSharpCode/ILSpy/dotnet-format-$DOTNET_FORMAT_VERSION"
1010
if [ ! -d "$DOTNET_PATH" ]; then
1111
echo "Downloading dotnet-format $DOTNET_FORMAT_VERSION..."
12-
dotnet tool install --tool-path "$DOTNET_PATH" dotnet-format --version "$DOTNET_FORMAT_VERSION" --add-source "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json"
12+
dotnet tool install --tool-path "$DOTNET_PATH" dotnet-format --version "$DOTNET_FORMAT_VERSION" --add-source "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json"
1313
fi
1414

1515
"$DOTNET_PATH/dotnet-format.exe" --version

ICSharpCode.BamlDecompiler/ICSharpCode.BamlDecompiler.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55

66
<SignAssembly>True</SignAssembly>
77
<AssemblyOriginatorKeyFile>..\ICSharpCode.Decompiler\ICSharpCode.Decompiler.snk</AssemblyOriginatorKeyFile>
@@ -14,7 +14,7 @@
1414

1515
<PropertyGroup>
1616
<PackageId>ICSharpCode.BamlDecompiler</PackageId>
17-
<PackageVersion>8.0.0.0-noversion</PackageVersion>
17+
<PackageVersion>10.0.0.0-noversion</PackageVersion>
1818
<Title>ILSpy BAML Decompiler</Title>
1919
<Authors>ILSpy Contributors</Authors>
2020
<PackageLicenseExpression>MIT</PackageLicenseExpression>
@@ -44,7 +44,7 @@
4444
<!-- https://devblogs.microsoft.com/nuget/enable-repeatable-package-restores-using-a-lock-file/ -->
4545
<PropertyGroup>
4646
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
47-
<RestoreLockedMode Condition="'$(GITHUB_ACTIONS)' == 'true'">true</RestoreLockedMode>
47+
<RestoreLockedMode>true</RestoreLockedMode>
4848
</PropertyGroup>
4949

5050
<ItemGroup>

ICSharpCode.BamlDecompiler/packages.lock.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"version": 2,
33
"dependencies": {
4-
"net8.0": {
4+
"net10.0": {
55
"Microsoft.Sbom.Targets": {
66
"type": "Direct",
77
"requested": "[3.1.0, )",

ICSharpCode.Decompiler.TestRunner/ICSharpCode.Decompiler.TestRunner.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net8.0</TargetFramework>
5+
<TargetFramework>net10.0</TargetFramework>
66
<Nullable>enable</Nullable>
77
</PropertyGroup>
88

ICSharpCode.Decompiler.Tests/Helpers/RoslynToolset.cs

Lines changed: 81 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,22 @@
1818

1919
using System;
2020
using System.Collections.Generic;
21+
using System.Diagnostics;
2122
using System.IO;
2223
using System.Linq;
2324
using System.Threading;
2425
using System.Threading.Tasks;
2526

26-
using ICSharpCode.Decompiler.Util;
27+
using ICSharpCode.Decompiler.Metadata;
2728

2829
using NuGet.Common;
2930
using NuGet.Packaging;
3031
using NuGet.Protocol;
3132
using NuGet.Protocol.Core.Types;
3233
using NuGet.Versioning;
3334

35+
using NUnit.Framework;
36+
3437
namespace ICSharpCode.Decompiler.Tests.Helpers
3538
{
3639
abstract class AbstractToolset
@@ -50,29 +53,45 @@ public AbstractToolset(string baseDir)
5053

5154
protected async Task FetchPackage(string packageName, string version, string sourcePath, string outputPath)
5255
{
56+
if (!Directory.Exists(Path.Combine(Roundtrip.RoundtripAssembly.TestDir, "nuget")))
57+
Assert.Fail("No nuget cache found!");
58+
5359
ILogger logger = NullLogger.Instance;
5460
CancellationToken cancellationToken = CancellationToken.None;
55-
using MemoryStream packageStream = new MemoryStream();
56-
57-
await resource.CopyNupkgToStreamAsync(
58-
packageName,
59-
NuGetVersion.Parse(version),
60-
packageStream,
61-
cache,
62-
logger,
63-
cancellationToken).ConfigureAwait(false);
64-
65-
using PackageArchiveReader packageReader = new PackageArchiveReader(packageStream);
66-
NuspecReader nuspecReader = await packageReader.GetNuspecReaderAsync(cancellationToken).ConfigureAwait(false);
67-
68-
var files = (await packageReader.GetFilesAsync(cancellationToken).ConfigureAwait(false)).ToArray();
69-
files = files.Where(f => f.StartsWith(sourcePath, StringComparison.OrdinalIgnoreCase)).ToArray();
70-
await packageReader.CopyFilesAsync(outputPath, files,
71-
(sourceFile, targetPath, fileStream) => {
72-
fileStream.CopyToFile(targetPath);
73-
return targetPath;
74-
},
75-
logger, cancellationToken).ConfigureAwait(false);
61+
string pathToPackage = Path.Combine(Roundtrip.RoundtripAssembly.TestDir, "nuget", $"{packageName}-{version}.nupkg");
62+
Stream packageStream;
63+
if (File.Exists(pathToPackage))
64+
{
65+
packageStream = File.OpenRead(pathToPackage);
66+
}
67+
else
68+
{
69+
packageStream = new MemoryStream();
70+
71+
await resource.CopyNupkgToStreamAsync(
72+
packageName,
73+
NuGetVersion.Parse(version),
74+
packageStream,
75+
cache,
76+
logger,
77+
cancellationToken).ConfigureAwait(false);
78+
79+
packageStream.Position = 0;
80+
}
81+
using (packageStream)
82+
{
83+
using PackageArchiveReader packageReader = new PackageArchiveReader(packageStream);
84+
NuspecReader nuspecReader = await packageReader.GetNuspecReaderAsync(cancellationToken).ConfigureAwait(false);
85+
86+
var files = (await packageReader.GetFilesAsync(cancellationToken).ConfigureAwait(false)).ToArray();
87+
files = files.Where(f => f.StartsWith(sourcePath, StringComparison.OrdinalIgnoreCase)).ToArray();
88+
await packageReader.CopyFilesAsync(outputPath, files,
89+
(sourceFile, targetPath, fileStream) => {
90+
fileStream.CopyToFile(targetPath);
91+
return targetPath;
92+
},
93+
logger, cancellationToken).ConfigureAwait(false);
94+
}
7695
}
7796
}
7897

@@ -145,4 +164,44 @@ public async Task Fetch()
145164

146165
public string GetVsWhere() => vswherePath;
147166
}
167+
168+
class RefAssembliesToolset : AbstractToolset
169+
{
170+
readonly Dictionary<string, string> installedFrameworks = new Dictionary<string, string> {
171+
{ "legacy", Path.Combine(Roundtrip.RoundtripAssembly.TestDir, "dotnet", "legacy") },
172+
{ "2.2.0", Path.Combine(Roundtrip.RoundtripAssembly.TestDir, "dotnet", "netcore-2.2") },
173+
};
174+
175+
public RefAssembliesToolset()
176+
: base(Path.Combine(AppContext.BaseDirectory, "netfx"))
177+
{
178+
}
179+
180+
public async Task Fetch(string version, string packageName = "Microsoft.NETCore.App.Ref", string sourcePath = "ref/net5.0")
181+
{
182+
string path = Path.Combine(baseDir, version, sourcePath);
183+
if (!Directory.Exists(path))
184+
{
185+
await FetchPackage(packageName, version, sourcePath, Path.Combine(baseDir, version)).ConfigureAwait(false);
186+
}
187+
188+
installedFrameworks.Add(RoslynToolset.SanitizeVersion(version), path);
189+
}
190+
191+
internal string GetPath(string targetFramework)
192+
{
193+
var (id, version) = UniversalAssemblyResolver.ParseTargetFramework(targetFramework);
194+
string path;
195+
if (id == TargetFrameworkIdentifier.NETFramework)
196+
{
197+
path = installedFrameworks["legacy"];
198+
}
199+
else
200+
{
201+
path = installedFrameworks[version.ToString(3)];
202+
}
203+
Debug.Assert(Path.Exists(path));
204+
return path;
205+
}
206+
}
148207
}

ICSharpCode.Decompiler.Tests/Helpers/Tester.VB.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,9 @@
1616
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
1717
// DEALINGS IN THE SOFTWARE.
1818
using System;
19-
using System.CodeDom.Compiler;
2019
using System.Collections.Generic;
21-
using System.Diagnostics;
2220
using System.IO;
2321
using System.Linq;
24-
using System.Text;
2522
using System.Text.RegularExpressions;
2623
using System.Threading.Tasks;
2724

@@ -49,27 +46,30 @@ public static async Task<CompilerResults> CompileVB(string sourceFileName, Compi
4946
CompilerResults results = new CompilerResults();
5047
results.PathToAssembly = outputFileName;
5148

52-
var (roslynVersion, languageVersion) = (flags & CompilerOptions.UseRoslynMask) switch {
53-
0 => ("legacy", "11"),
54-
CompilerOptions.UseRoslyn1_3_2 => ("1.3.2", "14"),
55-
CompilerOptions.UseRoslyn2_10_0 => ("2.10.0", "latest"),
56-
CompilerOptions.UseRoslyn3_11_0 => ("3.11.0", "latest"),
57-
_ => (roslynLatestVersion, flags.HasFlag(CompilerOptions.Preview) ? "preview" : "latest")
49+
bool targetNet40 = (flags & CompilerOptions.TargetNet40) != 0;
50+
51+
var (roslynVersion, languageVersion, targetFramework) = (flags & CompilerOptions.UseRoslynMask) switch {
52+
0 => ("legacy", "11", null),
53+
CompilerOptions.UseRoslyn1_3_2 => ("1.3.2", "14", null),
54+
CompilerOptions.UseRoslyn2_10_0 => ("2.10.0", "latest", targetNet40 ? null : ".NETCoreApp,Version=v2.2"),
55+
CompilerOptions.UseRoslyn3_11_0 => ("3.11.0", "latest", targetNet40 ? null : ".NETCoreApp,Version=v5.0"),
56+
_ => (roslynLatestVersion, flags.HasFlag(CompilerOptions.Preview) ? "preview" : "latest", targetNet40 ? null : ".NETCoreApp,Version=v10.0")
5857
};
5958

6059
var vbcPath = roslynToolset.GetVBCompiler(roslynVersion);
6160

6261
IEnumerable<string> references;
6362
string libPath;
64-
if ((flags & CompilerOptions.UseRoslynMask) != 0 && (flags & CompilerOptions.TargetNet40) == 0)
63+
if ((flags & CompilerOptions.UseRoslynMask) != 0 && targetFramework != null)
6564
{
65+
var coreRefAsmPath = RefAssembliesToolset.GetPath(targetFramework);
6666
references = coreDefaultReferences.Select(r => "-r:\"" + r + "\"");
6767
libPath = coreRefAsmPath;
6868
}
6969
else
7070
{
7171
references = defaultReferences.Select(r => "-r:\"" + r + "\"");
72-
libPath = RefAsmPath;
72+
libPath = RefAssembliesToolset.GetPath("legacy");
7373
}
7474
if (flags.HasFlag(CompilerOptions.ReferenceVisualBasic))
7575
{
@@ -121,7 +121,7 @@ public static async Task<CompilerResults> CompileVB(string sourceFileName, Compi
121121
var command = Cli.Wrap(vbcPath)
122122
.WithArguments($"{otherOptions}-libpath:\"{libPath}\" {string.Join(" ", references)} -out:\"{Path.GetFullPath(results.PathToAssembly)}\" {string.Join(" ", sourceFileNames.Select(fn => '"' + Path.GetFullPath(fn) + '"'))}")
123123
.WithValidation(CommandResultValidation.None);
124-
Console.WriteLine($"\"{command.TargetFilePath}\" {command.Arguments}");
124+
//Console.WriteLine($"\"{command.TargetFilePath}\" {command.Arguments}");
125125

126126
var result = await command.ExecuteBufferedAsync().ConfigureAwait(false);
127127

0 commit comments

Comments
 (0)