Skip to content

Commit

Permalink
Fix issues with MpCompatSyncFieldAttribute (#482)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
SokyranTheDragon authored Oct 19, 2024
1 parent e5edff6 commit 66e1699
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Source/MpCompatAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 66e1699

Please sign in to comment.