Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple equivalent target framework short names cause exception #6203

Closed
drewnoakes opened this issue May 19, 2020 · 2 comments · Fixed by #9008
Closed

Multiple equivalent target framework short names cause exception #6203

drewnoakes opened this issue May 19, 2020 · 2 comments · Fixed by #9008
Assignees
Labels
Feature-Dependency-Node "Dependencies" node in Solution Explorer that display project, binary & package references Feature-Multi-Targeting Targeting and building for multiple frameworks. Resolution-Fixed The bug has been fixed, refer to the milestone to see in which release it was fixed. Triage-Investigate Reviewed and investigation needed by dev team
Milestone

Comments

@drewnoakes
Copy link
Member

Visual Studio Version: master

Summary:

Multiple equivalent target framework short names cause exception.

Steps to Reproduce:

In this example, both foo and bar are unknown and map to Unsupported,Version=v0.0:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>foo;bar</TargetFrameworks>
  </PropertyGroup>
</Project>

In this example, both net48 and net4.8 are valid and map to .NETFramework,Version=v4.8:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>net48;net4.8</TargetFrameworks>
  </PropertyGroup>
</Project>

Expected Behavior:

No exception.

Actual Behavior:

System.ArgumentException: An element with the same key but a different value already exists.

System.AggregateException: Project system data flow 'DataflowBlockSlim (ActionBlockSlimAsync`1 : 2595789)' closed because of an exception: System.AggregateException: One or more errors occurred. ---> System.ArgumentException: An element with the same key but a different value already exists. Key: Unsupported,Version=v0.0
   at System.Collections.Immutable.ImmutableDictionary`2.HashBucket.Add(TKey key, TValue value, IEqualityComparer`1 keyOnlyComparer, IEqualityComparer`1 valueComparer, KeyCollisionBehavior behavior, OperationResult& result)
   at System.Collections.Immutable.ImmutableDictionary`2.AddRange(IEnumerable`1 items, MutationInput origin, KeyCollisionBehavior collisionBehavior)
   at System.Collections.Immutable.ImmutableDictionary`2.AddRange(IEnumerable`1 pairs, Boolean avoidToHashMap)
   at System.Collections.Immutable.ImmutableDictionary`2.AddRange(IEnumerable`1 pairs)
   at Microsoft.VisualStudio.ProjectSystem.Tree.Dependencies.Snapshot.DependenciesSnapshot.SetTargets(ImmutableArray`1 targetFrameworks, ITargetFramework activeTargetFramework)
   at Microsoft.VisualStudio.ProjectSystem.Tree.Dependencies.Subscriptions.DependenciesSnapshotProvider.<>c__DisplayClass31_0.<UpdateProjectContextAndSubscriptionsAsync>b__2(DependenciesSnapshot previousSnapshot)
   at Microsoft.VisualStudio.ProjectSystem.Tree.Dependencies.Subscriptions.DependenciesSnapshotProvider.SnapshotUpdater.TryUpdate(Func`2 updateFunc, CancellationToken token)
   at Microsoft.VisualStudio.ProjectSystem.Tree.Dependencies.Subscriptions.DependenciesSnapshotProvider.<<UpdateProjectContextAndSubscriptionsAsync>b__31_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Threading.SemaphoreSlimExtensions.<ExecuteWithinLockAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at Microsoft.VisualStudio.ProjectSystem.DataReceivingBlockSlim`1.<ProcessInputQueueAsync>d__5.MoveNext()
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.ArgumentException: An element with the same key but a different value already exists. Key: Unsupported,Version=v0.0
   at System.Collections.Immutable.ImmutableDictionary`2.HashBucket.Add(TKey key, TValue value, IEqualityComparer`1 keyOnlyComparer, IEqualityComparer`1 valueComparer, KeyCollisionBehavior behavior, OperationResult& result)
   at System.Collections.Immutable.ImmutableDictionary`2.AddRange(IEnumerable`1 items, MutationInput origin, KeyCollisionBehavior collisionBehavior)
   at System.Collections.Immutable.ImmutableDictionary`2.AddRange(IEnumerable`1 pairs, Boolean avoidToHashMap)
   at System.Collections.Immutable.ImmutableDictionary`2.AddRange(IEnumerable`1 pairs)
   at Microsoft.VisualStudio.ProjectSystem.Tree.Dependencies.Snapshot.DependenciesSnapshot.SetTargets(ImmutableArray`1 targetFrameworks, ITargetFramework activeTargetFramework)
   at Microsoft.VisualStudio.ProjectSystem.Tree.Dependencies.Subscriptions.DependenciesSnapshotProvider.<>c__DisplayClass31_0.<UpdateProjectContextAndSubscriptionsAsync>b__2(DependenciesSnapshot previousSnapshot)
   at Microsoft.VisualStudio.ProjectSystem.Tree.Dependencies.Subscriptions.DependenciesSnapshotProvider.SnapshotUpdater.TryUpdate(Func`2 updateFunc, CancellationToken token)
   at Microsoft.VisualStudio.ProjectSystem.Tree.Dependencies.Subscriptions.DependenciesSnapshotProvider.<<UpdateProjectContextAndSubscriptionsAsync>b__31_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Threading.SemaphoreSlimExtensions.<ExecuteWithinLockAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at Microsoft.VisualStudio.ProjectSystem.DataReceivingBlockSlim`1.<ProcessInputQueueAsync>d__5.MoveNext()<---
. ---> System.ArgumentException: An element with the same key but a different value already exists. Key: Unsupported,Version=v0.0
   at System.Collections.Immutable.ImmutableDictionary`2.HashBucket.Add(TKey key, TValue value, IEqualityComparer`1 keyOnlyComparer, IEqualityComparer`1 valueComparer, KeyCollisionBehavior behavior, OperationResult& result)
   at System.Collections.Immutable.ImmutableDictionary`2.AddRange(IEnumerable`1 items, MutationInput origin, KeyCollisionBehavior collisionBehavior)
   at System.Collections.Immutable.ImmutableDictionary`2.AddRange(IEnumerable`1 pairs, Boolean avoidToHashMap)
   at System.Collections.Immutable.ImmutableDictionary`2.AddRange(IEnumerable`1 pairs)
   at Microsoft.VisualStudio.ProjectSystem.Tree.Dependencies.Snapshot.DependenciesSnapshot.SetTargets(ImmutableArray`1 targetFrameworks, ITargetFramework activeTargetFramework)
   at Microsoft.VisualStudio.ProjectSystem.Tree.Dependencies.Subscriptions.DependenciesSnapshotProvider.<>c__DisplayClass31_0.<UpdateProjectContextAndSubscriptionsAsync>b__2(DependenciesSnapshot previousSnapshot)
   at Microsoft.VisualStudio.ProjectSystem.Tree.Dependencies.Subscriptions.DependenciesSnapshotProvider.SnapshotUpdater.TryUpdate(Func`2 updateFunc, CancellationToken token)
   at Microsoft.VisualStudio.ProjectSystem.Tree.Dependencies.Subscriptions.DependenciesSnapshotProvider.<<UpdateProjectContextAndSubscriptionsAsync>b__31_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Threading.SemaphoreSlimExtensions.<ExecuteWithinLockAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at Microsoft.VisualStudio.ProjectSystem.DataReceivingBlockSlim`1.<ProcessInputQueueAsync>d__5.MoveNext()
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.ArgumentException: An element with the same key but a different value already exists. Key: Unsupported,Version=v0.0
   at System.Collections.Immutable.ImmutableDictionary`2.HashBucket.Add(TKey key, TValue value, IEqualityComparer`1 keyOnlyComparer, IEqualityComparer`1 valueComparer, KeyCollisionBehavior behavior, OperationResult& result)
   at System.Collections.Immutable.ImmutableDictionary`2.AddRange(IEnumerable`1 items, MutationInput origin, KeyCollisionBehavior collisionBehavior)
   at System.Collections.Immutable.ImmutableDictionary`2.AddRange(IEnumerable`1 pairs, Boolean avoidToHashMap)
   at System.Collections.Immutable.ImmutableDictionary`2.AddRange(IEnumerable`1 pairs)
   at Microsoft.VisualStudio.ProjectSystem.Tree.Dependencies.Snapshot.DependenciesSnapshot.SetTargets(ImmutableArray`1 targetFrameworks, ITargetFramework activeTargetFramework)
   at Microsoft.VisualStudio.ProjectSystem.Tree.Dependencies.Subscriptions.DependenciesSnapshotProvider.<>c__DisplayClass31_0.<UpdateProjectContextAndSubscriptionsAsync>b__2(DependenciesSnapshot previousSnapshot)
   at Microsoft.VisualStudio.ProjectSystem.Tree.Dependencies.Subscriptions.DependenciesSnapshotProvider.SnapshotUpdater.TryUpdate(Func`2 updateFunc, CancellationToken token)
   at Microsoft.VisualStudio.ProjectSystem.Tree.Dependencies.Subscriptions.DependenciesSnapshotProvider.<<UpdateProjectContextAndSubscriptionsAsync>b__31_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Threading.SemaphoreSlimExtensions.<ExecuteWithinLockAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at Microsoft.VisualStudio.ProjectSystem.DataReceivingBlockSlim`1.<ProcessInputQueueAsync>d__5.MoveNext()<---

User Impact:

Yellow bar. Dependencies tree dataflow closed.

@drewnoakes drewnoakes added Bug Feature-Dependency-Node "Dependencies" node in Solution Explorer that display project, binary & package references labels May 19, 2020
@drewnoakes
Copy link
Member Author

This code path would change (and likely be addressed by) #6183.

@jjmew jjmew added this to the 16.8 milestone May 22, 2020
@jjmew jjmew added the Triage-Investigate Reviewed and investigation needed by dev team label May 22, 2020
@drewnoakes drewnoakes added the Feature-Multi-Targeting Targeting and building for multiple frameworks. label Jul 24, 2020
@drewnoakes drewnoakes modified the milestones: 16.8, 16.9 Jul 24, 2020
@drewnoakes drewnoakes modified the milestones: 16.9, 16.10 Nov 23, 2020
@drewnoakes drewnoakes modified the milestones: 16.10, 17.0 May 11, 2021
@drewnoakes drewnoakes modified the milestones: 17.0, 17.1 Aug 10, 2021
@drewnoakes drewnoakes modified the milestones: 17.1, 17.x Nov 19, 2021
@drewnoakes
Copy link
Member Author

With rewrite:

image

@ghost ghost added the Resolution-Fixed The bug has been fixed, refer to the milestone to see in which release it was fixed. label May 16, 2023
@drewnoakes drewnoakes removed the Bug label Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature-Dependency-Node "Dependencies" node in Solution Explorer that display project, binary & package references Feature-Multi-Targeting Targeting and building for multiple frameworks. Resolution-Fixed The bug has been fixed, refer to the milestone to see in which release it was fixed. Triage-Investigate Reviewed and investigation needed by dev team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants