-Fixed using extension data with dictionary that explicitly implements Add method

This commit is contained in:
James Newton-King
2018-01-27 19:20:02 +13:00
parent 6360cc4c4b
commit d6c3794556
2 changed files with 88 additions and 0 deletions
@@ -495,6 +495,13 @@ namespace Newtonsoft.Json.Serialization
: null;
Func<object> createExtensionDataDictionary = JsonTypeReflector.ReflectionDelegateFactory.CreateDefaultConstructor<object>(createdType);
MethodInfo addMethod = t.GetMethod("Add", new[] { keyType, valueType });
if (addMethod == null)
{
// Add is explicitly implemented and non-public
// get from dictionary interface
addMethod = dictionaryType.GetMethod("Add", new[] {keyType, valueType});
}
MethodCall<object, object> setExtensionDataDictionaryValue = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall<object>(addMethod);
ExtensionDataSetter extensionDataSetter = (o, key, value) =>