1.6 to main #1

Merged
HRiggs merged 5 commits from rimworld-1.6 into main 2026-10-02 06:26:54 +00:00
3 changed files with 13 additions and 3 deletions
Showing only changes of commit 50f4d5378b - Show all commits
Binary file not shown.
Binary file not shown.
@@ -7,7 +7,9 @@ using System.Collections.Concurrent;
using System.Diagnostics;
using System.Linq;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Security;
using Verse;
namespace FisheryLib.FunctionPointers;
@@ -64,12 +66,18 @@ public abstract class MethodFactory(MethodInfo[] methods, string namePrefix, boo
=> type.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.DeclaredOnly)
.Where(predicate).ToArray();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected static bool UseReferenceIdentity(Type type)
=> !type.IsValueType && typeof(Thing).IsAssignableFrom(type);
public new class Equals(Type type, string dynamicMethodNamePrefix, bool byRef)
: MethodFactory(GetMethodInfoArraySafely(type), dynamicMethodNamePrefix, byRef)
{
protected override MethodInfo GetOrMakeMethodForType(Type type)
=> GetSpecializedMethod(type)
?? (type.IsAssignableTo(typeof(IEquatable<>), type)
?? (UseReferenceIdentity(type)
? GetGeneric(nameof(FunctionPointers.Equals.Methods.Reference), type)
: type.IsAssignableTo(typeof(IEquatable<>), type)
? GetGeneric(type.IsValueType
? nameof(FunctionPointers.Equals.Methods.EquatableValueType)
: nameof(FunctionPointers.Equals.Methods.EquatableReferenceType), type)
@@ -235,7 +243,9 @@ public abstract class MethodFactory(MethodInfo[] methods, string namePrefix, boo
{
protected override MethodInfo GetOrMakeMethodForType(Type type)
=> GetSpecializedMethod(type)
?? (type.IsNullable(out var genericArgument)
?? (UseReferenceIdentity(type)
? GetGeneric(nameof(FunctionPointers.GetHashCode.Methods.Reference), type)
: type.IsNullable(out var genericArgument)
&& genericArgument.IsAssignableTo(typeof(IEquatable<>), genericArgument)
? GetGeneric(nameof(FunctionPointers.GetHashCode.Methods.Nullable), genericArgument)
: type.IsEnum