@@ -120,10 +120,27 @@ private Config(Config config)
120120 public bool TreatEnumAsInteger { get ; set ; }
121121 public bool ExcludeTypeInfo { get ; set ; }
122122 public bool IncludeTypeInfo { get ; set ; }
123- public string TypeAttr { get ; set ; }
123+
124+ private string typeAttr ;
125+ public string TypeAttr
126+ {
127+ get => typeAttr ;
128+ set
129+ {
130+ typeAttrSpan = null ;
131+ jsonTypeAttrInObject = null ;
132+ jsvTypeAttrInObject = null ;
133+ typeAttr = value ;
134+ }
135+ }
136+ ReadOnlyMemory < char > ? typeAttrSpan = null ;
137+ public ReadOnlyMemory < char > TypeAttrMemory => typeAttrSpan ??= TypeAttr . AsMemory ( ) ;
124138 public string DateTimeFormat { get ; set ; }
125- internal string JsonTypeAttrInObject { get ; set ; }
126- internal string JsvTypeAttrInObject { get ; set ; }
139+ private string jsonTypeAttrInObject ;
140+ internal string JsonTypeAttrInObject => jsonTypeAttrInObject ??= JsonTypeSerializer . GetTypeAttrInObject ( TypeAttr ) ;
141+ private string jsvTypeAttrInObject ;
142+ internal string JsvTypeAttrInObject => jsvTypeAttrInObject ??= JsvTypeSerializer . GetTypeAttrInObject ( TypeAttr ) ;
143+
127144 public Func < Type , string > TypeWriter { get ; set ; }
128145 public Func < string , Type > TypeFinder { get ; set ; }
129146 public Func < string , object > ParsePrimitiveFn { get ; set ; }
@@ -180,8 +197,6 @@ public bool EmitLowercaseUnderscoreNames
180197 IncludeTypeInfo = false ,
181198 TypeAttr = JsWriter . TypeAttr ,
182199 DateTimeFormat = null ,
183- JsonTypeAttrInObject = JsonTypeSerializer . GetTypeAttrInObject ( JsWriter . TypeAttr ) ,
184- JsvTypeAttrInObject = JsvTypeSerializer . GetTypeAttrInObject ( JsWriter . TypeAttr ) ,
185200 TypeWriter = AssemblyUtils . WriteType ,
186201 TypeFinder = AssemblyUtils . FindType ,
187202 ParsePrimitiveFn = null ,
@@ -222,8 +237,6 @@ public Config Populate(Config config)
222237 IncludeTypeInfo = config . IncludeTypeInfo ;
223238 TypeAttr = config . TypeAttr ;
224239 DateTimeFormat = config . DateTimeFormat ;
225- JsonTypeAttrInObject = config . JsonTypeAttrInObject ;
226- JsvTypeAttrInObject = config . JsvTypeAttrInObject ;
227240 TypeWriter = config . TypeWriter ;
228241 TypeFinder = config . TypeFinder ;
229242 ParsePrimitiveFn = config . ParsePrimitiveFn ;
0 commit comments