@@ -4709,7 +4709,7 @@ private string LoadTemplate_ListOfEncodedFields(Template template, Context conte
47094709
47104710 if ( field . IsOptional )
47114711 {
4712- template . Write ( $ "if ((EncodingMask & (uint) { dataType . ClassName } Fields.{ field . Name } ) != 0) ") ;
4712+ template . Write ( $ "if ((EncodingMask & { dataType . ClassName } Fields.{ field . Name } ) != 0) ") ;
47134713 }
47144714
47154715 string functionName = field . DataTypeNode . BasicDataType . ToString ( ) ;
@@ -4880,7 +4880,7 @@ private string LoadTemplate_ListOfDecodedFields(Template template, Context conte
48804880
48814881 if ( field . IsOptional )
48824882 {
4883- template . Write ( $ "if ((EncodingMask & (uint) { dataType . ClassName } Fields.{ field . Name } ) != 0) ") ;
4883+ template . Write ( $ "if ((EncodingMask & { dataType . ClassName } Fields.{ field . Name } ) != 0) ") ;
48844884 }
48854885
48864886 string functionName = field . DataTypeNode . BasicDataType . ToString ( ) ;
@@ -5038,7 +5038,7 @@ private string LoadTemplate_ListOfComparedFields(Template template, Context cont
50385038
50395039 if ( field . IsOptional )
50405040 {
5041- template . Write ( $ "if ((EncodingMask & (uint) { dataType . ClassName } Fields.{ field . Name } ) != 0) ") ;
5041+ template . Write ( $ "if ((EncodingMask & { dataType . ClassName } Fields.{ field . Name } ) != 0) ") ;
50425042 }
50435043
50445044 template . Write ( "if (!Utils.IsEqual({0}, value.{0})) return false;" , GetChildFieldName ( field ) ) ;
@@ -5073,7 +5073,7 @@ private string LoadTemplate_ListOfClonedFields(Template template, Context contex
50735073
50745074 if ( field . IsOptional )
50755075 {
5076- template . Write ( $ "if ((EncodingMask & (uint) { dataType . ClassName } Fields.{ field . Name } ) != 0) ") ;
5076+ template . Write ( $ "if ((EncodingMask & { dataType . ClassName } Fields.{ field . Name } ) != 0) ") ;
50775077 }
50785078
50795079 template . Write ( "clone.{0} = ({1})Utils.Clone(this.{0});" , GetChildFieldName ( field ) , GetSystemTypeName ( field . DataTypeNode , field . ValueRank ) ) ;
@@ -5495,14 +5495,28 @@ private bool WriteTemplate_InitializeOptionalChildren(Template template, Context
54955495
54965496 private string LoadTemplate_EncodingMaskProperty ( Template template , Context context )
54975497 {
5498- if ( context . Target is not DataTypeDesign dataType )
5498+ if ( context . Target is not DataTypeDesign _ )
54995499 {
55005500 return null ;
55015501 }
55025502
5503- return IsFirstDataTypeWithOptionalFields ( dataType )
5504- ? TemplatePath + "Version2.DataTypes.EncodingMaskProperty.cs"
5505- : context . TemplatePath ;
5503+ return TemplatePath + "Version2.DataTypes.EncodingMaskProperty.cs" ;
5504+ }
5505+
5506+ private bool WriteTemplate_EncodingMaskProperty ( Template template , Context context )
5507+ {
5508+ if ( context . Target is not DataTypeDesign dataType )
5509+ {
5510+ return false ;
5511+ }
5512+
5513+ template . AddReplacement ( "_hide_by_new_" , IsFirstDataTypeWithOptionalFields ( dataType ) ? string . Empty : "new " ) ;
5514+ template . AddReplacement ( "_ClassName_" , dataType . ClassName ) ;
5515+
5516+ var result = template . WriteTemplate ( context ) ;
5517+ template . WriteLine ( string . Empty ) ;
5518+
5519+ return result ;
55065520 }
55075521
55085522 private static bool HasOptionalFields ( DataTypeDesign dataType )
@@ -5523,21 +5537,6 @@ private static bool IsFirstDataTypeWithOptionalFields(DataTypeDesign dataType)
55235537 && ! HasOptionalFieldsInherited ( dataType ) ;
55245538 }
55255539
5526- private bool WriteTemplate_EncodingMaskProperty ( Template template , Context context )
5527- {
5528- DataTypeDesign dataType = context . Target as DataTypeDesign ;
5529-
5530- if ( dataType == null )
5531- {
5532- return false ;
5533- }
5534-
5535- var result = template . WriteTemplate ( context ) ;
5536- template . WriteLine ( string . Empty ) ;
5537-
5538- return result ;
5539- }
5540-
55415540 #endregion
55425541
55435542 #region "// ListOfPropertiesForType and // ListOfProperties"
0 commit comments