diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index f4e846d4..61451414 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -28,6 +28,7 @@ jobs:
6.x
7.x
8.x
+ 9.x
- name: Log dotnet info
run: dotnet --info
@@ -47,7 +48,7 @@ jobs:
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
- dotnet-version: '8.x'
+ dotnet-version: '9.x'
- name: Make repo pushable
env:
diff --git a/.github/workflows/publish_release.yml b/.github/workflows/publish_release.yml
index e7e62be3..847902e2 100644
--- a/.github/workflows/publish_release.yml
+++ b/.github/workflows/publish_release.yml
@@ -25,7 +25,7 @@ jobs:
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
- dotnet-version: '8.x'
+ dotnet-version: '9.x'
- name: Get Version
id: get_version
diff --git a/Directory.Build.props b/Directory.Build.props
index d21acaae..c965981d 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -4,7 +4,7 @@
2.13.0
2.13.0.0
- 25.1.2
+ 25.2.2
diff --git a/Harmony/Internal/Util/EmitterExtensions.cs b/Harmony/Internal/Util/EmitterExtensions.cs
index 83f24843..ff3e9686 100644
--- a/Harmony/Internal/Util/EmitterExtensions.cs
+++ b/Harmony/Internal/Util/EmitterExtensions.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
@@ -198,13 +198,18 @@ public static LocalBuilder GetLocal(this CecilILGenerator il, VariableDefinition
return loc;
}
+ // https://github.com/MonoMod/MonoMod/commit/2011243901351e69b6b5da89631e01bc8eb61da5
+ // https://github.com/dotnet/runtime/blob/f1332ab0d82ee0e21ca387cbd1c8a87c5dfa4906/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeLocalBuilder.cs
+ // In .NET 9, LocalBuilder is an abstract type, so we look for RuntimeLocalBuilder first.
+ private static readonly Type t_LocalBuilder =
+ Type.GetType("System.Reflection.Emit.RuntimeLocalBuilder") ?? typeof(LocalBuilder);
private static readonly ConstructorInfo c_LocalBuilder =
- typeof(LocalBuilder).GetConstructors(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance)
+ t_LocalBuilder.GetConstructors(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance)
.OrderByDescending(c => c.GetParameters().Length).First();
private static readonly FieldInfo f_LocalBuilder_position =
- typeof(LocalBuilder).GetField("position", BindingFlags.NonPublic | BindingFlags.Instance);
+ t_LocalBuilder.GetField("position", BindingFlags.NonPublic | BindingFlags.Instance);
private static readonly FieldInfo f_LocalBuilder_is_pinned =
- typeof(LocalBuilder).GetField("is_pinned", BindingFlags.NonPublic | BindingFlags.Instance);
+ t_LocalBuilder.GetField("is_pinned", BindingFlags.NonPublic | BindingFlags.Instance);
private static int c_LocalBuilder_params = c_LocalBuilder.GetParameters().Length;
}
}
diff --git a/HarmonyTests/HarmonyTests.csproj b/HarmonyTests/HarmonyTests.csproj
index c9c8065a..57c94e89 100644
--- a/HarmonyTests/HarmonyTests.csproj
+++ b/HarmonyTests/HarmonyTests.csproj
@@ -1,7 +1,7 @@
- net35;net452;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0
+ net35;net452;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0
true
latest
false
@@ -32,7 +32,7 @@
-
+
all
@@ -50,7 +50,7 @@
-
+