diff --git a/Harmony/Internal/PatchTools.cs b/Harmony/Internal/PatchTools.cs
index 32028975..1a2df22d 100644
--- a/Harmony/Internal/PatchTools.cs
+++ b/Harmony/Internal/PatchTools.cs
@@ -87,7 +87,7 @@ internal static MethodBase GetOriginalMethod(this HarmonyMethod attr)
var enumMethod = AccessTools.DeclaredMethod(attr.declaringType, attr.methodName, attr.argumentTypes);
return AccessTools.EnumeratorMoveNext(enumMethod);
-#if NET40_OR_GREATER
+#if NET45_OR_GREATER
case MethodType.Async:
if (attr.methodName is null)
return null;
diff --git a/Harmony/Public/Attributes.cs b/Harmony/Public/Attributes.cs
index 0cf9cadf..edd077ac 100644
--- a/Harmony/Public/Attributes.cs
+++ b/Harmony/Public/Attributes.cs
@@ -17,10 +17,10 @@ public enum MethodType
Constructor,
/// This is a static constructor
StaticConstructor,
- /// This targets the MoveNext method of the enumerator result
+ /// This targets the MoveNext method of the enumerator result, that actually contains the method's implementation
Enumerator,
-#if NET40_OR_GREATER
- /// This targets the MoveNext method of the async state machine
+#if NET45_OR_GREATER
+ /// This targets the MoveNext method of the async state machine, that actually contains the method's implementation
Async
#endif
}
diff --git a/Harmony/Tools/AccessTools.cs b/Harmony/Tools/AccessTools.cs
index 017bae7e..e22b9e89 100644
--- a/Harmony/Tools/AccessTools.cs
+++ b/Harmony/Tools/AccessTools.cs
@@ -467,9 +467,9 @@ public static MethodInfo Method(string typeColonName, Type[] parameters = null,
return Method(info.type, info.name, parameters, generics);
}
- /// Gets the method of an enumerator method
+ /// Gets the method of an enumerator method
/// Enumerator method that creates the enumerator
- /// The internal method of the enumerator or null if no valid enumerator is detected
+ /// The internal method of the enumerator or null if no valid enumerator is detected
public static MethodInfo EnumeratorMoveNext(MethodBase method)
{
if (method is null)
@@ -499,10 +499,10 @@ public static MethodInfo EnumeratorMoveNext(MethodBase method)
return Method(type, nameof(IEnumerator.MoveNext));
}
-#if NET40_OR_GREATER
- /// Gets the method of an async method's state machine
+#if NET45_OR_GREATER
+ /// Gets the method of an async method's state machine
/// Async method that creates the state machine internally
- /// The internal method of the async state machine or null if no valid async method is detected
+ /// The internal method of the async state machine or null if no valid async method is detected
public static MethodInfo AsyncMoveNext(MethodBase method)
{
if (method is null)
@@ -512,15 +512,15 @@ public static MethodInfo AsyncMoveNext(MethodBase method)
}
var asyncAttribute = method.GetCustomAttribute();
- if (asyncAttribute == null)
+ if (asyncAttribute is null)
{
FileLog.Debug($"AccessTools.AsyncMoveNext: Could not find AsyncStateMachine for {method.FullDescription()}");
return null;
}
var asyncStateMachineType = asyncAttribute.StateMachineType;
- var asyncMethodBody = DeclaredMethod(asyncStateMachineType, "MoveNext");
- if (asyncMethodBody == null)
+ var asyncMethodBody = DeclaredMethod(asyncStateMachineType, nameof(IAsyncStateMachine.MoveNext));
+ if (asyncMethodBody is null)
{
FileLog.Debug($"AccessTools.AsyncMoveNext: Could not find async method body for {method.FullDescription()}");
return null;