You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Get ambiguous type identity error when using package 'Microsoft.CodeAnalysis.CSharp/2.0.0' in a project that targets 'netcoreapp2.0' #20861
I ran into this when using the package Microsoft.CodeAnalysis.CSharp/2.0.0 (2.0.0 is the latest version I can find) in my project targeting netcoreapp2.0. Microsoft.CodeAnalysis.CSharp/2.0.0 depends on Microsoft.CodeAnalysis.Common/2.0.0 which pulls in System.ValueTuple/4.3.0. However, the types in System.ValueTuple.dll are already exposed from System.Runtime.dll when targeting netcoreapp2.0, and thus using any of those types results in ambiguous type identity error:
Program.cs(9,45): error CS0433: The type 'TupleExtensions' exists in both 'System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' and 'System.Runtime, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [D:\apps\netcore2\test\test.csproj]
It looks netcoreapp2.0 doesn't come with Microsoft.CodeAnalysis.CSharp.dll and Microsoft.CodeAnalysis.dll. How should I consume the Microsoft.CodeAnalysis.CSharp package then?
CoreFx was updated to type-forward to System.Runtime (PR dotnet/corefx#14786).
But this was done after the initial release of the ValueTuple package (4.3.0). @ericstj is about to publish an updated package (for mono), which I suspect will also contain those type-forwards. I'll let him confirm if that's the case.
@weshaggard it works fine after referencing to a recent version of System.ValueTuple package. Thanks!
This is because ValueTuple hasn't been added to the shared framework yet.
I guess once ValueTuple is added to the shared framework, I won't need to reference to System.ValueTuple/4.4.0-preview1-25203-01 in order to use Microsoft.CodeAnalysis.CSharp/2.0.0, is that correct?
I guess once ValueTuple is added to the shared framework, I won't need to reference to System.ValueTuple/4.4.0-preview1-25203-01 in order to use Microsoft.CodeAnalysis.CSharp/2.0.0, is that correct?
@weshaggard I'm not very familiar with the concept of shared framework. I looked at your PRs from early April. I saw you did some netstandard changes (both in corefx and standard repos) for ValueTuple. Were those related to the shared framework?
Activity
karelz commentedon Apr 2, 2017
@weshaggard @ericeil @jcouv what is the story around
ValueTuple? I know it was somewhat special, but don't remember details ...cc @terrajobst
jcouv commentedon Apr 2, 2017
CoreFx was updated to type-forward to System.Runtime (PR dotnet/corefx#14786).
But this was done after the initial release of the ValueTuple package (4.3.0).
@ericstj is about to publish an updated package (for mono), which I suspect will also contain those type-forwards. I'll let him confirm if that's the case.
weshaggard commentedon Apr 3, 2017
This is because ValueTuple hasn't been added to the shared framework yet. I'm going to take care of this today.
@daxian-dbw you can workaround this issue by referencing the latest System.ValueTuple package from myget (https://dotnet.myget.org/feed/dotnet-core/package/nuget/System.ValueTuple/4.4.0-preview1-25203-01).
daxian-dbw commentedon Apr 3, 2017
@weshaggard it works fine after referencing to a recent version of
System.ValueTuplepackage. Thanks!I guess once
ValueTupleis added to the shared framework, I won't need to reference toSystem.ValueTuple/4.4.0-preview1-25203-01in order to useMicrosoft.CodeAnalysis.CSharp/2.0.0, is that correct?weshaggard commentedon Apr 3, 2017
That's correct.
danmoseley commentedon Apr 3, 2017
@daxian-dbw sounds like this is resolved, I"ll close , feel free to reopen
Move powershell to .NET Core 2.0 (#3556)
jcouv commentedon May 12, 2017
@weshaggard I'm not very familiar with the concept of shared framework. I looked at your PRs from early April. I saw you did some netstandard changes (both in corefx and standard repos) for ValueTuple. Were those related to the shared framework?
weshaggard commentedon May 12, 2017
I did a lot of changes you will need to be more specific. I can tell you that ValueTuple has been added to the shared framework for .NET Core.
jcouv commentedon May 12, 2017
Cool. That addresses my question. Thanks! :-)