Skip to content

Commit 5ed0cee

Browse files
committed
Remove workarounds for MethodImplOptions.Async
1 parent dfeb272 commit 5ed0cee

18 files changed

+15
-35
lines changed

src/tests/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<PropertyGroup>
1212
<!-- Override the compiler version with a private build that supports async2 -->
13-
<MicrosoftNetCompilersToolsetVersion>5.0.0-1.25258.11</MicrosoftNetCompilersToolsetVersion>
13+
<MicrosoftNetCompilersToolsetVersion>5.0.0-1.25259.6</MicrosoftNetCompilersToolsetVersion>
1414
</PropertyGroup>
1515

1616
<PropertyGroup>

src/tests/async/awaitingnotasync.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ private static async ValueTask<T> GetValueTask<T>(T arg)
3434

3535
private static T sIdentity<T>(T arg) => arg;
3636

37-
[MethodImpl(MethodImplOptions.Async)]
3837
private static async Task AsyncEntryPoint()
3938
{
4039
// static field

src/tests/async/cse-array-index-byref.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ private static async Task AsyncTestEntryPoint(int[] arr, int index)
2222
await HoistedByref(arr, index);
2323
}
2424

25-
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)]
25+
[MethodImpl(MethodImplOptions.NoInlining)]
2626
private static async Task<int> HoistedByref(int[] arr, int index)
2727
{
2828
for (int i = 0; i < 20000; i++)

src/tests/async/fibonacci-with-yields.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public static void Test()
2323
System.Console.WriteLine("allocated: " + allocated);
2424
}
2525

26-
[MethodImpl(MethodImplOptions.Async)]
2726
public static async Task AsyncEntry()
2827
{
2928
for (int i = 0; i < iterations; i++)
@@ -36,7 +35,6 @@ public static async Task AsyncEntry()
3635
}
3736
}
3837

39-
[MethodImpl(MethodImplOptions.Async)]
4038
static async Task<int> Fib(int i)
4139
{
4240
if (i <= 1)

src/tests/async/fibonacci-with-yields_struct_return.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public struct MyInt
3535
public MyInt(int i) => this.i = i;
3636
}
3737

38-
[MethodImpl(MethodImplOptions.Async)]
3938
public static async Task AsyncEntry()
4039
{
4140
for (int i = 0; i < iterations; i++)
@@ -48,7 +47,6 @@ public static async Task AsyncEntry()
4847
}
4948
}
5049

51-
[MethodImpl(MethodImplOptions.Async)]
5250
static async Task<MyInt> Fib(MyInt n)
5351
{
5452
int i = n.i;

src/tests/async/fibonacci-without-yields-config-await.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ public static void Test()
2626
System.Console.WriteLine("allocated: " + allocated);
2727
}
2828

29-
[MethodImpl(MethodImplOptions.Async)]
3029
public static async Task AsyncEntry()
3130
{
3231
for (int i = 0; i < iterations; i++)
@@ -39,7 +38,6 @@ public static async Task AsyncEntry()
3938
}
4039
}
4140

42-
[MethodImpl(MethodImplOptions.Async)]
4341
static async Task<int> Fib(int i)
4442
{
4543
if (i <= 1)

src/tests/async/fibonacci-without-yields.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public static void Test()
2323
System.Console.WriteLine("allocated: " + allocated);
2424
}
2525

26-
[MethodImpl(MethodImplOptions.Async)]
2726
public static async Task AsyncEntry()
2827
{
2928
for (int i = 0; i < iterations; i++)
@@ -36,7 +35,6 @@ public static async Task AsyncEntry()
3635
}
3736
}
3837

39-
[MethodImpl(MethodImplOptions.Async)]
4038
static async Task<int> Fib(int i)
4139
{
4240
if (i <= 1)

src/tests/async/object.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ private static async Task<object> AsyncTestEntryPoint(int arg)
2020
return await ObjMethod(arg);
2121
}
2222

