Skip to content

Commit

Permalink
Fix conflicting property name detection, minimize changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gregwinterstein committed Jun 15, 2023
1 parent 3decc1f commit 8a64678
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 28 deletions.
16 changes: 8 additions & 8 deletions src/Microsoft.OData.CodeGen/Templates/ODataT4CodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Microsoft.OData.CodeGen.Templates
{
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
Expand All @@ -18,6 +19,7 @@ namespace Microsoft.OData.CodeGen.Templates
using System.Net;
using System.Security;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml;
using System.Xml.Linq;
using Microsoft.OData.Edm.Csdl;
Expand All @@ -29,8 +31,6 @@ namespace Microsoft.OData.CodeGen.Templates
using Microsoft.OData.CodeGen.FileHandling;
using Microsoft.OData.CodeGen.Logging;
using Microsoft.OData.CodeGen.Common;
using System.CodeDom.Compiler;
using System.Text.RegularExpressions;

/// <summary>
/// Class to produce the template output
Expand Down Expand Up @@ -2923,7 +2923,7 @@ internal void SetPropertyIdentifierMappingsIfBaseConflicts(IEdmStructuredType st
baseProperties = BaseClassProperties.Select(prop => prop.ToUpperInvariant());
}

var propertiesToRename = structuredType.DeclaredProperties.Where(prop => baseProperties.Contains((isLanguageCaseSensitive ? prop.Name : prop.Name.ToUpperInvariant())));
var propertiesToRename = structuredType.DeclaredProperties.Where(prop => baseProperties.Contains((isLanguageCaseSensitive ? customizePropertyName(prop.Name) : prop.Name.ToUpperInvariant())));
UniqueIdentifierService uniqueIdentifierService =
new UniqueIdentifierService(BaseClassProperties, isLanguageCaseSensitive);

Expand Down Expand Up @@ -4577,8 +4577,8 @@ internal override void WriteConstructorForSingleType(string singleTypeName, stri
this.Write(this.ToStringHelper.ToStringWithCulture(singleTypeName));

this.Write("(global::Microsoft.OData.Client.DataServiceContext context, string path)\r\n " +
" : base(context, path) { }\r\n\r\n /// <summary>\r\n /// Initialize " +
"a new ");
" : base(context, path) {}\r\n\r\n /// <summary>\r\n /// Initialize a" +
" new ");

this.Write(this.ToStringHelper.ToStringWithCulture(singleTypeName));

Expand All @@ -4587,8 +4587,8 @@ internal override void WriteConstructorForSingleType(string singleTypeName, stri
this.Write(this.ToStringHelper.ToStringWithCulture(singleTypeName));

this.Write("(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isC" +
"omposable)\r\n : base(context, path, isComposable) { }\r\n\r\n /// <" +
"summary>\r\n /// Initialize a new ");
"omposable)\r\n : base(context, path, isComposable) {}\r\n\r\n /// <s" +
"ummary>\r\n /// Initialize a new ");

this.Write(this.ToStringHelper.ToStringWithCulture(singleTypeName));

Expand All @@ -4600,7 +4600,7 @@ internal override void WriteConstructorForSingleType(string singleTypeName, stri

this.Write(this.ToStringHelper.ToStringWithCulture(baseTypeName));

this.Write(" query)\r\n : base(query) { }\r\n\r\n");
this.Write(" query)\r\n : base(query) {}\r\n\r\n");


}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<#@ Assembly Name="System.Windows.Forms.dll" #>
<#@ Assembly Name="Microsoft.OData.Edm.dll" #>
<#@ Import Namespace="System" #>
<#@ Import Namespace= "System.CodeDom.Compiler"#>
<#@ Import Namespace="System.Collections.Generic" #>
<#@ Import Namespace="System.Diagnostics" #>
<#@ Import Namespace="System.Globalization" #>
Expand All @@ -26,6 +27,7 @@
<#@ Import Namespace="System.Net"#>
<#@ Import Namespace="System.Security"#>
<#@ Import Namespace="System.Text"#>
<#@ Import Namespace= "System.Text.RegularExpressions"#>
<#@ Import Namespace="System.Xml"#>
<#@ Import Namespace="System.Xml.Linq" #>
<#@ Import Namespace="Microsoft.OData.Edm.Csdl" #>
Expand All @@ -37,8 +39,6 @@
<#@ Import Namespace="Microsoft.OData.CodeGen.FileHandling" #>
<#@ Import Namespace="Microsoft.OData.CodeGen.Logging" #>
<#@ Import Namespace= "Microsoft.OData.CodeGen.Common"#>
<#@ Import Namespace= "System.CodeDom.Compiler"#>
<#@ Import Namespace= "System.Text.RegularExpressions"#>
<#@include file="ODataT4CodeGenFilesManager.ttinclude"
#><#
CodeGenerationContext context;
Expand Down Expand Up @@ -2781,7 +2781,7 @@ public abstract class ODataClientTemplate : TemplateBase
baseProperties = BaseClassProperties.Select(prop => prop.ToUpperInvariant());
}

