Imported Upstream version 5.18.0.142

Former-commit-id: 7467d4b717762eeaf652d77f1486dd11ffb1ff1f
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-10-09 08:20:59 +00:00
parent e52655b4dc
commit 0abdbe5a7d
1547 changed files with 93792 additions and 47893 deletions

View File

@@ -13,6 +13,8 @@ LIB_MCS_FLAGS = \
$(RESOURCE_FILES:%=/resource:%)
TXT_RESOURCE_STRINGS = ../referencesource/System.Runtime.Serialization/System.Runtime.Serialization.txt
XTEST_LIB_REFS = System System.Core System.Xml System.Xml.Linq System.Drawing Facades/System.Threading.Tasks
ifneq (2.1, $(FRAMEWORK_VERSION))
LIB_REFS += System.Data System.Configuration SMDiagnostics
LIB_MCS_FLAGS += /d:NET_3_0
@@ -34,8 +36,6 @@ TEST_LIB_REFS = System.ServiceModel System.Web.Services
EXTRA_DISTFILES = $(RESOURCE_FILES) $(TEST_RESOURCE_FILES) \
Test/Resources/FrameworkTypes/* \
Test/Resources/Schemas/*.xsd \
Test/System.Runtime.Serialization/one.xml \
ReferenceSource.common.sources \
ReferenceSource.desktop.sources
Test/System.Runtime.Serialization/one.xml
include ../../build/library.make

View File

@@ -508,7 +508,9 @@ namespace System.Runtime.Serialization.Json
var jsonMemberName = XmlObjectSerializerReadContextComplexJson.GetJsonMemberName (xmlReader);
object key = null;
if (keyParseMode == KeyParseMode.UsingParseEnum)
if (keyParseMode == KeyParseMode.AsString)
key = jsonMemberName;
else if (keyParseMode == KeyParseMode.UsingParseEnum)
key = Enum.Parse (keyType, jsonMemberName);
else if (keyParseMode == KeyParseMode.UsingCustomParse)
key = keyDataContract.ParseMethod.Invoke (null, new object [] {jsonMemberName});

View File

@@ -0,0 +1,5 @@
#../../../external/corefx/src/System.Runtime.Serialization.Json/tests/DataContractJsonSerializer.cs
../../../external/corefx/src/System.Runtime.Serialization.Xml/tests/SerializationTypes.cs
../../../external/corefx/src/System.Runtime.Serialization.Xml/tests/SerializationTypes.RuntimeOnly.cs
../../../external/corefx/src/Common/tests/System/Runtime/Serialization/Utils.cs
../../../external/corefx/src/CoreFx.Private.TestUtilities/src/System/AssertExtensions.cs

View File

@@ -879,5 +879,30 @@ namespace MonoTests.System.Runtime.Serialization.Json
Assert.AreEqual (typeof (string []), result.GetType ());
}
}
[Test] //https://github.com/mono/mono/issues/9332
public void SimpleStringDictionaryTest ()
{
string json = "{\"key\": \"value\"}";
// Dictionary<string, string>:
using (var stream = new MemoryStream (Encoding.UTF8.GetBytes (json))) {
var serializer = new DataContractJsonSerializer (typeof (Dictionary<string, string>),
new DataContractJsonSerializerSettings { UseSimpleDictionaryFormat = true });
var obj = serializer.ReadObject (stream) as Dictionary<string, string>;
Assert.AreEqual ("value", obj ["key"]);
}
// Dictionary<int, string>:
json = "{\"42\": \"value\"}";
using (var stream = new MemoryStream (Encoding.UTF8.GetBytes (json))) {
var serializer = new DataContractJsonSerializer (typeof (Dictionary<int, string>),
new DataContractJsonSerializerSettings { UseSimpleDictionaryFormat = true });
var obj = serializer.ReadObject (stream) as Dictionary<int, string>;
Assert.AreEqual ("value", obj [42]);
}
}
}
}