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.
65 lines
1.1 KiB
65 lines
1.1 KiB
using System; |
|
using System.Collections.Generic; |
|
using System.Threading.Tasks; |
|
|
|
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty |
|
{ |
|
public class AsyncStreams |
|
{ |
|
public static async IAsyncEnumerable<int> CountTo(int until) |
|
{ |
|
for (int i = 0; i < until; i++) { |
|
yield return i; |
|
await Task.Delay(10); |
|
} |
|
} |
|
|
|
public static async IAsyncEnumerable<int> AlwaysThrow() |
|
{ |
|
throw null; |
|
yield break; |
|
} |
|
|
|
public static async IAsyncEnumerator<int> InfiniteLoop() |
|
{ |
|
while (true) { |
|
} |
|
yield break; |
|
} |
|
|
|
public static async IAsyncEnumerable<int> InfiniteLoopWithAwait() |
|
{ |
|
while (true) { |
|
await Task.Delay(10); |
|
} |
|
yield break; |
|
} |
|
|
|
public async IAsyncEnumerable<int> AwaitInFinally() |
|
{ |
|
try { |
|
Console.WriteLine("try"); |
|
yield return 1; |
|
Console.WriteLine("end try"); |
|
} finally { |
|
Console.WriteLine("finally"); |
|
await Task.Yield(); |
|
Console.WriteLine("end finally"); |
|
} |
|
} |
|
} |
|
|
|
public struct TestStruct |
|
{ |
|
private int i; |
|
|
|
public async IAsyncEnumerable<int> AwaitInStruct(TestStruct xx) |
|
{ |
|
xx.i++; |
|
i++; |
|
await Task.Yield(); |
|
yield return i; |
|
yield return xx.i; |
|
} |
|
} |
|
}
|
|
|