diff --git a/Harmony/Internal/PatchTools.cs b/Harmony/Internal/PatchTools.cs index 27a834b0..34a4f01c 100644 --- a/Harmony/Internal/PatchTools.cs +++ b/Harmony/Internal/PatchTools.cs @@ -90,17 +90,17 @@ internal static MethodBase GetOriginalMethod(this HarmonyMethod attr) switch (attr.methodType) { case MethodType.Normal: - if (attr.methodName is null) + if (string.IsNullOrEmpty(attr.methodName)) return null; return AccessTools.DeclaredMethod(attr.declaringType, attr.methodName, attr.argumentTypes); case MethodType.Getter: - if (attr.methodName is null) + if (string.IsNullOrEmpty(attr.methodName)) return AccessTools.DeclaredIndexerGetter(attr.declaringType, attr.argumentTypes); return AccessTools.DeclaredPropertyGetter(attr.declaringType, attr.methodName); case MethodType.Setter: - if (attr.methodName is null) + if (string.IsNullOrEmpty(attr.methodName)) return AccessTools.DeclaredIndexerSetter(attr.declaringType, attr.argumentTypes); return AccessTools.DeclaredPropertySetter(attr.declaringType, attr.methodName); @@ -113,14 +113,14 @@ internal static MethodBase GetOriginalMethod(this HarmonyMethod attr) .FirstOrDefault(); case MethodType.Enumerator: - if (attr.methodName is null) + if (string.IsNullOrEmpty(attr.methodName)) return null; var enumMethod = AccessTools.DeclaredMethod(attr.declaringType, attr.methodName, attr.argumentTypes); return AccessTools.EnumeratorMoveNext(enumMethod); #if NET45_OR_GREATER || NETSTANDARD || NETCOREAPP case MethodType.Async: - if (attr.methodName is null) + if (string.IsNullOrEmpty(attr.methodName)) return null; var asyncMethod = AccessTools.DeclaredMethod(attr.declaringType, attr.methodName, attr.argumentTypes); return AccessTools.AsyncMoveNext(asyncMethod); diff --git a/Harmony/Tools/AccessTools.cs b/Harmony/Tools/AccessTools.cs index 303b672e..3a5593a6 100644 --- a/Harmony/Tools/AccessTools.cs +++ b/Harmony/Tools/AccessTools.cs @@ -149,9 +149,9 @@ public static FieldInfo DeclaredField(Type type, string name) FileLog.Debug("AccessTools.DeclaredField: type is null"); return null; } - if (name is null) + if (string.IsNullOrEmpty(name)) { - FileLog.Debug("AccessTools.DeclaredField: name is null"); + FileLog.Debug("AccessTools.DeclaredField: name is null/empty"); return null; } var fieldInfo = type.GetField(name, allDeclared); @@ -183,9 +183,9 @@ public static FieldInfo Field(Type type, string name) FileLog.Debug("AccessTools.Field: type is null"); return null; } - if (name is null) + if (string.IsNullOrEmpty(name)) { - FileLog.Debug("AccessTools.Field: name is null"); + FileLog.Debug("AccessTools.Field: name is null/empty"); return null; } var fieldInfo = FindIncludingBaseTypes(type, t => t.GetField(name, all)); @@ -234,9 +234,9 @@ public static PropertyInfo DeclaredProperty(Type type, string name) FileLog.Debug("AccessTools.DeclaredProperty: type is null"); return null; } - if (name is null) + if (string.IsNullOrEmpty(name)) { - FileLog.Debug("AccessTools.DeclaredProperty: name is null"); + FileLog.Debug("AccessTools.DeclaredProperty: name is null/empty"); return null; } var property = type.GetProperty(name, allDeclared); @@ -338,9 +338,9 @@ public static PropertyInfo Property(Type type, string name) FileLog.Debug("AccessTools.Property: type is null"); return null; } - if (name is null) + if (string.IsNullOrEmpty(name)) { - FileLog.Debug("AccessTools.Property: name is null"); + FileLog.Debug("AccessTools.Property: name is null/empty"); return null; } var property = FindIncludingBaseTypes(type, t => t.GetProperty(name, all)); @@ -446,9 +446,9 @@ public static MethodInfo DeclaredMethod(Type type, string name, Type[] parameter FileLog.Debug("AccessTools.DeclaredMethod: type is null"); return null; } - if (name is null) + if (string.IsNullOrEmpty(name)) { - FileLog.Debug("AccessTools.DeclaredMethod: name is null"); + FileLog.Debug("AccessTools.DeclaredMethod: name is null/empty"); return null; } MethodInfo result; @@ -495,9 +495,9 @@ public static MethodInfo Method(Type type, string name, Type[] parameters = null FileLog.Debug("AccessTools.Method: type is null"); return null; } - if (name is null) + if (string.IsNullOrEmpty(name)) { - FileLog.Debug("AccessTools.Method: name is null"); + FileLog.Debug("AccessTools.Method: name is null/empty"); return null; } MethodInfo result; @@ -857,9 +857,9 @@ public static Type Inner(Type type, string name) FileLog.Debug("AccessTools.Inner: type is null"); return null; } - if (name is null) + if (string.IsNullOrEmpty(name)) { - FileLog.Debug("AccessTools.Inner: name is null"); + FileLog.Debug("AccessTools.Inner: name is null/empty"); return null; } return FindIncludingBaseTypes(type, t => t.GetNestedType(name, all)); @@ -1722,7 +1722,6 @@ public static DelegateType MethodDelegate(string typeColonName, ob { var method = DeclaredMethod(typeColonName); return MethodDelegate(method, instance, virtualCall); - } /// Creates a delegate for a given delegate definition, attributed with []