Skip to content
Merged
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
37 changes: 37 additions & 0 deletions src/tests/async/awaitingnoasyncgeneric/awaitingnoasyncgeneric.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

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

public class AwaitingNoAsyncGeneric
{
[Fact]
public static void TestEntryPoint()
Comment thread
eduardo-vp marked this conversation as resolved.
{
Assert.Equal("hello", new Caller<string>().RunAsync("hello").GetAwaiter().GetResult());
Assert.Equal(42, new Caller<int>().RunAsync(42).GetAwaiter().GetResult());
}
}

public class Caller<T>
{
[MethodImpl(MethodImplOptions.NoInlining)]
public async ValueTask<T> RunAsync(T value)
{
return await Helper.GetValueAsync(value).ConfigureAwait(false);
}
}

public static class Helper
{
// Non-async method returning ValueTask<T>, so the compiler does not emit
// MethodImplAttributes.Async. This is the condition that can trigger a
// scanner/JIT mismatch.
[MethodImpl(MethodImplOptions.NoInlining)]
public static ValueTask<T> GetValueAsync<T>(T value)
{
return new ValueTask<T>(value);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.IL">
<PropertyGroup>
<!-- https://github.com/dotnet/runtime/issues/127179 -->
<NativeAotIncompatible>true</NativeAotIncompatible>
<!-- Needed due to NativeAotIncompatible -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>
Comment thread
eduardo-vp marked this conversation as resolved.
Comment thread
eduardo-vp marked this conversation as resolved.
</PropertyGroup>
Comment thread
eduardo-vp marked this conversation as resolved.
Comment thread
eduardo-vp marked this conversation as resolved.
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
Comment thread
eduardo-vp marked this conversation as resolved.
</ItemGroup>
</Project>
Loading