none
Can I Disable EmitDefaultValue=false for Generated DataMember Attribute? RRS feed

  • Question

  • When I set the SerializationMode to Unidirectional and set the ChildProperty of an associated entity to false on a given entity the generated property of the entity class gets a DataMember attribute assigned with EmitDefaultValue=false.  This prohibits the property value from being serialized.  If I manually go into the generated file and remove the EmitDefaultValue property from the attribute, the serialization works fine.
     
    Wednesday, January 5, 2011 6:37 PM

Answers

  • Ok so a little more background that ultimately must be causing the "issue":  I'm running this serialization operation inside a PostSharp OnExit aspect.  My type to be serialized isn't known at compile time.  I got this to work by making the runtime aware of the properties by iterating through the PropertyInfo[] PropertyValues of the given object.  Luckily I don't need this function to run all the time, just to make stub files for testing.
    • Marked as answer by ajamrozek Wednesday, January 5, 2011 11:05 PM
    Wednesday, January 5, 2011 11:03 PM

All replies

  • Update: The object is serializing with EmitDefaultValue=false when I interrogate the object in debug mode.  If i just let it run normally, my object only serializes at the topmost level - the reference type properties don't serialize.  Still need help here...
    Wednesday, January 5, 2011 8:27 PM
  • Ok so a little more background that ultimately must be causing the "issue":  I'm running this serialization operation inside a PostSharp OnExit aspect.  My type to be serialized isn't known at compile time.  I got this to work by making the runtime aware of the properties by iterating through the PropertyInfo[] PropertyValues of the given object.  Luckily I don't need this function to run all the time, just to make stub files for testing.
    • Marked as answer by ajamrozek Wednesday, January 5, 2011 11:05 PM
    Wednesday, January 5, 2011 11:03 PM