diff --git a/ser/XmlFormatter2.cs b/ser/XmlFormatter2.cs index b9f13a1..d960bc6 100644 --- a/ser/XmlFormatter2.cs +++ b/ser/XmlFormatter2.cs @@ -561,6 +561,7 @@ namespace lib string name = childFi.Name; var dontAtt = childFi.GetCustomAttributes(); + var doAtt = childFi.GetCustomAttributes(); string propName = ""; @@ -573,6 +574,8 @@ namespace lib var propInfo = narrowType.GetProperty( propName ); dontAtt = propInfo.GetCustomAttributes(); + + doAtt = propInfo.GetCustomAttributes(); } if( dontAtt.Any() ) @@ -586,7 +589,7 @@ namespace lib name = refl.TypeToIdentifier( name ); // @@@ TODO This doesnt yet handle propNames! - if( FilterField( filterFields, doImpls, whitelistFields, childFi as MemberInfo, name ) ) + if( !doAtt.Any() && FilterField( filterFields, doImpls, whitelistFields, childFi as MemberInfo, name ) ) continue; var useFieldName = true; @@ -641,9 +644,12 @@ namespace lib continue; } + var doAtt = childPi.GetCustomAttributes(); + + name = refl.TypeToIdentifier( name ); - if( FilterField( filterProps, doImpls, whitelistProps, childPi as PropertyInfo, name ) ) + if( !doAtt.Any() && FilterField( filterProps, doImpls, whitelistProps, childPi as PropertyInfo, name ) ) continue; XmlElement childElem = getNamedChild( allChildren, name ); @@ -1338,6 +1344,7 @@ namespace lib { string name = childFi.Name; var dontAtt = childFi.GetCustomAttributes(); + var doAtt = childFi.GetCustomAttributes(); string propName = ""; if( name.StartsWith( "<" ) && name.EndsWith( "BackingField" ) ) @@ -1349,6 +1356,7 @@ namespace lib var propInfo = narrowType.GetProperty( propName ); dontAtt = propInfo.GetCustomAttributes(); + doAtt = propInfo.GetCustomAttributes(); } @@ -1363,7 +1371,7 @@ namespace lib if( name == "Fn" ) continue; } - if( FilterField( filterFields, doImpls, whitelistFields, childFi as MemberInfo, name ) ) + if( !doAtt.Any() && FilterField( filterFields, doImpls, whitelistFields, childFi as MemberInfo, name ) ) continue; object[] objs = childFi.GetCustomAttributes( typeof( NonSerializedAttribute ), true ); @@ -1429,15 +1437,15 @@ namespace lib var custWLProps = mi?.GetCustomAttribute( true ); filterFields = custWLFields != null; - filterProps = custWLProps != null; + filterProps = custWLProps != null; var typesTodo = type.GetCustomAttribute( true )?.Types ?? TypesDefault; - doImpls = typesTodo.HasFlag( Types.Implied ); + doImpls = typesTodo.HasFlag( Types.Implied ); doFields = filterFields || typesTodo.HasFlag( Types.Fields ); - doProps = filterProps || typesTodo.HasFlag( Types.Props ); + doProps = filterProps || typesTodo.HasFlag( Types.Props ); whitelistFields = new( custWLFields?.Values ?? new string[0] ); - whitelistProps = new( custWLProps?.Values ?? new string[0] ); + whitelistProps = new( custWLProps?.Values ?? new string[0] ); } private void SerializeArray( XmlWriter writer, MemberInfo mi, Type mType, object root, int depth )