File tree Expand file tree Collapse file tree 3 files changed +21
-8
lines changed
src/GraphODataTemplateWriter/CodeHelpers/Android Expand file tree Collapse file tree 3 files changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -660,7 +660,7 @@ public {1} {2}{3}{4} {{";
660660 propertyName.SplitCamelCase(),
661661 property.Name,
662662 propertyType,
663- property.SanitizePropertyName().ToLowerFirstChar());
663+ property.Name. SanitizePropertyName(property ).ToLowerFirstChar());
664664 }
665665 return sb.ToString();
666666 }
@@ -685,7 +685,7 @@ public {1} {2}{3}{4} {{";
685685 ParamName(p).SplitCamelCase(),
686686 ParamName(p),
687687 ParamType(p),
688- p .SanitizePropertyName().ToLowerFirstChar()
688+ ParamName(p) .SanitizePropertyName(p ).ToLowerFirstChar()
689689 );
690690 }
691691 return sb.ToString();
@@ -755,7 +755,7 @@ public {1} {2}{3}{4} {{";
755755 {0} = new {2}(response, null);
756756 }}
757757",
758- property.SanitizePropertyName(),
758+ property.Name. SanitizePropertyName(property ),
759759 BaseTypeCollectionResponse(property),
760760 TypeCollectionPage(property),
761761 property.GetTypeString());
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ public enum <#= c.Name.ToUpperFirstChar()#>
1717 /**
1818 * <#= value.Name.SplitCamelCase()#>
1919 */
20- <#= value.SanitizePropertyName() #>,
20+ <#= value.Name. SanitizePropertyName(c ) #>,
2121<#
2222 }
2323#>
Original file line number Diff line number Diff line change @@ -84,14 +84,27 @@ public static string GetToLowerFirstCharName(this OdcmProperty property)
8484 return property . Name . ToLowerFirstChar ( ) ;
8585 }
8686
87- public static string SanitizePropertyName ( this OdcmObject property )
87+ public static string SanitizePropertyName ( this string property , OdcmObject odcmProperty = null )
8888 {
89- if ( ReservedNames . Contains ( property . Name ) )
89+ if ( ReservedNames . Contains ( property ) )
9090 {
91- return ReservedPrefix + property . Name ;
91+ return ReservedPrefix + property ;
9292 }
9393
94- return property . Name . Replace ( "@" , string . Empty ) . Replace ( "." , "_" ) ;
94+ if ( odcmProperty != null && property == odcmProperty . Name . ToUpperFirstChar ( ) )
95+ {
96+ // Check whether the property type is the same as the class name.
97+ if ( odcmProperty . Projection . Type . Name . ToUpperFirstChar ( ) == odcmProperty . Name . ToUpperFirstChar ( ) )
98+ {
99+ // Name the property: {metadataName} + "Property"
100+ return string . Concat ( property , "Property" ) ;
101+ }
102+
103+ // Name the property by its type. Sanitize it in case the type is a reserved name.
104+ return odcmProperty . Projection . Type . Name . ToUpperFirstChar ( ) . SanitizePropertyName ( odcmProperty ) ;
105+ }
106+
107+ return property . Replace ( "@" , string . Empty ) . Replace ( "." , "_" ) ;
95108 }
96109
97110 public static string GetToLowerImport ( this OdcmProperty property )
You can’t perform that action at this time.
0 commit comments