@@ -4654,7 +4654,7 @@ private string LoadTemplate_ListOfEncodedFields(Template template, Context conte
46544654
46554655 if ( field . IsOptional )
46564656 {
4657- template . Write ( $ "if ((EncodingMask & (uint) { dataType . ClassName } Fields.{ field . Name } ) != 0) ") ;
4657+ template . Write ( $ "if ((EncodingMask & { dataType . ClassName } Fields.{ field . Name } ) != 0) ") ;
46584658 }
46594659
46604660 string functionName = field . DataTypeNode . BasicDataType . ToString ( ) ;
@@ -4825,7 +4825,7 @@ private string LoadTemplate_ListOfDecodedFields(Template template, Context conte
48254825
48264826 if ( field . IsOptional )
48274827 {
4828- template . Write ( $ "if ((EncodingMask & (uint) { dataType . ClassName } Fields.{ field . Name } ) != 0) ") ;
4828+ template . Write ( $ "if ((EncodingMask & { dataType . ClassName } Fields.{ field . Name } ) != 0) ") ;
48294829 }
48304830
48314831 string functionName = field . DataTypeNode . BasicDataType . ToString ( ) ;
@@ -4983,7 +4983,7 @@ private string LoadTemplate_ListOfComparedFields(Template template, Context cont
49834983
49844984 if ( field . IsOptional )
49854985 {
4986- template . Write ( $ "if ((EncodingMask & (uint) { dataType . ClassName } Fields.{ field . Name } ) != 0) ") ;
4986+ template . Write ( $ "if ((EncodingMask & { dataType . ClassName } Fields.{ field . Name } ) != 0) ") ;
49874987 }
49884988
49894989 template . Write ( "if (!Utils.IsEqual({0}, value.{0})) return false;" , GetChildFieldName ( field ) ) ;
@@ -5018,7 +5018,7 @@ private string LoadTemplate_ListOfClonedFields(Template template, Context contex
50185018
50195019 if ( field . IsOptional )
50205020 {
5021- template . Write ( $ "if ((EncodingMask & (uint) { dataType . ClassName } Fields.{ field . Name } ) != 0) ") ;
5021+ template . Write ( $ "if ((EncodingMask & { dataType . ClassName } Fields.{ field . Name } ) != 0) ") ;
50225022 }
50235023
50245024 template . Write ( "clone.{0} = ({1})Utils.Clone(this.{0});" , GetChildFieldName ( field ) , GetSystemTypeName ( field . DataTypeNode , field . ValueRank ) ) ;
@@ -5289,14 +5289,28 @@ private bool WriteTemplate_InitializeOptionalChildren(Template template, Context
52895289
52905290 private string LoadTemplate_EncodingMaskProperty ( Template template , Context context )
52915291 {
5292- if ( context . Target is not DataTypeDesign dataType )
5292+ if ( context . Target is not DataTypeDesign _ )
52935293 {
52945294 return null ;
52955295 }
52965296
5297- return IsFirstDataTypeWithOptionalFields ( dataType )
5298- ? TemplatePath + "Version2.DataTypes.EncodingMaskProperty.cs"
5299- : context . TemplatePath ;
5297+ return TemplatePath + "Version2.DataTypes.EncodingMaskProperty.cs" ;
5298+ }
5299+
5300+ private bool WriteTemplate_EncodingMaskProperty ( Template template , Context context )
5301+ {
5302+ if ( context . Target is not DataTypeDesign dataType )
5303+ {
5304+ return false ;
5305+ }
5306+
5307+ template . AddReplacement ( "_hide_by_new_" , IsFirstDataTypeWithOptionalFields ( dataType ) ? string . Empty : "new " ) ;
5308+ template . AddReplacement ( "_ClassName_" , dataType . ClassName ) ;
5309+
5310+ var result = template . WriteTemplate ( context ) ;
5311+ template . WriteLine ( string . Empty ) ;
5312+
5313+ return result ;
53005314 }
53015315
53025316 private static bool HasOptionalFields ( DataTypeDesign dataType )
@@ -5317,21 +5331,6 @@ private static bool IsFirstDataTypeWithOptionalFields(DataTypeDesign dataType)
53175331 && ! HasOptionalFieldsInherited ( dataType ) ;
53185332 }
53195333
5320- private bool WriteTemplate_EncodingMaskProperty ( Template template , Context context )
5321- {
5322- DataTypeDesign dataType = context . Target as DataTypeDesign ;
5323-
5324- if ( dataType == null )
5325- {
5326- return false ;
5327- }
5328-
5329- var result = template . WriteTemplate ( context ) ;
5330- template . WriteLine ( string . Empty ) ;
5331-
5332- return result ;
5333- }
5334-
53355334 #endregion
53365335
53375336 #region "// ListOfPropertiesForType and // ListOfProperties"
0 commit comments