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

@ -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]);
}
}
}
}