@@ -518,6 +518,8 @@ public static bool EscapeUnicode
518518
519519 internal static HashSet < Type > HasSerializeFn = new HashSet < Type > ( ) ;
520520
521+ internal static HashSet < Type > HasIncludeDefaultValue = new HashSet < Type > ( ) ;
522+
521523 public static HashSet < Type > TreatValueAsRefTypes = new HashSet < Type > ( ) ;
522524
523525 private static bool ? sPreferInterfaces ;
@@ -658,6 +660,10 @@ public static void Reset()
658660 {
659661 Reset ( rawSerializeType ) ;
660662 }
663+ foreach ( var rawSerializeType in HasIncludeDefaultValue . ToArray ( ) )
664+ {
665+ Reset ( rawSerializeType ) ;
666+ }
661667 foreach ( var uniqueType in __uniqueTypes . ToArray ( ) )
662668 {
663669 Reset ( uniqueType ) ;
@@ -688,6 +694,7 @@ public static void Reset()
688694 sIncludePublicFields = null ;
689695 sReuseStringBuffer = null ;
690696 HasSerializeFn = new HashSet < Type > ( ) ;
697+ HasIncludeDefaultValue = new HashSet < Type > ( ) ;
691698 TreatValueAsRefTypes = new HashSet < Type > { typeof ( KeyValuePair < , > ) } ;
692699 sPropertyConvention = null ;
693700 sExcludePropertyReferences = null ;
@@ -755,6 +762,20 @@ public class JsConfig<T>
755762
756763 public static bool ? EmitLowercaseUnderscoreNames = null ;
757764
765+ public static bool IncludeDefaultValue
766+ {
767+ get { return JsConfig . HasIncludeDefaultValue . Contains ( typeof ( T ) ) ; }
768+ set
769+ {
770+ if ( value )
771+ JsConfig . HasIncludeDefaultValue . Add ( typeof ( T ) ) ;
772+ else
773+ JsConfig . HasIncludeDefaultValue . Remove ( typeof ( T ) ) ;
774+
775+ ClearFnCaches ( ) ;
776+ }
777+ }
778+
758779 /// <summary>
759780 /// Define custom serialization fn for BCL Structs
760781 /// </summary>
0 commit comments