Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.NET 9 Support #121

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}
6 changes: 3 additions & 3 deletions 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 Expand Up @@ -32,7 +32,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.3.2">
<PrivateAssets>all</PrivateAssets>
Expand All @@ -50,7 +50,7 @@
<!-- </ItemGroup>-->

<ItemGroup Condition="'$(TargetFrameworkIdentifier)'=='.NETCoreApp'">
<PackageReference Include="Lokad.ILPack" Version="0.1.7" PrivateAssets="all" />
<PackageReference Include="Lokad.ILPack" Version="0.2.0" PrivateAssets="all" />
</ItemGroup>

</Project>