Skip to content

Commit 29d268b

Browse files
Disambiguation for base and cstor on EntityType (#217)
This is related to 9850b83 Fixes #212 * Added rule for preprocess * Disambiguation for base and cstor on EntityType
1 parent 9e61d19 commit 29d268b

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

Templates/CSharp/Model/EntityType.cs.tt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ var entityName = entity.Name.ToCheckedCase();
88

99
var typeDeclaration = entityName;
1010

11+
1112
// In the case a entity type name ends with "Request", we will have a collision with the Request objects
12-
// when we generate. For example, there are entities named EventMessage and EventMessageRequest. Those entities
13-
// lead to the generation of an EventMessageRequest and EventMessageRequestRequest request objects in the same
13+
// when we generate. For example, there are entities named EventMessage and EventMessageRequest. Those entities
14+
// lead to the generation of an EventMessageRequest and EventMessageRequestRequest request objects in the same
1415
// namespace as the entities. We add 'Object' to the end of the name to disambiguate the entity.
1516
// This change needs to sync with changes for the *Request templates.
1617

@@ -19,10 +20,18 @@ if (typeDeclaration.EndsWith("Request"))
1920
typeDeclaration = String.Concat(typeDeclaration, "Object");
2021
}
2122

23+
string cstorTypeDeclaration = typeDeclaration;
2224

2325
if (entity.Base != null)
2426
{
25-
typeDeclaration = string.Format("{0} : {1}", typeDeclaration, entity.Base.Name.ToCheckedCase());
27+
var baseTypeDeclaration = entity.Base.Name.ToCheckedCase();
28+
29+
if (baseTypeDeclaration.EndsWith("Request"))
30+
{
31+
baseTypeDeclaration = String.Concat(baseTypeDeclaration, "Object");
32+
}
33+
34+
typeDeclaration = string.Format("{0} : {1}", typeDeclaration, baseTypeDeclaration);
2635
}
2736

2837
var attributeStringBuilder = new StringBuilder();
@@ -60,7 +69,7 @@ namespace <#=entity.Namespace.GetNamespaceName()#>
6069
///<summary>
6170
/// The internal <#=entityName#> constructor
6271
///</summary>
63-
protected internal <#=entityName#>()
72+
protected internal <#=cstorTypeDeclaration#>()
6473
{
6574
// Don't allow initialization of abstract entity types
6675
}

src/Typewriter/MetadataPreprocessor.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ internal static string CleanMetadata(string csdlContents)
5555
AddContainsTarget("itemActivity");
5656
AddContainsTarget("labelPolicy");
5757

58+
// RoleManagement singleton
59+
AddContainsTarget("unifiedRoleDefinition");
60+
61+
62+
5863
// Intune
5964
AddContainsTarget("windows81TrustedRootCertificate");
6065
AddContainsTarget("iosTrustedRootCertificate");

0 commit comments

Comments
 (0)