Skip to content

Commit

Permalink
Remove ValueTask<T>.CreateAsyncMethodBuilder from ref (dotnet/corefx#…
Browse files Browse the repository at this point in the history
…26703)

Commit migrated from dotnet/corefx@9ba6220
  • Loading branch information
stephentoub authored Jan 31, 2018
1 parent 1ab2afd commit 3a2a815
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
2 changes: 0 additions & 2 deletions src/libraries/System.Runtime/ref/System.Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7976,8 +7976,6 @@ public void SetObserved() { }
public TResult Result { get { throw null; } }
public System.Threading.Tasks.Task<TResult> AsTask() { throw null; }
public System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable<TResult> ConfigureAwait(bool continueOnCapturedContext) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(1))]
public static System.Runtime.CompilerServices.AsyncValueTaskMethodBuilder<TResult> CreateAsyncMethodBuilder() { throw null; }
public override bool Equals(object obj) { throw null; }
public bool Equals(System.Threading.Tasks.ValueTask<TResult> other) { throw null; }
public System.Runtime.CompilerServices.ValueTaskAwaiter<TResult> GetAwaiter() { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ namespace System.Threading.Tasks
public TResult Result { get { throw null; } }
public System.Threading.Tasks.Task<TResult> AsTask() { throw null; }
public System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable<TResult> ConfigureAwait(bool continueOnCapturedContext) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(1))]
public static System.Runtime.CompilerServices.AsyncValueTaskMethodBuilder<TResult> CreateAsyncMethodBuilder() { throw null; }
public override bool Equals(object obj) { throw null; }
public bool Equals(System.Threading.Tasks.ValueTask<TResult> other) { throw null; }
public System.Runtime.CompilerServices.ValueTaskAwaiter<TResult> GetAwaiter() { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ public class AsyncValueTaskMethodBuilderTests
[Fact]
public void Create_ReturnsDefaultInstance()
{
AsyncValueTaskMethodBuilder<int> b = ValueTask<int>.CreateAsyncMethodBuilder();
AsyncValueTaskMethodBuilder<int> b = default;
Assert.Equal(default(AsyncValueTaskMethodBuilder<int>), b); // implementation detail being verified
}

[Fact]
public void SetResult_BeforeAccessTask_ValueTaskContainsValue()
{
AsyncValueTaskMethodBuilder<int> b = ValueTask<int>.CreateAsyncMethodBuilder();
AsyncValueTaskMethodBuilder<int> b = default;
b.SetResult(42);
ValueTask<int> vt = b.Task;
Assert.True(vt.IsCompletedSuccessfully);
Expand All @@ -31,7 +31,7 @@ public void SetResult_BeforeAccessTask_ValueTaskContainsValue()
[Fact]
public void SetResult_AfterAccessTask_ValueTaskContainsValue()
{
AsyncValueTaskMethodBuilder<int> b = ValueTask<int>.CreateAsyncMethodBuilder();
AsyncValueTaskMethodBuilder<int> b = default;
ValueTask<int> vt = b.Task;
b.SetResult(42);
Assert.True(vt.IsCompletedSuccessfully);
Expand All @@ -42,7 +42,7 @@ public void SetResult_AfterAccessTask_ValueTaskContainsValue()
[Fact]
public void SetException_BeforeAccessTask_FaultsTask()
{
AsyncValueTaskMethodBuilder<int> b = ValueTask<int>.CreateAsyncMethodBuilder();
AsyncValueTaskMethodBuilder<int> b = default;
var e = new FormatException();
b.SetException(e);
ValueTask<int> vt = b.Task;
Expand All @@ -53,7 +53,7 @@ public void SetException_BeforeAccessTask_FaultsTask()
[Fact]
public void SetException_AfterAccessTask_FaultsTask()
{
AsyncValueTaskMethodBuilder<int> b = ValueTask<int>.CreateAsyncMethodBuilder();
AsyncValueTaskMethodBuilder<int> b = default;
var e = new FormatException();
ValueTask<int> vt = b.Task;
b.SetException(e);
Expand All @@ -64,7 +64,7 @@ public void SetException_AfterAccessTask_FaultsTask()
[Fact]
public void SetException_OperationCanceledException_CancelsTask()
{
AsyncValueTaskMethodBuilder<int> b = ValueTask<int>.CreateAsyncMethodBuilder();
AsyncValueTaskMethodBuilder<int> b = default;
var e = new OperationCanceledException();
ValueTask<int> vt = b.Task;
b.SetException(e);
Expand All @@ -75,7 +75,7 @@ public void SetException_OperationCanceledException_CancelsTask()
[Fact]
public void Start_InvokesMoveNext()
{
AsyncValueTaskMethodBuilder<int> b = ValueTask<int>.CreateAsyncMethodBuilder();
AsyncValueTaskMethodBuilder<int> b = default;
int invokes = 0;
var dsm = new DelegateStateMachine { MoveNextDelegate = () => invokes++ };
b.Start(ref dsm);
Expand All @@ -89,7 +89,7 @@ public void Start_InvokesMoveNext()
[InlineData(2, true)]
public void AwaitOnCompleted_ForcesTaskCreation(int numAwaits, bool awaitUnsafe)
{
AsyncValueTaskMethodBuilder<int> b = ValueTask<int>.CreateAsyncMethodBuilder();
AsyncValueTaskMethodBuilder<int> b = default;

var dsm = new DelegateStateMachine();
TaskAwaiter<int> t = new TaskCompletionSource<int>().Task.GetAwaiter();
Expand Down Expand Up @@ -117,7 +117,7 @@ public void AwaitOnCompleted_ForcesTaskCreation(int numAwaits, bool awaitUnsafe)
[ActiveIssue("https://github.com/dotnet/corefx/issues/22506", TargetFrameworkMonikers.UapAot)]
public void SetStateMachine_InvalidArgument_ThrowsException()
{
AsyncValueTaskMethodBuilder<int> b = ValueTask<int>.CreateAsyncMethodBuilder();
AsyncValueTaskMethodBuilder<int> b = default;
AssertExtensions.Throws<ArgumentNullException>("stateMachine", () => b.SetStateMachine(null));
}

Expand All @@ -144,7 +144,7 @@ public void Start_ExecutionContextChangesInMoveNextDontFlowOut()
Assert.Equal(2, al.Value);
Assert.Equal(2, calls);

AsyncValueTaskMethodBuilder<int> b = ValueTask<int>.CreateAsyncMethodBuilder();
AsyncValueTaskMethodBuilder<int> b = default;
b.Start(ref dsm);
Assert.Equal(2, al.Value); // change should not be visible
Assert.Equal(3, calls);
Expand Down

0 comments on commit 3a2a815

Please sign in to comment.