| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 | 
							- using System;
 
- using System.Diagnostics;
 
- using System.Runtime.CompilerServices;
 
- using System.Security;
 
- namespace Fort23.Core
 
- {
 
-     /// <summary>
 
-     /// Represents a builder for asynchronous methods that return a task.
 
-     /// </summary>
 
-     public struct AsyncTaskMethodBuilder
 
-     {
 
-         private CTask _tcs;
 
-         // 1. Static Create method.
 
-         [DebuggerHidden]
 
-         [MethodImpl(MethodImplOptions.AggressiveInlining)]
 
-         public static AsyncTaskMethodBuilder Create()
 
-         {
 
-             AsyncTaskMethodBuilder builder = new AsyncTaskMethodBuilder() {_tcs = CTask.Create()};
 
-             return builder;
 
-         }
 
-         // 2. TaskLike Task property.
 
-         [DebuggerHidden] public CTask Task => this._tcs;
 
-         // 3. SetException
 
-         [MethodImpl(MethodImplOptions.AggressiveInlining)]
 
-         [DebuggerHidden]
 
-         public void SetException(Exception exception)
 
-         {
 
-             this._tcs.SetException(exception);
 
-         }
 
-         // 4. SetResult
 
-         [DebuggerHidden]
 
-         [MethodImpl(MethodImplOptions.AggressiveInlining)]
 
-         public void SetResult()
 
-         {
 
-             this._tcs.SetResult();
 
-         }
 
-         // 5. AwaitOnCompleted
 
-         [MethodImpl(MethodImplOptions.AggressiveInlining)]
 
-         [DebuggerHidden]
 
-         public void AwaitOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : INotifyCompletion where TStateMachine : IAsyncStateMachine
 
-         {
 
-             awaiter.OnCompleted(stateMachine.MoveNext);
 
-         }
 
-         // 6. AwaitUnsafeOnCompleted
 
-         [MethodImpl(MethodImplOptions.AggressiveInlining)]
 
-         [DebuggerHidden]
 
-         [SecuritySafeCritical]
 
-         public void AwaitUnsafeOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : ICriticalNotifyCompletion where TStateMachine : IAsyncStateMachine
 
-         {
 
-             awaiter.OnCompleted(stateMachine.MoveNext);
 
-         }
 
-         // 7. Start
 
-         [DebuggerHidden]
 
-         [MethodImpl(MethodImplOptions.AggressiveInlining)]
 
-         public void Start<TStateMachine>(ref TStateMachine stateMachine) where TStateMachine : IAsyncStateMachine
 
-         {
 
-             stateMachine.MoveNext();
 
-         }
 
-         // 8. SetStateMachine
 
-         [DebuggerHidden]
 
-         [MethodImpl(MethodImplOptions.AggressiveInlining)]
 
-         public void SetStateMachine(IAsyncStateMachine stateMachine)
 
-         {
 
-         }
 
-     }
 
-     /// <summary>
 
-     /// Represents a builder for asynchronous methods that return a task.
 
-     /// </summary>
 
-     /// <typeparam name="T"></typeparam>
 
-     public struct AsyncTaskMethodBuilder<T>
 
-     {
 
-         private CTask<T> _task;
 
-         // 1. Static Create method.
 
-         [DebuggerHidden]
 
-         [MethodImpl(MethodImplOptions.AggressiveInlining)]
 
-         public static AsyncTaskMethodBuilder<T> Create()
 
-         {
 
-             AsyncTaskMethodBuilder<T> builder = new AsyncTaskMethodBuilder<T>() {_task = CTask<T>.Create()};
 
-             return builder;
 
-         }
 
-         // 2. TaskLike Task property.
 
-         [DebuggerHidden] public CTask<T> Task => _task;
 
-         // 3. SetException
 
-         [DebuggerHidden]
 
-         [MethodImpl(MethodImplOptions.AggressiveInlining)]
 
-         public void SetException(Exception exception)
 
-         {
 
-             _task.SetException(exception);
 
-         }
 
-         // 4. SetResult
 
-         [DebuggerHidden]
 
-         [MethodImpl(MethodImplOptions.AggressiveInlining)]
 
-         public void SetResult(T ret)
 
-         {
 
-             _task.SetResult(ret);
 
-         }
 
-         // 5. AwaitOnCompleted
 
-         [DebuggerHidden]
 
-         [MethodImpl(MethodImplOptions.AggressiveInlining)]
 
-         public void AwaitOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : INotifyCompletion where TStateMachine : IAsyncStateMachine
 
-         {
 
-             awaiter.OnCompleted(stateMachine.MoveNext);
 
-         }
 
-         // 6. AwaitUnsafeOnCompleted
 
-         [MethodImpl(MethodImplOptions.AggressiveInlining)]
 
-         [DebuggerHidden]
 
-         [SecuritySafeCritical]
 
-         public void AwaitUnsafeOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : ICriticalNotifyCompletion where TStateMachine : IAsyncStateMachine
 
-         {
 
-             awaiter.OnCompleted(stateMachine.MoveNext);
 
-         }
 
-         // 7. Start
 
-         [MethodImpl(MethodImplOptions.AggressiveInlining)]
 
-         [DebuggerHidden]
 
-         public void Start<TStateMachine>(ref TStateMachine stateMachine) where TStateMachine : IAsyncStateMachine
 
-         {
 
-             stateMachine.MoveNext();
 
-         }
 
-         // 8. SetStateMachine
 
-         [MethodImpl(MethodImplOptions.AggressiveInlining)]
 
-         [DebuggerHidden]
 
-         public void SetStateMachine(IAsyncStateMachine stateMachine)
 
-         {
 
-         }
 
-     }
 
- }
 
 
  |