Created
November 5, 2019 00:27
-
-
Save jaredpar/de522f659963bf50e0fd9f24d3b00768 to your computer and use it in GitHub Desktop.
Evil async and await C# code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Runtime.CompilerServices; | |
public class C { | |
async async await(await async) => await async; | |
} | |
[AsyncMethodBuilder(typeof(builder))] | |
class async { | |
public awaiter GetAwaiter() => throw null; | |
} | |
class await { | |
public awaiter GetAwaiter() => throw null; | |
} | |
class awaiter : INotifyCompletion { | |
public bool IsCompleted => true; | |
public void GetResult() { } | |
public void OnCompleted(Action continuation) { } | |
} | |
class builder | |
{ | |
public builder() { } | |
public static builder Create() => throw null; | |
public void SetResult() { } | |
public void SetException(Exception e) { } | |
public void Start<TStateMachine>(ref TStateMachine stateMachine) | |
where TStateMachine : IAsyncStateMachine => throw null; | |
public async Task => throw null; | |
public void AwaitOnCompleted<TAwaiter, TStateMachine>( | |
ref TAwaiter awaiter, ref TStateMachine stateMachine) | |
where TAwaiter : INotifyCompletion | |
where TStateMachine : IAsyncStateMachine => throw null; | |
public void AwaitUnsafeOnCompleted<TAwaiter, TStateMachine>( | |
ref TAwaiter awaiter, ref TStateMachine stateMachine) | |
where TAwaiter : ICriticalNotifyCompletion | |
where TStateMachine : IAsyncStateMachine => throw null; | |
public void SetStateMachine(IAsyncStateMachine stateMachine) => throw null; | |
} |
Indeed, you can get to a point where you can arbitrarily chain await
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We can add more await!