diff options
author | Marek Safar <marek.safar@gmail.com> | 2017-12-22 17:02:27 +0300 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2017-12-22 18:53:31 +0300 |
commit | 841ffc2334512b5a4d0c59c4ce9f311cf63c4610 (patch) | |
tree | e7d87ddc5f5d295c7aa549d50b07ff229b770f0f /mcs/tests | |
parent | 6e885dec43b2e275822e9372412a7077287fd484 (diff) |
[mcs] Implements C# 7.0 Generalized async return types
Diffstat (limited to 'mcs/tests')
-rw-r--r-- | mcs/tests/test-async-94.cs | 127 | ||||
-rw-r--r-- | mcs/tests/ver-il-net_4_x.xml | 111 |
2 files changed, 238 insertions, 0 deletions
diff --git a/mcs/tests/test-async-94.cs b/mcs/tests/test-async-94.cs new file mode 100644 index 00000000000..ce9a30409bb --- /dev/null +++ b/mcs/tests/test-async-94.cs @@ -0,0 +1,127 @@ +using System; +using System.Threading.Tasks; +using System.Runtime.CompilerServices; + +[AsyncMethodBuilder (typeof(MyTaskMethodBuilder<>))] +class MyTask<T> +{ +} + +[AsyncMethodBuilder (typeof(MyTaskMethodBuilder))] +class MyTask +{ +} + +class MyTaskMethodBuilder +{ + public static MyTaskMethodBuilder Create() + { + return null; + } + + public MyTask Task { + get { + return null; + } + } + + public void SetException (Exception exception) + { + + } + + public void SetResult () + { + + } + + public void AwaitOnCompleted<TAwaiter, TStateMachine> (ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : INotifyCompletion where TStateMachine : IAsyncStateMachine + { + + } + + public void AwaitUnsafeOnCompleted<TAwaiter, TStateMachine> (ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : ICriticalNotifyCompletion where TStateMachine : IAsyncStateMachine + { + + } + + public void Start<TStateMachine> (ref TStateMachine stateMachine) where TStateMachine : IAsyncStateMachine + { + + } + + public void SetStateMachine (IAsyncStateMachine stateMachine) + { + + } +} + +class MyTaskMethodBuilder<T> +{ + public static MyTaskMethodBuilder<T> Create() + { + return null; + } + + public MyTask<T> Task { + get { + return null; + } + } + + public void SetException (Exception exception) + { + + } + + public void SetResult (T result) + { + + } + + public void AwaitOnCompleted<TAwaiter, TStateMachine> (ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : INotifyCompletion where TStateMachine : IAsyncStateMachine + { + + } + + public void AwaitUnsafeOnCompleted<TAwaiter, TStateMachine> (ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : ICriticalNotifyCompletion where TStateMachine : IAsyncStateMachine + { + + } + + public void Start<TStateMachine> (ref TStateMachine stateMachine) where TStateMachine : IAsyncStateMachine + { + + } + + public void SetStateMachine (IAsyncStateMachine stateMachine) + { + + } +} + +class X +{ + public async MyTask Test () + { + await Task.Delay (1); + } + + public async MyTask<int> Test2 () + { + await Task.Delay (1); + return 2; + } + + public async ValueTask<string> Test3 () + { + await Task.Delay (1); + return "as"; + } + + public static void Main () + { + var x = new X (); + var r1 = x.Test3 ().Result; + } +}
\ No newline at end of file diff --git a/mcs/tests/ver-il-net_4_x.xml b/mcs/tests/ver-il-net_4_x.xml index d57416d8e0b..09b8c637e18 100644 --- a/mcs/tests/ver-il-net_4_x.xml +++ b/mcs/tests/ver-il-net_4_x.xml @@ -66911,6 +66911,117 @@ </method> </type> </test> + <test name="test-async-94.cs"> + <type name="MyTask`1[T]"> + <method name="Void .ctor()" attrs="6278"> + <size>7</size> + </method> + </type> + <type name="MyTask"> + <method name="Void .ctor()" attrs="6278"> + <size>7</size> + </method> + </type> + <type name="MyTaskMethodBuilder"> + <method name="MyTaskMethodBuilder Create()" attrs="150"> + <size>10</size> + </method> + <method name="MyTask get_Task()" attrs="2182"> + <size>10</size> + </method> + <method name="Void SetException(System.Exception)" attrs="134"> + <size>2</size> + </method> + <method name="Void SetResult()" attrs="134"> + <size>2</size> + </method> + <method name="Void AwaitOnCompleted[TAwaiter,TStateMachine](TAwaiter ByRef, TStateMachine ByRef)" attrs="134"> + <size>2</size> + </method> + <method name="Void AwaitUnsafeOnCompleted[TAwaiter,TStateMachine](TAwaiter ByRef, TStateMachine ByRef)" attrs="134"> + <size>2</size> + </method> + <method name="Void Start[TStateMachine](TStateMachine ByRef)" attrs="134"> + <size>2</size> + </method> + <method name="Void SetStateMachine(System.Runtime.CompilerServices.IAsyncStateMachine)" attrs="134"> + <size>2</size> + </method> + <method name="Void .ctor()" attrs="6278"> + <size>7</size> + </method> + </type> + <type name="MyTaskMethodBuilder`1[T]"> + <method name="MyTaskMethodBuilder`1[T] Create()" attrs="150"> + <size>10</size> + </method> + <method name="MyTask`1[T] get_Task()" attrs="2182"> + <size>10</size> + </method> + <method name="Void SetException(System.Exception)" attrs="134"> + <size>2</size> + </method> + <method name="Void SetResult(T)" attrs="134"> + <size>2</size> + </method> + <method name="Void AwaitOnCompleted[TAwaiter,TStateMachine](TAwaiter ByRef, TStateMachine ByRef)" attrs="134"> + <size>2</size> + </method> + <method name="Void AwaitUnsafeOnCompleted[TAwaiter,TStateMachine](TAwaiter ByRef, TStateMachine ByRef)" attrs="134"> + <size>2</size> + </method> + <method name="Void Start[TStateMachine](TStateMachine ByRef)" attrs="134"> + <size>2</size> + </method> + <method name="Void SetStateMachine(System.Runtime.CompilerServices.IAsyncStateMachine)" attrs="134"> + <size>2</size> + </method> + <method name="Void .ctor()" attrs="6278"> + <size>7</size> + </method> + </type> + <type name="X"> + <method name="MyTask Test()" attrs="134"> + <size>33</size> + </method> + <method name="MyTask`1[System.Int32] Test2()" attrs="134"> + <size>33</size> + </method> + <method name="System.Threading.Tasks.ValueTask`1[System.String] Test3()" attrs="134"> + <size>33</size> + </method> + <method name="Void Main()" attrs="150"> + <size>23</size> + </method> + <method name="Void .ctor()" attrs="6278"> + <size>7</size> + </method> + </type> + <type name="X+<Test>c__async0"> + <method name="Void MoveNext()" attrs="486"> + <size>157</size> + </method> + <method name="Void SetStateMachine(System.Runtime.CompilerServices.IAsyncStateMachine)" attrs="486"> + <size>13</size> + </method> + </type> + <type name="X+<Test2>c__async1"> + <method name="Void MoveNext()" attrs="486"> + <size>165</size> + </method> + <method name="Void SetStateMachine(System.Runtime.CompilerServices.IAsyncStateMachine)" attrs="486"> + <size>13</size> + </method> + </type> + <type name="X+<Test3>c__async2"> + <method name="Void MoveNext()" attrs="486"> + <size>169</size> + </method> + <method name="Void SetStateMachine(System.Runtime.CompilerServices.IAsyncStateMachine)" attrs="486"> + <size>13</size> + </method> + </type> + </test> <test name="test-cls-00.cs"> <type name="CLSCLass_6"> <method name="Void add_Disposed(Delegate)" attrs="2182"> |