TaskTupleAwaiter icon indicating copy to clipboard operation
TaskTupleAwaiter copied to clipboard

Compile error when TaskTupleAwaiter is used with System.ValueTuple 4.6.1 on .NET Framework

Open jnm2 opened this issue 2 months ago • 3 comments

System.Text.Json 10.0.0 depends on System.ValueTuple 4.6.1. If you're on .NET Framework and you want to use System.Text.Json 10.0.0 and you use TaskTupleAwaiter, you will hit a slew of compile errors per await:

error CS0012: The type 'ValueTuple<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ValueTuple, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. error CS0012: The type '(, )' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ValueTuple, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. error CS0012: The type '(, , )' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ValueTuple, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. error CS0012: The type '(, , , )' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ValueTuple, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. error CS0012: The type '(, , , , )' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ValueTuple, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. error CS0012: The type '(, , , , , )' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ValueTuple, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. error CS0012: The type '(, , , , , , )' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ValueTuple, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. error CS0012: The type 'ValueTuple<,,,,,,,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ValueTuple, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.

This only affects TaskTupleAwaiter v1.1.0+. v1.0.0 and v1.0.1 do not have this problem. This also only affects the latest System.ValueTuple (4.6.1). The previous System.ValueTuple (4.5.0) does not have this problem.

Repro

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net48</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="System.ValueTuple" Version="4.6.1" />
    <PackageReference Include="TaskTupleAwaiter" Version="2.1.1" />
  </ItemGroup>

</Project>
using System.Threading.Tasks;

class C
{
    async Task M()
    {
        await (Task.FromResult(1), Task.FromResult(2));
    }
}

jnm2 avatar Nov 12 '25 00:11 jnm2