Skip to content

System.ValueTuple 4.6.1 dropped the reference assembly for net471+, causing unresolvable compile errors in some cases #243

@jnm2

Description

@jnm2

Scenario:

  • Community library TaskTupleAwaiter references System.ValueTuple 4.3.1 and includes a net462 target. Therefore, the APIs in the TaskTupleAwaiter binaries reference System.ValueTuple, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51.
  • An application targeting net48 references TaskTupleAwaiter. All is well; the System.ValueTuple 4.5.0 package gives the C# compiler its net47 System.ValueTuple ref assembly.
  • Then, the application wants to upgrade its System.Text.Json dependency from v9 to v10. System.Text.Json 10.0.0 depends on System.ValueTuple 4.6.1, forcing the application to use the latter.
  • System.ValueTuple 4.6.1 now has an empty net471 folder, so no System.ValueTuple ref assembly is given to the C# compiler.
  • The application fails to compile when any TaskTupleAwaiter API is used which references System.ValueTuple, with the following errors:

    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'.

.NET Framework 4.8 defines ValueTuple in mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, and it includes a shim library System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51.

I think no binding redirect is created for the System.ValueTuple assembly because there are no conflicts after a NuGet restore, because System.ValueTuple 4.6.1 stopped putting its additional System.ValueTuple assembly in the mix. But this also looks intentional:

<Target Name="RemoveValueTupleRedirectForNet471AndAbove" DependsOnTargets="ResolveAssemblyReferences" BeforeTargets="GenerateBindingRedirects">
<ItemGroup>
<SuggestedBindingRedirects Remove="System.ValueTuple, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" />
</ItemGroup>
</Target>

I expect it is the job of the System.ValueTuple package to provide the correct type forwards and/or binding redirects, given that community binaries have references to System.ValueTuple, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 because they compiled against the System.ValueTuple 4.3.1 package.

The consuming app seems to have no way to resolve this issue. There is no way to target .NET Framework 4.7.1+, while using System.Text.Json 10.0.0+, while also using TaskTupleAwaiter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions