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

Don't use Dictionary<K,V> to avoid duplicate value exception (#7340) #7345

Merged

Conversation

jonathanpeppers
Copy link
Member

Backport of #7340
(There were some minor merge conflicts)

Fixes: #7302
Context: 7117414

When building .NET6 app on .NET7, sometimes the build fails with:

C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.451\tools\Xamarin.Android.Common.targets(1438,3): error XAGJS7004: System.ArgumentException: An item with the same key has already been added.
 at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
 at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
 at Xamarin.Android.Tasks.TypeMapGenerator.GenerateRelease(Boolean skipJniAddNativeMethodRegistrationAttributeScan, List`1 javaTypes, String outputDirectory, ApplicationConfigTaskState appConfState)
 at Xamarin.Android.Tasks.GenerateJavaStubs.WriteTypeMappings(List`1 types, TypeDefinitionCache cache)
 at Xamarin.Android.Tasks.GenerateJavaStubs.Run(DirectoryAssemblyResolver res)
 at Xamarin.Android.Tasks.GenerateJavaStubs.RunTask()
 at Microsoft.Android.Build.Tasks.AndroidTask.Execute() in /Users/runner/work/1/s/xamarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/AndroidTask.cs:line 17

Avoid that by switching the data structure to List<T>, since we no longer use the Dictionary key for anything.

…7340)

Fixes: dotnet#7302
Context: dotnet@7117414

When building .NET6 app on .NET7, sometimes the build fails with:

    C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.451\tools\Xamarin.Android.Common.targets(1438,3): error XAGJS7004: System.ArgumentException: An item with the same key has already been added.
     at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
     at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
     at Xamarin.Android.Tasks.TypeMapGenerator.GenerateRelease(Boolean skipJniAddNativeMethodRegistrationAttributeScan, List`1 javaTypes, String outputDirectory, ApplicationConfigTaskState appConfState)
     at Xamarin.Android.Tasks.GenerateJavaStubs.WriteTypeMappings(List`1 types, TypeDefinitionCache cache)
     at Xamarin.Android.Tasks.GenerateJavaStubs.Run(DirectoryAssemblyResolver res)
     at Xamarin.Android.Tasks.GenerateJavaStubs.RunTask()
     at Microsoft.Android.Build.Tasks.AndroidTask.Execute() in /Users/runner/work/1/s/xamarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/AndroidTask.cs:line 17

Avoid that by switching the data structure to `List<T>`, since we no
longer use the Dictionary key for anything.
@jonathanpeppers jonathanpeppers merged commit a220db5 into dotnet:release/6.0.4xx Sep 7, 2022
@jonathanpeppers jonathanpeppers deleted the backport-7340 branch September 7, 2022 04:44
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants