@@ -91,25 +91,17 @@ public static string SanitizePropertyName(this string property, OdcmObject odcmP
9191 {
9292 if ( ReservedNames . Value . Contains ( property ) )
9393 {
94- logger . Info ( "Property \" {0}\" is a reserved word in Java. Converting to \" {1}{0}\" " , property , ReservedPrefix ) ;
95- return ReservedPrefix + property . ToUpperFirstChar ( ) ;
94+ var result = ReservedPrefix + property . ToUpperFirstChar ( ) ;
95+ logger . Info ( $ "Property \" { property } \" is a reserved word in Java. Converting to \" { result } \" ") ;
96+ return result ;
9697 }
97-
98- if ( odcmProperty != null && property == odcmProperty . Name . ToUpperFirstChar ( ) )
98+ else if ( property == odcmProperty ? . Name ? . ToUpperFirstChar ( ) && ! ( odcmProperty ? . Name ? . StartsWith ( "_" ) ?? false ) )
9999 {
100- // Check whether the property type is the same as the class name.
101- if ( odcmProperty . Projection . Type ? . Name ? . ToUpperFirstChar ( ) == odcmProperty . Name . ToUpperFirstChar ( ) )
102- {
103- // Name the property: {metadataName} + "Property"
104- logger . Info ( "Property type \" {0}\" has the same name as the class. Converting to \" {0}Property\" " , property ) ;
105- return string . Concat ( property , "Property" ) ;
106- }
107-
108100 // Name the property by its type. Sanitize it in case the type is a reserved name.
109- return odcmProperty . Projection . Type ? . Name ? . ToUpperFirstChar ( ) ? . SanitizePropertyName ( odcmProperty ) ?? property . SanitizePropertyName ( ) ;
101+ return odcmProperty ? . Projection ? . Type ? . Name ? . ToUpperFirstChar ( ) ? . SanitizePropertyName ( odcmProperty ) ?? odcmProperty ? . Name ? . SanitizePropertyName ( ) ;
110102 }
111-
112- return property . Replace ( "@" , string . Empty ) . Replace ( "." , string . Empty ) ;
103+ else
104+ return property ? . Replace ( "@" , string . Empty ) ? . Replace ( "." , string . Empty ) ;
113105 }
114106
115107 public static string GetToLowerImport ( this OdcmProperty property )
0 commit comments