Skip to content

Commit

Permalink
Adapts style and requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Banane9 committed Mar 22, 2023
1 parent e2296ce commit b329cbc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Harmony/Internal/PatchTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions Harmony/Public/Attributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ public enum MethodType
Constructor,
/// <summary>This is a static constructor</summary>
StaticConstructor,
/// <summary>This targets the MoveNext method of the enumerator result</summary>
/// <summary>This targets the MoveNext method of the enumerator result, that actually contains the method's implementation</summary>
Enumerator,
#if NET40_OR_GREATER
/// <summary>This targets the MoveNext method of the async state machine</summary>
#if NET45_OR_GREATER
/// <summary>This targets the MoveNext method of the async state machine, that actually contains the method's implementation</summary>
Async
#endif
}
Expand Down
16 changes: 8 additions & 8 deletions Harmony/Tools/AccessTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,9 @@ public static MethodInfo Method(string typeColonName, Type[] parameters = null,
return Method(info.type, info.name, parameters, generics);
}

/// <summary>Gets the <see cref="IEnumerator.MoveNext" /> method of an enumerator method</summary>
/// <summary>Gets the <see cref="IEnumerator.MoveNext"/> method of an enumerator method</summary>
/// <param name="method">Enumerator method that creates the enumerator <see cref="IEnumerator" /></param>
/// <returns>The internal <see cref="IEnumerator.MoveNext" /> method of the enumerator or <b>null</b> if no valid enumerator is detected</returns>
/// <returns>The internal <see cref="IEnumerator.MoveNext"/> method of the enumerator or <b>null</b> if no valid enumerator is detected</returns>
public static MethodInfo EnumeratorMoveNext(MethodBase method)
{
if (method is null)
Expand Down Expand Up @@ -499,10 +499,10 @@ public static MethodInfo EnumeratorMoveNext(MethodBase method)
return Method(type, nameof(IEnumerator.MoveNext));
}

#if NET40_OR_GREATER
/// <summary>Gets the <see cref="IAsyncStateMachine.MoveNext" /> method of an async method's state machine</summary>
#if NET45_OR_GREATER
/// <summary>Gets the <see cref="IAsyncStateMachine.MoveNext"/> method of an async method's state machine</summary>
/// <param name="method">Async method that creates the state machine internally</param>
/// <returns>The internal <see cref="IAsyncStateMachine.MoveNext" /> method of the async state machine or <b>null</b> if no valid async method is detected</returns>
/// <returns>The internal <see cref="IAsyncStateMachine.MoveNext"/> method of the async state machine or <b>null</b> if no valid async method is detected</returns>
public static MethodInfo AsyncMoveNext(MethodBase method)
{
if (method is null)
Expand All @@ -512,15 +512,15 @@ public static MethodInfo AsyncMoveNext(MethodBase method)
}

var asyncAttribute = method.GetCustomAttribute<AsyncStateMachineAttribute>();
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;
Expand Down

0 comments on commit b329cbc

Please sign in to comment.