Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public static void Main()
NestedAsyncLambda.Test<int>();
NestedAsyncLocalFunction.Test<int>();
NestedStaticLambda.Test<int>();

// Partial methods
PartialAsyncMethodWithLambda.Test();
}

private static void UseIterator()
Expand Down Expand Up @@ -433,5 +436,32 @@ public static void Test<T>()
Container<T>.NestedLambda((T t) => t)(default(T));
}
}

// Regression test for https://github.com/dotnet/runtime/issues/122800
// Roslyn does not emit [AsyncStateMachineAttribute] on async partial methods.
partial class PartialAsyncMethodWithLambda
{
public static void Test()
{
new PartialAsyncMethodWithLambda().GetData<int>();
}

public partial Task<T> GetData<T>() where T : new();
}

partial class PartialAsyncMethodWithLambda
{
public async partial Task<T> GetData<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] T>() where T : new()
{
var tcs = new TaskCompletionSource<T>();
Action<T> callback = (result) =>
{
_ = typeof(T).GetMethods();
tcs.TrySetResult(result);
};
callback(new T());
return await tcs.Task;
}
}
}
}
Loading