|
5 | 5 | using System.Runtime.InteropServices; |
6 | 6 | using System.Runtime.InteropServices.Marshalling; |
7 | 7 | using System.Runtime.Versioning; |
| 8 | +using System.Threading.Tasks; |
8 | 9 | using System.Windows.Input; |
9 | 10 | using TestComponent; |
10 | 11 | using TestComponentCSharp; |
| 12 | +using Windows.Foundation; |
11 | 13 | using Windows.Foundation.Collections; |
| 14 | +using Windows.Foundation.Tasks; |
12 | 15 | using WindowsRuntime.InteropServices; |
13 | 16 |
|
14 | 17 | CustomDisposableTest customDisposableTest = new(); |
|
115 | 118 | } |
116 | 119 | } |
117 | 120 |
|
| 121 | +IAsyncActionWithProgress<int> asyncActionWithProgress = GenericFactory.MakeAsyncActionWithProgress(); |
| 122 | + |
| 123 | +unsafe |
| 124 | +{ |
| 125 | + void* asyncActionWithProgressPtr = WindowsRuntimeMarshal.ConvertToUnmanaged(asyncActionWithProgress); |
| 126 | + |
| 127 | + try |
| 128 | + { |
| 129 | + ComHelpers.EnsureQueryInterface( |
| 130 | + unknownPtr: asyncActionWithProgressPtr, |
| 131 | + iids: [ |
| 132 | + new Guid("0EDE398F-0090-574E-AD30-E152B433BF6A"), // 'IAsyncActionWithProgress<int>' |
| 133 | + new Guid("0DB2462F-B6D6-5A6C-8834-B530BAAA45FD")]); // 'IAsyncInfo' |
| 134 | + } |
| 135 | + finally |
| 136 | + { |
| 137 | + WindowsRuntimeMarshal.Free(asyncActionWithProgressPtr); |
| 138 | + } |
| 139 | +} |
| 140 | + |
| 141 | +IAsyncOperation<TimeSpan> asyncOperation = GenericFactory.MakeAsyncOperation(); |
| 142 | + |
| 143 | +unsafe |
| 144 | +{ |
| 145 | + void* asyncOperationPtr = WindowsRuntimeMarshal.ConvertToUnmanaged(asyncOperation); |
| 146 | + |
| 147 | + try |
| 148 | + { |
| 149 | + ComHelpers.EnsureQueryInterface( |
| 150 | + unknownPtr: asyncOperationPtr, |
| 151 | + iids: [ |
| 152 | + new Guid("1AE01209-1ACA-51D3-A080-8B1214E0A39E"), // 'IAsyncOperation<TimeSpan>' |
| 153 | + new Guid("0DB2462F-B6D6-5A6C-8834-B530BAAA45FD")]); // 'IAsyncInfo' |
| 154 | + } |
| 155 | + finally |
| 156 | + { |
| 157 | + WindowsRuntimeMarshal.Free(asyncOperationPtr); |
| 158 | + } |
| 159 | +} |
| 160 | + |
118 | 161 | sealed class TestComposable : Composable |
119 | 162 | { |
120 | 163 | } |
@@ -209,6 +252,26 @@ class GenericFactory |
209 | 252 | public static object Make() => Make<bool>(); |
210 | 253 |
|
211 | 254 | private static object Make<T>() => new GenericType<T, float>(); |
| 255 | + |
| 256 | + // Specific test for 'AsyncInfo.Run' with explicit type arguments |
| 257 | + [SupportedOSPlatform("windows10.0.10240.0")] |
| 258 | + public static IAsyncActionWithProgress<int> MakeAsyncActionWithProgress() |
| 259 | + { |
| 260 | + return AsyncInfo.Run<int>((token, progress) => Task.CompletedTask); |
| 261 | + } |
| 262 | + |
| 263 | + // Specific test for 'AsyncInfo.Run' with transitive type arguments |
| 264 | + [SupportedOSPlatform("windows10.0.10240.0")] |
| 265 | + public static IAsyncOperation<TimeSpan> MakeAsyncOperation() |
| 266 | + { |
| 267 | + return MakeAsyncActionOperation<TimeSpan>(); |
| 268 | + } |
| 269 | + |
| 270 | + [SupportedOSPlatform("windows10.0.10240.0")] |
| 271 | + private static IAsyncOperation<T> MakeAsyncActionOperation<T>() |
| 272 | + { |
| 273 | + return AsyncInfo.Run(token => Task.FromResult(default(T))); |
| 274 | + } |
212 | 275 | } |
213 | 276 |
|
214 | 277 | [Guid("3C832AA5-5F7E-46EE-B1BF-7FE03AE866AF")] |
|
0 commit comments