mirror of https://github.com/icsharpcode/ILSpy.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.3 KiB
60 lines
1.3 KiB
using System; |
|
using System.Runtime.InteropServices; |
|
using System.Threading.Tasks; |
|
|
|
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty |
|
{ |
|
internal class AsyncUsing |
|
{ |
|
internal class AsyncDisposableClass : IAsyncDisposable |
|
{ |
|
public ValueTask DisposeAsync() |
|
{ |
|
throw new NotImplementedException(); |
|
} |
|
} |
|
|
|
[StructLayout(LayoutKind.Sequential, Size = 1)] |
|
internal struct AsyncDisposableStruct : IAsyncDisposable |
|
{ |
|
public ValueTask DisposeAsync() |
|
{ |
|
throw new NotImplementedException(); |
|
} |
|
} |
|
|
|
public static async void TestAsyncUsing(IAsyncDisposable disposable) |
|
{ |
|
await using (disposable) { |
|
Console.WriteLine("Hello"); |
|
} |
|
} |
|
|
|
public static async void TestAsyncUsingClass() |
|
{ |
|
await using (AsyncDisposableClass test = new AsyncDisposableClass()) { |
|
Use(test); |
|
} |
|
} |
|
|
|
public static async void TestAsyncUsingStruct() |
|
{ |
|
await using (AsyncDisposableStruct asyncDisposableStruct = default(AsyncDisposableStruct)) { |
|
Use(asyncDisposableStruct); |
|
} |
|
} |
|
|
|
public static async void TestAsyncUsingNullableStruct() |
|
{ |
|
await using (AsyncDisposableStruct? asyncDisposableStruct = new AsyncDisposableStruct?(default(AsyncDisposableStruct))) { |
|
Use(asyncDisposableStruct); |
|
} |
|
} |
|
|
|
private static void Use(IAsyncDisposable test) |
|
{ |
|
throw new NotImplementedException(); |
|
} |
|
|
|
} |
|
}
|
|
|