diff options
author | Atsushi Eno <atsushieno@veritas-vos-liberabit.com> | 2013-08-21 10:44:27 +0400 |
---|---|---|
committer | Atsushi Eno <atsushieno@veritas-vos-liberabit.com> | 2013-08-21 10:44:27 +0400 |
commit | 2d6335f6a7ca2d9513af155c1025fdd404344aaf (patch) | |
tree | a4392b973456d3f3c4d3957104cdbae4db22a370 /mcs/class/System.ServiceModel.Web | |
parent | bfff327c1020038d473e7180da9decbd0f412cc8 (diff) |
revert default serialization: ignore non-public members. Also need to exclude backing field in non-default serialization.
Diffstat (limited to 'mcs/class/System.ServiceModel.Web')
-rw-r--r-- | mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/TypeMap.cs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/TypeMap.cs b/mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/TypeMap.cs index 09886796b7f..3f1cbb510c9 100644 --- a/mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/TypeMap.cs +++ b/mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/TypeMap.cs @@ -33,6 +33,7 @@ using System.Globalization; using System.IO; using System.Linq; using System.Reflection; +using System.Runtime.CompilerServices; using System.Runtime.Serialization; using System.Text; using System.Xml; @@ -81,10 +82,11 @@ namespace System.Runtime.Serialization.Json static TypeMap CreateDefaultTypeMap (Type type) { var l = new List<TypeMapMember> (); - foreach (var fi in type.GetFields (binding_flags)) - l.Add (new TypeMapField (fi, null)); - foreach (var pi in type.GetProperties (binding_flags)) - if (pi.CanRead && pi.CanWrite && !pi.GetGetMethod ().IsStatic && pi.GetIndexParameters ().Length == 0) + foreach (var fi in type.GetFields ()) + if (!fi.IsStatic) + l.Add (new TypeMapField (fi, null)); + foreach (var pi in type.GetProperties ()) + if (pi.CanRead && pi.CanWrite && !pi.GetGetMethod (true).IsStatic && pi.GetIndexParameters ().Length == 0) l.Add (new TypeMapProperty (pi, null)); l.Sort ((x, y) => x.Order != y.Order ? x.Order - y.Order : String.Compare (x.Name, y.Name, StringComparison.Ordinal)); return new TypeMap (type, null, l.ToArray ()); @@ -116,6 +118,8 @@ namespace System.Runtime.Serialization.Json List<TypeMapMember> members = new List<TypeMapMember> (); foreach (FieldInfo fi in type.GetFields (binding_flags)) { + if (fi.GetCustomAttributes (typeof (CompilerGeneratedAttribute), false).Length > 0) + continue; if (dca != null) { object [] atts = fi.GetCustomAttributes (typeof (DataMemberAttribute), true); if (atts.Length == 0) |