var propertiesToRename = structuredType.DeclaredProperties.Where(prop => baseProperties.Contains((isLanguageCaseSensitive ? prop.Name : prop.Name.ToUpperInvariant())));
var propertiesToRename = structuredType.DeclaredProperties.Where(prop => baseProperties.Contains((isLanguageCaseSensitive ? customizePropertyName(prop.Name) : prop.Name.ToUpperInvariant())));
UniqueIdentifierService uniqueIdentifierService =
new UniqueIdentifierService(BaseClassProperties, isLanguageCaseSensitive);

Expand Down Expand Up @@ -4352,19 +4352,19 @@ namespace <#= fullNamespace #>
/// Initialize a new <#= singleTypeName #> object.
/// </summary>
public <#= singleTypeName #>(global::Microsoft.OData.Client.DataServiceContext context, string path)
: base(context, path) { }
: base(context, path) {}

/// <summary>
/// Initialize a new <#= singleTypeName #> object.
/// </summary>
public <#= singleTypeName #>(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable)
: base(context, path, isComposable) { }
: base(context, path, isComposable) {}

/// <summary>
/// Initialize a new <#= singleTypeName #> object.
/// </summary>
public <#= singleTypeName #>(<#= baseTypeName #> query)
: base(query) { }
: base(query) {}

<#+
}
Expand Down Expand Up @@ -4794,7 +4794,6 @@ namespace <#= fullNamespace #>
WriteRequiredAttribute($"{propertyOptions.PropertyName} is required.");
}
#>

<#+
if (!string.IsNullOrEmpty(propertyOptions.PropertyAttribute))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public EntityContainer(global::System.Uri serviceRoot) :
this(serviceRoot, global::Microsoft.OData.Client.ODataProtocolVersion.V4)
{
}

/// <summary>
/// Initialize a new EntityContainer object.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Namespace DupNames.DSC
Public Sub New(ByVal serviceRoot As Global.System.Uri)
Me.New(serviceRoot, Global.Microsoft.OData.Client.ODataProtocolVersion.V4)
End Sub

''' <summary>
''' Initialize a new EntityContainer object.
''' </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,19 +226,19 @@ public partial class DupWithTypeNameSingle : global::Microsoft.OData.Client.Data
/// Initialize a new DupWithTypeNameSingle object.
/// </summary>
public DupWithTypeNameSingle(global::Microsoft.OData.Client.DataServiceContext context, string path)
: base(context, path) { }
: base(context, path) {}

/// <summary>
/// Initialize a new DupWithTypeNameSingle object.
/// </summary>
public DupWithTypeNameSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable)
: base(context, path, isComposable) { }
: base(context, path, isComposable) {}

/// <summary>
/// Initialize a new DupWithTypeNameSingle object.
/// </summary>
public DupWithTypeNameSingle(global::Microsoft.OData.Client.DataServiceQuerySingle<DupWithTypeName> query)
: base(query) { }
: base(query) {}

/// <summary>
/// There are no comments for DupPropertyName1 in the schema.
Expand Down Expand Up @@ -653,19 +653,19 @@ public partial class DupWithTypeName1Single : global::Microsoft.OData.Client.Dat
/// Initialize a new DupWithTypeName1Single object.
/// </summary>
public DupWithTypeName1Single(global::Microsoft.OData.Client.DataServiceContext context, string path)
: base(context, path) { }
: base(context, path) {}

/// <summary>
/// Initialize a new DupWithTypeName1Single object.
/// </summary>
public DupWithTypeName1Single(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable)
: base(context, path, isComposable) { }
: base(context, path, isComposable) {}

/// <summary>
/// Initialize a new DupWithTypeName1Single object.
/// </summary>
public DupWithTypeName1Single(global::Microsoft.OData.Client.DataServiceQuerySingle<DupWithTypeName1> query)
: base(query) { }
: base(query) {}

}
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,19 +169,19 @@ public partial class eventSingle : global::Microsoft.OData.Client.DataServiceQue
/// Initialize a new eventSingle object.
/// </summary>
public eventSingle(global::Microsoft.OData.Client.DataServiceContext context, string path)
: base(context, path) { }
: base(context, path) {}

/// <summary>
/// Initialize a new eventSingle object.
/// </summary>
public eventSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable)
: base(context, path, isComposable) { }
: base(context, path, isComposable) {}

/// <summary>
/// Initialize a new eventSingle object.
/// </summary>
public eventSingle(global::Microsoft.OData.Client.DataServiceQuerySingle<@event> query)
: base(query) { }
: base(query) {}

/// <summary>
/// There are no comments for event1 in the schema.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public EntityContainer(global::System.Uri serviceRoot) :
this(serviceRoot, global::Microsoft.OData.Client.ODataProtocolVersion.V4)
{
}

/// <summary>
/// Initialize a new EntityContainer object.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Namespace PrefixConflict.DSC
Public Sub New(ByVal serviceRoot As Global.System.Uri)
Me.New(serviceRoot, Global.Microsoft.OData.Client.ODataProtocolVersion.V4)
End Sub

''' <summary>
''' Initialize a new EntityContainer object.
''' </summary>
Expand Down

0 comments on commit 8a64678

Please sign in to comment.