Skip to content

Commit 68ccd0e

Browse files
ds5678ManlyMarco
authored andcommitted
Support .NET 9
1 parent d803c74 commit 68ccd0e

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

.github/workflows/build.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
6.x
2929
7.x
3030
8.x
31+
9.x
3132
3233
- name: Log dotnet info
3334
run: dotnet --info
@@ -47,7 +48,7 @@ jobs:
4748
- name: Setup dotnet
4849
uses: actions/setup-dotnet@v4
4950
with:
50-
dotnet-version: '8.x'
51+
dotnet-version: '9.x'
5152

5253
- name: Make repo pushable
5354
env:

.github/workflows/publish_release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Setup dotnet
2626
uses: actions/setup-dotnet@v4
2727
with:
28-
dotnet-version: '8.x'
28+
dotnet-version: '9.x'
2929

3030
- name: Get Version
3131
id: get_version

Directory.Build.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<HarmonyXVersion>2.13.0</HarmonyXVersion>
55
<HarmonyXVersionFull>2.13.0.0</HarmonyXVersionFull>
66
<HarmonyXVersionSuffix></HarmonyXVersionSuffix>
7-
<MonoModRuntimeDetour>25.1.2</MonoModRuntimeDetour>
7+
<MonoModRuntimeDetour>25.2.2</MonoModRuntimeDetour>
88
</PropertyGroup>
99

1010
</Project>

Harmony/Internal/Util/EmitterExtensions.cs

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Reflection;
@@ -198,13 +198,18 @@ public static LocalBuilder GetLocal(this CecilILGenerator il, VariableDefinition
198198
return loc;
199199
}
200200

201+
// https://github.com/MonoMod/MonoMod/commit/2011243901351e69b6b5da89631e01bc8eb61da5
202+
// https://github.com/dotnet/runtime/blob/f1332ab0d82ee0e21ca387cbd1c8a87c5dfa4906/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeLocalBuilder.cs
203+
// In .NET 9, LocalBuilder is an abstract type, so we look for RuntimeLocalBuilder first.
204+
private static readonly Type t_LocalBuilder =
205+
Type.GetType("System.Reflection.Emit.RuntimeLocalBuilder") ?? typeof(LocalBuilder);
201206
private static readonly ConstructorInfo c_LocalBuilder =
202-
typeof(LocalBuilder).GetConstructors(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance)
207+
t_LocalBuilder.GetConstructors(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance)
203208
.OrderByDescending(c => c.GetParameters().Length).First();
204209
private static readonly FieldInfo f_LocalBuilder_position =
205-
typeof(LocalBuilder).GetField("position", BindingFlags.NonPublic | BindingFlags.Instance);
210+
t_LocalBuilder.GetField("position", BindingFlags.NonPublic | BindingFlags.Instance);
206211
private static readonly FieldInfo f_LocalBuilder_is_pinned =
207-
typeof(LocalBuilder).GetField("is_pinned", BindingFlags.NonPublic | BindingFlags.Instance);
212+
t_LocalBuilder.GetField("is_pinned", BindingFlags.NonPublic | BindingFlags.Instance);
208213
private static int c_LocalBuilder_params = c_LocalBuilder.GetParameters().Length;
209214
}
210215
}

HarmonyTests/HarmonyTests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net35;net452;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
4+
<TargetFrameworks>net35;net452;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
55
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
66
<LangVersion>latest</LangVersion>
77
<IsPackable>false</IsPackable>

0 commit comments

Comments
 (0)