From 33dd351d6fba98bbcb13de0c3bb2c45bfc646c31 Mon Sep 17 00:00:00 2001 From: ElektroKill Date: Tue, 14 Nov 2023 21:35:13 +0100 Subject: [PATCH] Update to .NET 8 --- .github/workflows/build.yml | 6 +++--- DnSpyCommon.props | 9 ++++++--- DnSpyRoslyn.props | 2 +- Extensions/ILSpy.Decompiler/ICSharpCode.Decompiler | 2 +- Extensions/ILSpy.Decompiler/NRefactory | 2 +- Extensions/dnSpy.Debugger/Mono.Debugger.Soft | 2 +- .../Utilities/DotNetHelpers.cs | 7 +++---- .../dnSpy.Debugger.DotNet.CorDebug.csproj | 1 + .../InterpreterMessageException.cs | 7 ------- Extensions/dnSpy.Debugger/netcorefiles | 2 +- build.ps1 | 2 +- .../Documents/TreeView/Resources/Deserializer.cs | 2 +- .../TreeView/Resources/SerializationUtilities.cs | 7 +++++-- .../Resources/SerializedImageListStreamerUtilities.cs | 2 ++ .../TreeView/Resources/SerializedResourceElementNode.cs | 4 ++-- .../Hex/NormalizedHexSpanCollection.cs | 4 ++++ 16 files changed, 33 insertions(+), 28 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 480fd1a758..0b161f4128 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,10 +27,10 @@ jobs: build-dir: net48 - platform: net-x86 package-name: net-win32 - build-dir: net6.0-windows\win-x86\publish + build-dir: net8.0-windows\win-x86\publish - platform: net-x64 package-name: net-win64 - build-dir: net6.0-windows\win-x64\publish + build-dir: net8.0-windows\win-x64\publish steps: - uses: actions/checkout@v4.1.1 @@ -39,7 +39,7 @@ jobs: - uses: actions/setup-dotnet@v3.2.0 with: - dotnet-version: 6.0.x + dotnet-version: 8.0.x dotnet-quality: ga - uses: microsoft/setup-msbuild@v1.3.1 diff --git a/DnSpyCommon.props b/DnSpyCommon.props index 776ac34584..9e1a3780ab 100644 --- a/DnSpyCommon.props +++ b/DnSpyCommon.props @@ -6,7 +6,7 @@ - .github/workflows/build.yml - DnSpyRoslyn.props NOTE: Update the ABOVE files when TargetFrameworks is updated --> - net48;net6.0-windows + net48;net8.0-windows false false false @@ -35,11 +35,13 @@ 6.4.1.0 v6.4.1 + + false Copyright (C) 2014-2020 de4dot@gmail.com - NU1701;AD0001;WFAC010 + NU1701;AD0001;WFAC010;NETSDK1189 $(NoWarn);CS8767 @@ -54,8 +56,9 @@ 13.0.3 5.0.1 4.7.0 - 7.0.0 + 8.0.0 6.7.0 + 8.0.452401 diff --git a/DnSpyRoslyn.props b/DnSpyRoslyn.props index 5bb0268b31..8326de854e 100644 --- a/DnSpyRoslyn.props +++ b/DnSpyRoslyn.props @@ -3,7 +3,7 @@ - netstandard2.0;net6.0-windows + netstandard2.0;net8.0-windows diff --git a/Extensions/ILSpy.Decompiler/ICSharpCode.Decompiler b/Extensions/ILSpy.Decompiler/ICSharpCode.Decompiler index fec42c8fa7..73e800110a 160000 --- a/Extensions/ILSpy.Decompiler/ICSharpCode.Decompiler +++ b/Extensions/ILSpy.Decompiler/ICSharpCode.Decompiler @@ -1 +1 @@ -Subproject commit fec42c8fa7d95e33332d7a6645c97a710499b12b +Subproject commit 73e800110a2b5b3d3cf40ba7248887928f742bea diff --git a/Extensions/ILSpy.Decompiler/NRefactory b/Extensions/ILSpy.Decompiler/NRefactory index 32e5593384..967baef318 160000 --- a/Extensions/ILSpy.Decompiler/NRefactory +++ b/Extensions/ILSpy.Decompiler/NRefactory @@ -1 +1 @@ -Subproject commit 32e5593384d3db9b14fc21637dfdd5ed7d2be0a7 +Subproject commit 967baef318e037939349dcd2db3907d491e99512 diff --git a/Extensions/dnSpy.Debugger/Mono.Debugger.Soft b/Extensions/dnSpy.Debugger/Mono.Debugger.Soft index 55b84b9032..ad1bcfbfb4 160000 --- a/Extensions/dnSpy.Debugger/Mono.Debugger.Soft +++ b/Extensions/dnSpy.Debugger/Mono.Debugger.Soft @@ -1 +1 @@ -Subproject commit 55b84b9032eaac91cc52179742968d5ae3ca22fb +Subproject commit ad1bcfbfb4f6aa0301ddcd95a4ffbc85ba8f1ed8 diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Utilities/DotNetHelpers.cs b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Utilities/DotNetHelpers.cs index bbfbcb7e29..8f141971f1 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Utilities/DotNetHelpers.cs +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/Utilities/DotNetHelpers.cs @@ -129,18 +129,17 @@ static bool TryGetInstallLocationFromRegistry(string regPath, [NotNullWhen(true) } public static string GetDebugShimFilename(int bitness) { -#if NETFRAMEWORK + var filename = FileUtilities.GetNativeDllFilename("dbgshim"); var basePath = Contracts.App.AppDirectories.BinDirectory; +#if NETFRAMEWORK basePath = Path.Combine(basePath, "debug", "core"); - var filename = FileUtilities.GetNativeDllFilename("dbgshim"); switch (bitness) { case 32: return Path.Combine(basePath, "x86", filename); case 64: return Path.Combine(basePath, "x64", filename); default: throw new ArgumentOutOfRangeException(nameof(bitness)); } #elif NET - var filename = FileUtilities.GetNativeDllFilename("dbgshim"); - return Path.Combine(Path.GetDirectoryName(typeof(void).Assembly.Location)!, filename); + return Path.Combine(basePath, "runtimes", RuntimeInformation.RuntimeIdentifier, "native", filename); #else #error Unknown target framework #endif diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/dnSpy.Debugger.DotNet.CorDebug.csproj b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/dnSpy.Debugger.DotNet.CorDebug.csproj index 50f7e8a8dd..cbcb7eb491 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/dnSpy.Debugger.DotNet.CorDebug.csproj +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.CorDebug/dnSpy.Debugger.DotNet.CorDebug.csproj @@ -65,6 +65,7 @@ + diff --git a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.Interpreter/InterpreterMessageException.cs b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.Interpreter/InterpreterMessageException.cs index 96503eb142..9bdec86652 100644 --- a/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.Interpreter/InterpreterMessageException.cs +++ b/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.Interpreter/InterpreterMessageException.cs @@ -38,12 +38,5 @@ public InterpreterMessageException(string message) : base(message) { } /// Error message /// Other exception public InterpreterMessageException(string message, Exception innerException) : base(message, innerException) { } - - /// - /// Constructor - /// - /// - /// - protected InterpreterMessageException(SerializationInfo info, StreamingContext context) : base(info, context) { } } } diff --git a/Extensions/dnSpy.Debugger/netcorefiles b/Extensions/dnSpy.Debugger/netcorefiles index 0ec96bc4ad..4a6e9da169 160000 --- a/Extensions/dnSpy.Debugger/netcorefiles +++ b/Extensions/dnSpy.Debugger/netcorefiles @@ -1 +1 @@ -Subproject commit 0ec96bc4ad3645b282247adc0cd31f7fe9e9761d +Subproject commit 4a6e9da1697119d10cb76b45aa320e66728cefc9 diff --git a/build.ps1 b/build.ps1 index 378629e3d4..e127793b94 100644 --- a/build.ps1 +++ b/build.ps1 @@ -6,7 +6,7 @@ param( $ErrorActionPreference = 'Stop' $netframework_tfm = 'net48' -$net_tfm = 'net6.0-windows' +$net_tfm = 'net8.0-windows' $configuration = 'Release' $net_baseoutput = "dnSpy\dnSpy\bin\$configuration" $apphostpatcher_dir = "Build\AppHostPatcher" diff --git a/dnSpy/dnSpy.Contracts.DnSpy/Documents/TreeView/Resources/Deserializer.cs b/dnSpy/dnSpy.Contracts.DnSpy/Documents/TreeView/Resources/Deserializer.cs index 263bfb0b6d..9bd849872a 100644 --- a/dnSpy/dnSpy.Contracts.DnSpy/Documents/TreeView/Resources/Deserializer.cs +++ b/dnSpy/dnSpy.Contracts.DnSpy/Documents/TreeView/Resources/Deserializer.cs @@ -87,9 +87,9 @@ public DontDeserializeType(SerializationInfo info, StreamingContext context) { } public static Dictionary Deserialize(string asmName, string typeName, byte[] data) { +#pragma warning disable SYSLIB0011 var fmt = new BinaryFormatter(); fmt.Binder = new MyBinder(asmName, typeName); -#pragma warning disable SYSLIB0011 var obj = fmt.Deserialize(new MemoryStream(data)) as DeserializedType; #pragma warning restore SYSLIB0011 Debug2.Assert(obj is not null); diff --git a/dnSpy/dnSpy.Contracts.DnSpy/Documents/TreeView/Resources/SerializationUtilities.cs b/dnSpy/dnSpy.Contracts.DnSpy/Documents/TreeView/Resources/SerializationUtilities.cs index e9dfbae570..3b000447eb 100644 --- a/dnSpy/dnSpy.Contracts.DnSpy/Documents/TreeView/Resources/SerializationUtilities.cs +++ b/dnSpy/dnSpy.Contracts.DnSpy/Documents/TreeView/Resources/SerializationUtilities.cs @@ -67,12 +67,15 @@ static ResourceElement CreateSerializedImage(Stream stream, string filename) { /// /// Data /// - public static byte[] Serialize(object obj) { + public static byte[] Serialize(object? obj) { + if (obj is null) + return Array.Empty(); + //TODO: The asm names of the saved types are saved in the serialized data. If the current // module is eg. a .NET 2.0 asm, you should replace the versions from 4.0.0.0 to 2.0.0.0. +#pragma warning disable SYSLIB0011 var formatter = new BinaryFormatter(); var outStream = new MemoryStream(); -#pragma warning disable SYSLIB0011 formatter.Serialize(outStream, obj); #pragma warning restore SYSLIB0011 return outStream.ToArray(); diff --git a/dnSpy/dnSpy.Contracts.DnSpy/Documents/TreeView/Resources/SerializedImageListStreamerUtilities.cs b/dnSpy/dnSpy.Contracts.DnSpy/Documents/TreeView/Resources/SerializedImageListStreamerUtilities.cs index d7641656d6..f8e60721e2 100644 --- a/dnSpy/dnSpy.Contracts.DnSpy/Documents/TreeView/Resources/SerializedImageListStreamerUtilities.cs +++ b/dnSpy/dnSpy.Contracts.DnSpy/Documents/TreeView/Resources/SerializedImageListStreamerUtilities.cs @@ -125,12 +125,14 @@ public static string CheckCanUpdateData(ModuleDef? module, ResourceElement newRe /// public static ImageListOptions ReadImageData(byte[] imageData) { var imageList = new ImageList(); +#pragma warning disable SYSLIB0050 var info = new SerializationInfo(typeof(ImageListStreamer), new FormatterConverter()); info.AddValue("Data", imageData); var ctor = typeof(ImageListStreamer).GetConstructor(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, new Type[] { typeof(SerializationInfo), typeof(StreamingContext) }, null); if (ctor is null) throw new InvalidOperationException(); var streamer = (ImageListStreamer)ctor.Invoke(new object[] { info, new StreamingContext(StreamingContextStates.All) }); +#pragma warning restore SYSLIB0050 imageList.ImageStream = streamer; var opts = new ImageListOptions(); diff --git a/dnSpy/dnSpy.Contracts.DnSpy/Documents/TreeView/Resources/SerializedResourceElementNode.cs b/dnSpy/dnSpy.Contracts.DnSpy/Documents/TreeView/Resources/SerializedResourceElementNode.cs index 50acb6a645..3b77e53eba 100644 --- a/dnSpy/dnSpy.Contracts.DnSpy/Documents/TreeView/Resources/SerializedResourceElementNode.cs +++ b/dnSpy/dnSpy.Contracts.DnSpy/Documents/TreeView/Resources/SerializedResourceElementNode.cs @@ -97,15 +97,15 @@ public void Deserialize() { var binaryResourceData = ((BinaryResourceData)ResourceElement.ResourceData); var serializedData = binaryResourceData.Data; if (binaryResourceData.Format == SerializationFormat.BinaryFormatter) { +#pragma warning disable SYSLIB0011 var formatter = new BinaryFormatter(); try { -#pragma warning disable SYSLIB0011 deserializedData = formatter.Deserialize(new MemoryStream(serializedData)); -#pragma warning restore SYSLIB0011 } catch { return; } +#pragma warning restore SYSLIB0011 } else if (binaryResourceData.Format == SerializationFormat.TypeConverterByteArray) { try { diff --git a/dnSpy/dnSpy.Contracts.DnSpy/Hex/NormalizedHexSpanCollection.cs b/dnSpy/dnSpy.Contracts.DnSpy/Hex/NormalizedHexSpanCollection.cs index cc37584c14..e0d96e5cd8 100644 --- a/dnSpy/dnSpy.Contracts.DnSpy/Hex/NormalizedHexSpanCollection.cs +++ b/dnSpy/dnSpy.Contracts.DnSpy/Hex/NormalizedHexSpanCollection.cs @@ -31,7 +31,11 @@ public sealed class NormalizedHexSpanCollection : ReadOnlyCollection, I /// /// An empty collection /// +#if NETFRAMEWORK public static readonly NormalizedHexSpanCollection Empty = new NormalizedHexSpanCollection(); +#else + public new static readonly NormalizedHexSpanCollection Empty = new NormalizedHexSpanCollection(); +#endif /// /// Constructor