From 4553b845e436acfdd9cd21df6ac543edc5297d4a Mon Sep 17 00:00:00 2001 From: Alan McGovern Date: Wed, 8 Jun 2016 18:30:13 +0100 Subject: [PATCH] [Core] Allow Registrar.RegisterAll to be run multiple times (#215) There are cases where we run RegisterAll manually to ensure all assemblies have actually been registered. The `Registrar` class does not use the `Dictionary.Add` method so it does not throw if there's a clash/duplicate. If we change the `Effect` registration to use the same pattern we can remove errors like this: System.ArgumentException: An item with the same key has already been added. at ThrowArgumentException at offset 0 in file:line:column /Users/builder/data/lanes/2922/977921b7/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/throwhelper.cs:72:0 at Insert at offset 142 in file:line:column /Users/builder/data/lanes/2922/977921b7/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/collections/generic/dictionary.cs:336:0 at Add at offset 0 in file:line:column /Users/builder/data/lanes/2922/977921b7/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/collections/generic/dictionary.cs:192:0 at RegisterAll at in file:line:column :0:0 at at in file:line:column :0:0 at Invoke at offset 56 in file:line:column /Users/builder/data/lanes/2922/977921b7/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:295:0 --- Xamarin.Forms.Core/Registrar.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xamarin.Forms.Core/Registrar.cs b/Xamarin.Forms.Core/Registrar.cs index 92c2e53..1224edf 100644 --- a/Xamarin.Forms.Core/Registrar.cs +++ b/Xamarin.Forms.Core/Registrar.cs @@ -138,7 +138,7 @@ namespace Xamarin.Forms foreach (Attribute attribute in effectAttributes) { var effect = (ExportEffectAttribute)attribute; - Effects.Add(resolutionName + "." + effect.Id, effect.Type); + Effects [resolutionName + "." + effect.Id] = effect.Type; } } } -- 2.7.4