fix build errors on Linux

This commit is contained in:
Jesse Plamondon-Willard 2021-09-02 21:24:10 -04:00
parent 0ce8939988
commit 169ce01810
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
3 changed files with 3 additions and 3 deletions

View File

@ -56,7 +56,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Finders
if (this.MethodNames.Any())
{
MethodReference methodRef = RewriteHelper.AsMethodReference(instruction);
if (methodRef is not null && methodRef.DeclaringType.FullName == this.FullTypeName && this.MethodNames.Contains(methodRef.Name))
if (methodRef != null && methodRef.DeclaringType.FullName == this.FullTypeName && this.MethodNames.Contains(methodRef.Name))
{
string eventName = methodRef.Name.Split(new[] { '_' }, 2)[1];
this.MethodNames.Remove($"add_{eventName}");

View File

@ -50,7 +50,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Finders
if (this.FieldNames.Any())
{
FieldReference fieldRef = RewriteHelper.AsFieldReference(instruction);
if (fieldRef is not null && fieldRef.DeclaringType.FullName == this.FullTypeName && this.FieldNames.Contains(fieldRef.Name))
if (fieldRef != null && fieldRef.DeclaringType.FullName == this.FullTypeName && this.FieldNames.Contains(fieldRef.Name))
{
this.FieldNames.Remove(fieldRef.Name);

View File

@ -34,7 +34,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters
public override bool Handle(ModuleDefinition module, TypeReference type, Action<TypeReference> replaceWith)
{
// detect Harmony
if (type.Scope is not AssemblyNameReference { Name: "0Harmony" } scope)
if (!(type.Scope is AssemblyNameReference scope) || scope.Name != "0Harmony")
return false;
// rewrite Harmony 1.x type to Harmony 2.0 type