Skip to content

Commit ae62411

Browse files
committed
Try runtime-async
1 parent 021386a commit ae62411

24 files changed

Lines changed: 693 additions & 78 deletions

AssemblyToProcess/AssemblyToProcess.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project Sdk="Microsoft.NET.Sdk">
33
<PropertyGroup>
4-
<TargetFrameworks>net472;net11.0</TargetFrameworks>
4+
<TargetFrameworks>net472;net10.0;net11.0</TargetFrameworks>
55
<DisableFody>true</DisableFody>
66
<Nullable>enable</Nullable>
77
</PropertyGroup>
8-
<PropertyGroup>
8+
<PropertyGroup Condition="'$(TargetFramework)'=='net11.0'">
99
<EnablePreviewFeatures>true</EnablePreviewFeatures>
1010
<Features>$(Features);runtime-async=on</Features>
11+
<DefineConstants>$(DefineConstants);NET11_0</DefineConstants>
1112
</PropertyGroup>
1213
<ItemGroup>
1314
<Using Remove="System.Net.Http" />

AssemblyToProcess/CatchAndFinally.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public async Task Finally3()
7676
}
7777
}
7878

79-
#if NETCOREAPP2_0
79+
#if NET
8080
public async Task Catch1_WithValueTask()
8181
{
8282
try

AssemblyToProcess/ClassWithAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public async Task<int> AsyncGenericMethodWithReturn(SynchronizationContext conte
2828
return await Task.Run(() => 10);
2929
}
3030

31-
#if NETCOREAPP2_0
31+
#if NET
3232
public async Task AsyncMethod_WithValueTask(SynchronizationContext context)
3333
{
3434
SynchronizationContext.SetSynchronizationContext(context);

AssemblyToProcess/DoNotWeave.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public async Task<int> AsyncGenericMethodWithReturn(SynchronizationContext conte
2828
return await Task.Run(() => 10).ConfigureAwait(true);
2929
}
3030

31-
#if NETCOREAPP2_0
31+
#if NET
3232
public async Task AsyncMethod_WithValueTask(SynchronizationContext context)
3333
{
3434
SynchronizationContext.SetSynchronizationContext(context);

AssemblyToProcess/Example.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
public class Example
44
{
5+
#if NET
6+
public async Task Test()
7+
{
8+
await new ValueTask(Task.Delay(1)).ConfigureAwait(false);
9+
}
10+
#endif
11+
512
public async Task AsyncMethod1()
613
{
714
await Task.Delay(1);
@@ -93,7 +100,7 @@ public async Task<Example> AsyncMethod12()
93100
return result;
94101
}
95102

96-
#if NETCOREAPP2_0
103+
#if NET
97104
public async Task AsyncMethod1_WithValueTask()
98105
{
99106
await new ValueTask(Task.Delay(1));

AssemblyToProcess/FlagSynchronizationContext.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
public class FlagSynchronizationContext :
2-
SynchronizationContext
1+
public class FlagSynchronizationContext : SynchronizationContext
32
{
43
public bool Flag { get; set; }
54

AssemblyToProcess/GenericIssue.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public async Task Method(Task<TItem> itemTask)
99
var item = await itemTask;
1010
}
1111

12-
#if NETCOREAPP2_0
12+
#if NET
1313
[ConfigureAwait(false)]
1414
public async Task Method_WithValueTask(Task<TItem> itemTask)
1515
{
@@ -26,7 +26,7 @@ public async Task Method<TItem>(Task<TItem> itemTask)
2626
var item = await itemTask;
2727
}
2828

29-
#if NETCOREAPP2_0
29+
#if NET
3030
[ConfigureAwait(false)]
3131
public async Task Method_WithValueTask<TItem>(Task<TItem> itemTask)
3232
{

AssemblyToProcess/Issue1.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ async Task WithReaderAndWriter(TextWriter writer, StreamReader reader)
1111
}
1212
}
1313

14-
#if NETCOREAPP2_0
14+
#if NET
1515
[ConfigureAwait(false)]
1616
async Task WithReaderAndWriter_WithValueTask(TextWriter writer, StreamReader reader)
1717
{
18-
while (await new ValueTask<string>(reader.ReadLineAsync()) is { } line)
18+
while (await new ValueTask<string?>(reader.ReadLineAsync()) is { } line)
1919
{
2020
await new ValueTask(writer.WriteLineAsync(line));
2121
}

AssemblyToProcess/MethodWithAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public async Task AsyncMethod(SynchronizationContext context)
99
await Task.Delay(0);
1010
}
1111

12-
#if NETCOREAPP2_0
12+
#if NET
1313
[ConfigureAwait(false)]
1414
public async Task AsyncMethod_WithValueTask(SynchronizationContext context)
1515
{

AssemblyToProcess/MethodWithUsing.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ static async Task<IDisposable> NewMethod()
1414
return new MyDisposable();
1515
}
1616

17-
#if NETCOREAPP2_0
17+
#if NET
1818
[ConfigureAwait(false)]
1919
public async Task AsyncMethod_WithValueTask()
2020
{

0 commit comments

Comments
 (0)