From e26db4576db11c4cd48ca864b990ab0fc56edd1b Mon Sep 17 00:00:00 2001 From: Geoff Norton Date: Fri, 13 Mar 2009 00:09:51 +0000 Subject: [PATCH] 2009-03-12 Geoff Norton * TypeMap.cs: Avoid checking the getter/setter information until after checking if we have the required attribute decorated. svn path=/trunk/mcs/; revision=129232 --- .../System.Runtime.Serialization.Json/ChangeLog | 5 +++++ .../System.Runtime.Serialization.Json/TypeMap.cs | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/ChangeLog b/mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/ChangeLog index 7f8a0a3bdb9..af49e4daf56 100644 --- a/mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/ChangeLog +++ b/mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/ChangeLog @@ -1,3 +1,8 @@ +2009-03-12 Geoff Norton + + * TypeMap.cs: Avoid checking the getter/setter information until after + checking if we have the required attribute decorated. + 2009-03-12 Andreia Gaita * JsonReaderWriterFactory.cs: try to auto-detect encoding for streams 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 ff86987d7eb..9bf3583ebcd 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 @@ -121,17 +121,17 @@ namespace System.Runtime.Serialization.Json if (dca != null) { foreach (PropertyInfo pi in type.GetProperties (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) { - if (pi.GetIndexParameters ().Length > 0) continue; + object [] atts = pi.GetCustomAttributes (typeof (DataMemberAttribute), true); + if (atts.Length == 0) + continue; + if (pi.GetIndexParameters ().Length > 0) if (IsCollection (pi.PropertyType)) { if (!pi.CanRead) throw new InvalidDataContractException (String.Format ("Property {0} must have a getter", pi)); } else if (!pi.CanRead || !pi.CanWrite) throw new InvalidDataContractException (String.Format ("Non-collection property {0} must have both getter and setter", pi)); - object [] atts = pi.GetCustomAttributes (typeof (DataMemberAttribute), true); - if (atts.Length == 0) - continue; DataMemberAttribute dma = (DataMemberAttribute) atts [0]; members.Add (new TypeMapProperty (pi, dma)); } -- 2.11.4.GIT