23-
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)]
23+
[MethodImpl(MethodImplOptions.NoInlining)]
2424
private static async Task<object> ObjMethod(int arg)
2525
{
2626
await Task.Yield();

src/tests/async/objects-captured.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
public class Async2ObjectsWithYields
1111
{
12-
[MethodImpl(MethodImplOptions.Async)]
1312
internal static async Task<int> A(object n)
1413
{
1514
// use string equality so that JIT would not think of hoisting "(int)n"

src/tests/async/override.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ public class Async2Override
1010
{
1111
class Base
1212
{
13-
[MethodImpl(MethodImplOptions.Async)]
1413
public virtual async Task<int> M1()
1514
{
1615
await Task.Yield();
@@ -30,7 +29,6 @@ public override async Task<int> M1()
3029

3130
class Derived2 : Derived1
3231
{
33-
[MethodImpl(MethodImplOptions.Async)]
3432
public override async Task<int> M1()
3533
{
3634
await Task.Yield();
@@ -51,7 +49,6 @@ public virtual async Task<int> M1()
5149

5250
class Derived11 : Base1
5351
{
54-
[MethodImpl(MethodImplOptions.Async)]
5552
public override async Task<int> M1()
5653
{
5754
await Task.Yield();

src/tests/async/pgo.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ public static void EntryPoint()
1717
AsyncEntryPoint().Wait();
1818
}
1919

20-
[MethodImpl(MethodImplOptions.Async)]
2120
internal static async Task<int> AsyncEntryPoint()
2221
{
2322
int[] arr = Enumerable.Range(0, 100_000).ToArray();
@@ -37,7 +36,6 @@ internal static async Task<int> AsyncEntryPoint()
3736
private class AggregateSum : I<int>
3837
{
3938
#pragma warning disable CS1998
40-
[MethodImpl(MethodImplOptions.Async)]
4139
public async Task<int> Aggregate(int a, int b) => a + b;
4240
}
4341

@@ -46,7 +44,7 @@ public interface I<T>
4644
public Task<T> Aggregate(T seed, T val);
4745
}
4846

49-
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)]
47+
[MethodImpl(MethodImplOptions.NoInlining)]
5048
public static async Task<T> AggregateDelegateAsync<T>(T[] arr, I<T> aggregate, T seed)
5149
{
5250
foreach (T val in arr)

src/tests/async/pinvoke.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ public static void TestEntryPoint()
1414
AsyncEntryPoint().Wait();
1515
}
1616

17-
[MethodImpl(MethodImplOptions.Async)]
1817
private static async Task AsyncEntryPoint()
1918
{
2019
unsafe

src/tests/async/returns.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public static void TestEntryPoint()
1414
Returns(new C()).Wait();
1515
}
1616

17-
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)]
17+
[MethodImpl(MethodImplOptions.NoInlining)]
1818
private static async Task Returns(C c)
1919
{
2020
for (int i = 0; i < 20000; i++)
@@ -57,28 +57,28 @@ private static void AssertEqual<T>(T expected, T actual)
5757
Assert.Equal(expected, actual);
5858
}
5959

60-
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)]
60+
[MethodImpl(MethodImplOptions.NoInlining)]
6161
private static async Task<S<long>> ReturnsStruct()
6262
{
6363
await Task.Yield();
6464
return new S<long> { A = 42, B = 4242, C = 424242, D = 42424242 };
6565
}
6666

67-
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)]
67+
[MethodImpl(MethodImplOptions.NoInlining)]
6868
private static async Task<S<string>> ReturnsStructGC()
6969
{
7070
await Task.Yield();
7171
return new S<string> { A = "A", B = "B", C = "C", D = "D" };
7272
}
7373

74-
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)]
74+
[MethodImpl(MethodImplOptions.NoInlining)]
7575
private static async Task<S<byte>> ReturnsBytes()
7676
{
7777
await Task.Yield();
7878
return new S<byte> { A = 4, B = 40, C = 42, D = 45 };
7979
}
8080

81-
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)]
81+
[MethodImpl(MethodImplOptions.NoInlining)]
8282
private static async Task<string> ReturnsString()
8383
{
8484
await Task.Yield();

src/tests/async/shared-generic.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ private static async Task Async1EntryPoint<T>(Type t, T value)
6666
Assert.Equal(value, await GenericClass<T>.StaticReturnMethodTypeAsync1<T>(value));
6767
}
6868

69-
[MethodImpl(MethodImplOptions.Async)]
7069
private static async Task Async2EntryPoint<T>(Type t, T value)
7170
{
7271
await new GenericClass<T>().InstanceMethod(t);
@@ -85,7 +84,7 @@ private static async Task Async2EntryPoint<T>(Type t, T value)
8584
public class GenericClass<T>
8685
{
8786
// 'this' is context
88-
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)]
87+
[MethodImpl(MethodImplOptions.NoInlining)]
8988
public async Task InstanceMethod(Type t)
9089
{
9190
Assert.Equal(typeof(T), t);
@@ -94,7 +93,7 @@ public async Task InstanceMethod(Type t)
9493
}
9594

9695
// Class context
97-
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)]
96+
[MethodImpl(MethodImplOptions.NoInlining)]
9897
public static async Task StaticMethod(Type t)
9998
{
10099
Assert.Equal(typeof(T), t);
@@ -103,7 +102,7 @@ public static async Task StaticMethod(Type t)
103102
}
104103

105104
// Method context
106-
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)]
105+
[MethodImpl(MethodImplOptions.NoInlining)]
107106
public static async Task StaticMethod<TM>(Type t, Type tm)
108107
{
109108
Assert.Equal(typeof(T), t);
@@ -135,14 +134,12 @@ public static async Task StaticMethodAsync1<TM>(Type t, Type tm)
135134
Assert.Equal(typeof(TM), tm);
136135
}
137136

138-
[MethodImpl(MethodImplOptions.Async)]
139137
public static async Task<T> StaticReturnClassType(T value)
140138
{
141139
await Task.Yield();
142140
return value;
143141
}
144142

145-
[MethodImpl(MethodImplOptions.Async)]
146143
public static async Task<TM> StaticReturnMethodType<TM>(TM value)
147144
{
148145
await Task.Yield();

src/tests/async/simple-eh.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ public static async Task AsyncEntry()
2525
Assert.Equal(42, result);
2626
}
2727

28-
[MethodImpl(MethodImplOptions.Async)]
2928
public static async Task<int> Handler()
3029
{
3130
try
@@ -38,7 +37,7 @@ public static async Task<int> Handler()
3837
}
3938
}
4039

41-
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)]
40+
[MethodImpl(MethodImplOptions.NoInlining)]
4241
public static async Task<int> Throw(int value)
4342
{
4443
await Task.Yield();

src/tests/async/simple-eh.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<Optimize>True</Optimize>
4+
<RequiresProcessIsolation>true</RequiresProcessIsolation>
45
</PropertyGroup>
56
<ItemGroup>
67
<Compile Include="$(MSBuildProjectName).cs" />

src/tests/async/small.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public static void TestEntryPoint()
1414
SmallType(123).Wait();
1515
}
1616

17-
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)]
17+
[MethodImpl(MethodImplOptions.NoInlining)]
1818
private static async Task SmallType(byte arg)
1919
{
2020
await Task.Yield();

src/tests/async/struct.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ private static async Task Async()
2525
AssertEqual(100, s.Value);
2626
}
2727

28-
[MethodImpl(MethodImplOptions.Async)]
2928
private static async Task Async2()
3029
{
3130
S s = new S(100);

0 commit comments

Comments
 (0)