Skip to content

Commit

Permalink
Move AsyncMethodBuilder.SetStateMachine to non-generic (#24403)
Browse files Browse the repository at this point in the history
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
  • Loading branch information
benaadams authored and marek-safar committed May 6, 2019
1 parent f60a397 commit 3bb7f82
Showing 1 changed file with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -354,22 +354,7 @@ public void Start<TStateMachine>(ref TStateMachine stateMachine) where TStateMac
/// <exception cref="System.ArgumentNullException">The <paramref name="stateMachine"/> argument was null (Nothing in Visual Basic).</exception>
/// <exception cref="System.InvalidOperationException">The builder is incorrectly initialized.</exception>
public void SetStateMachine(IAsyncStateMachine stateMachine)
{
if (stateMachine == null)
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.stateMachine);
}

if (m_task != null)
{
ThrowHelper.ThrowInvalidOperationException(ExceptionResource.AsyncMethodBuilder_InstanceNotInitialized);
}

// SetStateMachine was originally needed in order to store the boxed state machine reference into
// the boxed copy. Now that a normal box is no longer used, SetStateMachine is also legacy. We need not
// do anything here, and thus assert to ensure we're not calling this from our own implementations.
Debug.Fail("SetStateMachine should not be used.");
}
=> AsyncMethodBuilderCore.SetStateMachine(stateMachine, m_task);

/// <summary>
/// Schedules the specified state machine to be pushed forward when the specified awaiter completes.
Expand Down Expand Up @@ -1047,6 +1032,24 @@ public static void Start<TStateMachine>(ref TStateMachine stateMachine) where TS
}
}

public static void SetStateMachine(IAsyncStateMachine stateMachine, Task task)
{
if (stateMachine == null)
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.stateMachine);
}

if (task != null)
{
ThrowHelper.ThrowInvalidOperationException(ExceptionResource.AsyncMethodBuilder_InstanceNotInitialized);
}

// SetStateMachine was originally needed in order to store the boxed state machine reference into
// the boxed copy. Now that a normal box is no longer used, SetStateMachine is also legacy. We need not
// do anything here, and thus assert to ensure we're not calling this from our own implementations.
Debug.Fail("SetStateMachine should not be used.");
}

#if !CORERT
/// <summary>Gets whether we should be tracking async method completions for eventing.</summary>
internal static bool TrackAsyncMethodCompletion
Expand Down

0 comments on commit 3bb7f82

Please sign in to comment.