Title: Added support for 'Do' attribute in XML Formatter

x) Introduced the 'Do' attribute to the XML formatter.
x) The 'Do' attribute is now fetched and checked before filtering fields and properties.
x) This change allows more granular control over serialization, as items marked with the 'Do' attribute will not be filtered out.
x) Adjusted formatting in some areas for consistency.
This commit is contained in:
Marc Hernandez 2024-07-29 20:25:22 -07:00
parent b0b9496c4a
commit b66bc4e5ed

View File

@ -561,6 +561,7 @@ namespace lib
string name = childFi.Name;
var dontAtt = childFi.GetCustomAttributes<lib.Dont>();
var doAtt = childFi.GetCustomAttributes<lib.Do>();
string propName = "";
@ -573,6 +574,8 @@ namespace lib
var propInfo = narrowType.GetProperty( propName );
dontAtt = propInfo.GetCustomAttributes<lib.Dont>();
doAtt = propInfo.GetCustomAttributes<lib.Do>();
}
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<lib.Do>();
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<lib.Dont>();
var doAtt = childFi.GetCustomAttributes<lib.Do>();
string propName = "";
if( name.StartsWith( "<" ) && name.EndsWith( "BackingField" ) )
@ -1349,6 +1356,7 @@ namespace lib
var propInfo = narrowType.GetProperty( propName );
dontAtt = propInfo.GetCustomAttributes<lib.Dont>();
doAtt = propInfo.GetCustomAttributes<lib.Do>();
}
@ -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 );