Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAtsushi Eno <atsushieno@gmail.com>2015-06-22 14:12:38 +0300
committerAtsushi Eno <atsushieno@gmail.com>2015-06-22 14:12:38 +0300
commitcc9ddec7c4ba55f77e0e3bcec6ce39f292c81a03 (patch)
treebe3cd4591f0a73881e76d873e8747d0028fb363a /mcs/class/System.ServiceModel.Web
parent0780c58b982711f0bbbfa2906a7a0942ac572db9 (diff)
[S.R.Serialization] fix default value comparison.
The fixed code used to invoke null.Equals(other). The new test (by @alien0ada) shows the failing case.
Diffstat (limited to 'mcs/class/System.ServiceModel.Web')
-rw-r--r--mcs/class/System.ServiceModel.Web/Test/System.Runtime.Serialization.Json/DataContractJsonSerializerTest.cs57
1 files changed, 56 insertions, 1 deletions
diff --git a/mcs/class/System.ServiceModel.Web/Test/System.Runtime.Serialization.Json/DataContractJsonSerializerTest.cs b/mcs/class/System.ServiceModel.Web/Test/System.Runtime.Serialization.Json/DataContractJsonSerializerTest.cs
index bb7c1d9f579..bede256b8c9 100644
--- a/mcs/class/System.ServiceModel.Web/Test/System.Runtime.Serialization.Json/DataContractJsonSerializerTest.cs
+++ b/mcs/class/System.ServiceModel.Web/Test/System.Runtime.Serialization.Json/DataContractJsonSerializerTest.cs
@@ -1894,6 +1894,32 @@ namespace MonoTests.System.Runtime.Serialization.Json
public class IntList : List<int>{}
#endregion
+
+ [Test]
+ public void DefaultValueDeserialization ()
+ {
+ // value type
+ var person = new Person { name = "John" };
+ using (var ms = new MemoryStream()) {
+ var serializer = new DataContractJsonSerializer (typeof (Person), new DataContractJsonSerializerSettings {
+ SerializeReadOnlyTypes = true,
+ UseSimpleDictionaryFormat = true
+ });
+ serializer.WriteObject (ms, person);
+ }
+
+ // reference type
+ var person2 = new PersonWithContact {
+ name = "Jane",
+ contact = new Contact { url = "localhost", email = "jane@localhost" } };
+ using (var ms = new MemoryStream ()) {
+ var serializer = new DataContractJsonSerializer (typeof (PersonWithContact), new DataContractJsonSerializerSettings {
+ SerializeReadOnlyTypes = true,
+ UseSimpleDictionaryFormat = true
+ });
+ serializer.WriteObject (ms, person2);
+ }
+ }
}
public class CharTest
@@ -2685,4 +2711,33 @@ public class Bug13485Type
}
}
-#endregion \ No newline at end of file
+#endregion
+
+#region DefaultValueDeserialization
+ [DataContract]
+ public class Person
+ {
+ [DataMember(EmitDefaultValue = false)]
+ public string name { get; set; }
+ }
+
+ [DataContract]
+ public class PersonWithContact
+ {
+ [DataMember(EmitDefaultValue = false)]
+ public string name { get; set; }
+
+ [DataMember(EmitDefaultValue = false)]
+ public Contact contact { get; set; }
+ }
+
+ [DataContract]
+ public class Contact
+ {
+ [DataMember(EmitDefaultValue = false)]
+ public string url { get; set; }
+
+ [DataMember(EmitDefaultValue = false)]
+ public string email{ get; set; }
+ }
+#endregion