From 8eb7dbe803498b6e0838749b2f83b9df2107cbe8 Mon Sep 17 00:00:00 2001 From: Andrii Kurdiumov Date: Fri, 1 May 2026 11:29:51 +0200 Subject: [PATCH] Modernize examples - Use .NET 10, since .NET 6 is not by default on new computer anymore and it's not supported - You cannot save to drive C: in Windows 11 by default. Maybe just my computer, who knowns. Anyway, that make examples Windows only, which is unnecessary - Example3 crashed, since invariant changed, and you should pass empty string as locale. --- Examples/Example2.cs | 2 +- Examples/Example3.cs | 4 ++-- Examples/Example4.cs | 2 +- Examples/Example5.cs | 2 +- Examples/Example6.cs | 2 +- Examples/Examples.csproj | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Examples/Example2.cs b/Examples/Example2.cs index 97926d504..8d237c426 100644 --- a/Examples/Example2.cs +++ b/Examples/Example2.cs @@ -56,7 +56,7 @@ public static void Run() { body.Instructions.Add(OpCodes.Ret.ToInstruction()); // Save the assembly to a file on disk - mod.Write(@"C:\saved-assembly.dll"); + mod.Write(@"saved-assembly.dll"); } } } diff --git a/Examples/Example3.cs b/Examples/Example3.cs index 30e919d74..23c74ed32 100644 --- a/Examples/Example3.cs +++ b/Examples/Example3.cs @@ -28,7 +28,7 @@ public static void Run() { mod.Kind = ModuleKind.Console; // Add the module to an assembly - var asm = new AssemblyDefUser("MyAssembly", new Version(1, 2, 3, 4), null, null); + var asm = new AssemblyDefUser("MyAssembly", new Version(1, 2, 3, 4), null, UTF8String.Empty); asm.Modules.Add(mod); // Add a .NET resource @@ -72,7 +72,7 @@ public static void Run() { epBody.Instructions.Add(OpCodes.Ret.ToInstruction()); // Save the assembly to a file on disk - mod.Write(@"C:\saved-assembly.exe"); + mod.Write(@"saved-assembly.exe"); } } } diff --git a/Examples/Example4.cs b/Examples/Example4.cs index a2dd34005..5a96ec72a 100644 --- a/Examples/Example4.cs +++ b/Examples/Example4.cs @@ -63,7 +63,7 @@ namespace dnlib.Examples { public class Example4 { public static void Run() { // This is the file that will be created - string newFileName = @"C:\ctor-test.exe"; + string newFileName = @"ctor-test.exe"; // Create the module var mod = new ModuleDefUser("ctor-test", Guid.NewGuid(), diff --git a/Examples/Example5.cs b/Examples/Example5.cs index 8116fe53f..eab6580c8 100644 --- a/Examples/Example5.cs +++ b/Examples/Example5.cs @@ -8,7 +8,7 @@ namespace dnlib.Examples { /// public class Example5 { public static void Run() { - string sectionFileName = @"c:\section{0}.bin"; + string sectionFileName = @"section{0}.bin"; // Open the current mscorlib var mod = ModuleDefMD.Load(typeof(int).Module); diff --git a/Examples/Example6.cs b/Examples/Example6.cs index d92add484..d2f54b3a0 100644 --- a/Examples/Example6.cs +++ b/Examples/Example6.cs @@ -16,7 +16,7 @@ public class Example6 { public static void Run() => new Example6().DoIt(); void DoIt() { - string destFileName = @"c:\output.dll"; + string destFileName = @"output.dll"; // Open the current module var mod = ModuleDefMD.Load(typeof(Example6).Module); diff --git a/Examples/Examples.csproj b/Examples/Examples.csproj index 3bd7f6613..80cb698f1 100644 --- a/Examples/Examples.csproj +++ b/Examples/Examples.csproj @@ -1,7 +1,7 @@ - net6.0;net45 + net10.0;net45 Exe false latest