Skip to content
Draft
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/coreclr/inc/clrconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ RETAIL_CONFIG_DWORD_INFO(EXTERNAL_EnableRiscV64Zbb, W("EnableRiscV64
#endif

// Runtime-async
RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_RuntimeAsync, W("RuntimeAsync"), 0, "Enables runtime async method support")
RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_RuntimeAsync, W("RuntimeAsync"), 1, "Enables runtime async method support")

///
/// Uncategorized
Expand Down
17 changes: 17 additions & 0 deletions src/coreclr/vm/methodtablebuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3301,6 +3301,23 @@ MethodTableBuilder::EnumerateClassMethods()
}
}

// Vararg methods are not allowed to be marked MethodImpl.Async
// and even when they return Tasks they are still treated as NormalMethod.
if (returnKind != MethodReturnKind::NormalMethod)
{
if (MetaSig::IsVarArg(Signature(pMemberSignature, cMemberSignature)))
{
if (IsMiAsync(dwImplFlags))
{
BuildMethodTableThrowException(IDS_EE_VARARG_NOT_SUPPORTED);
}
else
{
returnKind = MethodReturnKind::NormalMethod;
}
}
}

//
// Create a new bmtMDMethod representing this method and add it to the
// declared method list.
Expand Down
5 changes: 0 additions & 5 deletions src/tests/async/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,5 @@
<DisableProjectBuild Condition="'$(TestBuildMode)' == 'nativeaot' and '$(TargetArchitecture)' == 'arm64'">true</DisableProjectBuild>
</PropertyGroup>

<PropertyGroup>
<!-- runtime async testing in main repo NYI -->
<DisableProjectBuild Condition="'$(TestBuildMode)' != 'nativeaot'">true</DisableProjectBuild>
</PropertyGroup>

<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets, $(MSBuildThisFileDirectory)..))" />
</Project>
80 changes: 80 additions & 0 deletions src/tests/async/varargs/varargs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Xunit;

public class Async2Varargs
{
[Fact]
public static void TestTaskDirectCall()
{
TaskWithArglist(42, __arglist(100, 200)).Wait();
}

[Fact]
public static void TestTaskAwait()
{
TestTaskAwaitAsync().Wait();
}

private static async Task TestTaskAwaitAsync()
{
await TaskWithArglist(42, __arglist(100, 200));

Check failure on line 25 in src/tests/async/varargs/varargs.cs

View check run for this annotation

Azure Pipelines / runtime (Build coreclr Common Pri0 Test Build AnyOS AnyCPU checked)

src/tests/async/varargs/varargs.cs#L25

src/tests/async/varargs/varargs.cs(25,35): error CS9328: Method 'Async2Varargs.TestTaskAwaitAsync()' uses a feature that is not supported by runtime async currently. Opt the method out of runtime async by attributing it with 'System.Runtime.CompilerServices.RuntimeAsyncMethodGenerationAttribute(false)'. [/__w/1/s/src/tests/async/varargs/varargs.csproj]

Check failure on line 25 in src/tests/async/varargs/varargs.cs

View check run for this annotation

Azure Pipelines / runtime

src/tests/async/varargs/varargs.cs#L25

src/tests/async/varargs/varargs.cs(25,35): error CS9328: Method 'Async2Varargs.TestTaskAwaitAsync()' uses a feature that is not supported by runtime async currently. Opt the method out of runtime async by attributing it with 'System.Runtime.CompilerServices.RuntimeAsyncMethodGenerationAttribute(false)'. [/__w/1/s/src/tests/async/varargs/varargs.csproj]
}

[MethodImpl(MethodImplOptions.NoInlining)]
private static Task TaskWithArglist(int fixedArg, __arglist)
{
Assert.Equal(42, fixedArg);

ArgIterator args = new ArgIterator(__arglist);
Assert.Equal(2, args.GetRemainingCount());

int arg1 = __refvalue(args.GetNextArg(), int);
int arg2 = __refvalue(args.GetNextArg(), int);

Assert.Equal(100, arg1);
Assert.Equal(200, arg2);

return Task.CompletedTask;
}

[Fact]
public static void TestValueTaskDirectCall()
{
int result = ValueTaskWithArglist(42, __arglist(100, 200)).Result;
Assert.Equal(342, result);
}

[Fact]
public static void TestValueTaskAwait()
{
TestValueTaskAwaitAsync().Wait();
}

private static async Task TestValueTaskAwaitAsync()
{
int result = await ValueTaskWithArglist(42, __arglist(100, 200));

Check failure on line 60 in src/tests/async/varargs/varargs.cs

View check run for this annotation

Azure Pipelines / runtime (Build coreclr Common Pri0 Test Build AnyOS AnyCPU checked)

src/tests/async/varargs/varargs.cs#L60

src/tests/async/varargs/varargs.cs(60,53): error CS9328: Method 'Async2Varargs.TestValueTaskAwaitAsync()' uses a feature that is not supported by runtime async currently. Opt the method out of runtime async by attributing it with 'System.Runtime.CompilerServices.RuntimeAsyncMethodGenerationAttribute(false)'. [/__w/1/s/src/tests/async/varargs/varargs.csproj]

Check failure on line 60 in src/tests/async/varargs/varargs.cs

View check run for this annotation

Azure Pipelines / runtime

src/tests/async/varargs/varargs.cs#L60

src/tests/async/varargs/varargs.cs(60,53): error CS9328: Method 'Async2Varargs.TestValueTaskAwaitAsync()' uses a feature that is not supported by runtime async currently. Opt the method out of runtime async by attributing it with 'System.Runtime.CompilerServices.RuntimeAsyncMethodGenerationAttribute(false)'. [/__w/1/s/src/tests/async/varargs/varargs.csproj]
Assert.Equal(342, result);
}

[MethodImpl(MethodImplOptions.NoInlining)]
private static ValueTask<int> ValueTaskWithArglist(int fixedArg, __arglist)
{
Assert.Equal(42, fixedArg);

ArgIterator args = new ArgIterator(__arglist);
Assert.Equal(2, args.GetRemainingCount());

int arg1 = __refvalue(args.GetNextArg(), int);
int arg2 = __refvalue(args.GetNextArg(), int);

Assert.Equal(100, arg1);
Assert.Equal(200, arg2);

return new ValueTask<int>(fixedArg + arg1 + arg2);
}
}
5 changes: 5 additions & 0 deletions src/tests/async/varargs/varargs.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>
Loading