Skip to content

Commit

Permalink
Support .NET 9
Browse files Browse the repository at this point in the history
  • Loading branch information
ds5678 committed Dec 12, 2024
1 parent 64fc33f commit 38d8ee7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
6.x
7.x
8.x
9.x
- name: Log dotnet info
run: dotnet --info
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<HarmonyXVersion>2.13.0</HarmonyXVersion>
<HarmonyXVersionFull>2.13.0.0</HarmonyXVersionFull>
<HarmonyXVersionSuffix></HarmonyXVersionSuffix>
<MonoModRuntimeDetour>25.1.2</MonoModRuntimeDetour>
<MonoModRuntimeDetour>25.2.2</MonoModRuntimeDetour>
</PropertyGroup>

</Project>
13 changes: 9 additions & 4 deletions Harmony/Internal/Util/EmitterExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
Expand Down Expand Up @@ -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;
}
}
2 changes: 1 addition & 1 deletion HarmonyTests/HarmonyTests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net35;net452;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net35;net452;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<IsPackable>false</IsPackable>
Expand Down

0 comments on commit 38d8ee7

Please sign in to comment.