fix error in heuristic rewriting

This commit is contained in:
Jesse Plamondon-Willard 2020-10-17 22:03:43 -04:00
parent e20d26adcf
commit 1cac389284
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
2 changed files with 5 additions and 1 deletions

View File

@ -7,6 +7,10 @@
* Migrated to Harmony 2.0 (see [_migrate to Harmony 2.0_](https://stardewvalleywiki.com/Modding:Migrate_to_Harmony_2.0) for more info).
-->
## Upcoming release
* For modders:
* Fixed error when heuristically rewriting a property for a type that no longer exists.
## 3.7.5
Released 16 October 2020 for Stardew Valley 1.4.1 or later.

View File

@ -68,7 +68,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters
private bool TryRewriteToProperty(ModuleDefinition module, Instruction instruction, FieldReference fieldRef, TypeDefinition declaringType, bool isRead)
{
// get equivalent property
PropertyDefinition property = declaringType.Properties.FirstOrDefault(p => p.Name == fieldRef.Name);
PropertyDefinition property = declaringType?.Properties.FirstOrDefault(p => p.Name == fieldRef.Name);
MethodDefinition method = isRead ? property?.GetMethod : property?.SetMethod;
if (method == null)
return false;