From 66e16996a0f214db663c4c48637d1a66490b9a49 Mon Sep 17 00:00:00 2001 From: SokyranTheDragon <36712560+SokyranTheDragon@users.noreply.github.com> Date: Sun, 20 Oct 2024 00:10:00 +0200 Subject: [PATCH] Fix issues with MpCompatSyncFieldAttribute (#482) Fixes: - The field is accessed `AccessTools.Field` rather than `AccessTools.DeclaredField` - The thrown exception if the `field` is null is now `MissingFieldException` rather than `MissingMethodException` - The exception that's thrown if the `field` is null now uses `fieldName` rather than `field` in its message --- Source/MpCompatAttributes.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/MpCompatAttributes.cs b/Source/MpCompatAttributes.cs index e3e6901..8c195a0 100644 --- a/Source/MpCompatAttributes.cs +++ b/Source/MpCompatAttributes.cs @@ -468,9 +468,9 @@ public FieldInfo Field if (field != null) return field; - field = AccessTools.DeclaredField(Type, fieldName); + field = AccessTools.Field(Type, fieldName); if (field == null) - throw new MissingMethodException($"Couldn't find field {field} in type {Type}"); + throw new MissingFieldException($"Couldn't find field {fieldName} in type {Type}"); return field; }