Skip to content

Commit ed36716

Browse files
committed
Sort bind/lookup/formatted vars by logical name before mapping
Previously sortByName ran after List.map, sorting on the generated property name (e.g. field@odata.bind). Now sorting is inline on the source logical name, which can produce a different output order.
1 parent ccf80e4 commit ed36716

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/CreateTypeScript/CreateWebEntities.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ let getBindVars (nameMap: Map<string, EntityInfo>) (filter: XrmAttribute -> bool
7878

7979
entity.manyToOneRelationships
8080
|> List.filter (fun rel -> Map.tryFind rel.ReferencingAttribute attrMap |> Option.exists filter)
81+
|> List.sortBy (fun rel -> rel.ReferencingEntityNavigationPropertyName)
8182
|> List.map (fun rel ->
8283
let eInfo = Map.find rel.ReferencedEntity nameMap
8384

@@ -93,19 +94,18 @@ let getBindVars (nameMap: Map<string, EntityInfo>) (filter: XrmAttribute -> bool
9394
Comment.Basic eInfo.DisplayName,
9495
optional = true
9596
))
96-
|> sortByName
9797

9898
let getLookupValueVars (attrs: XrmAttribute list) =
9999
attrs
100100
|> List.filter (fun a -> a.specialType = SpecialType.EntityReference)
101+
|> List.sortBy (fun a -> a.logicalName)
101102
|> List.map (fun a ->
102103
Variable.Create(
103104
valueInfix a.logicalName,
104105
TsType.String,
105106
getAttributeComment a None,
106107
optional = true
107108
))
108-
|> sortByName
109109

110110
let private toInterfaceName forWrite schemaName =
111111
if forWrite then $"{schemaName}.{CREATE_INTERFACE_NAME}" else schemaName
@@ -206,18 +206,19 @@ let getManyToManyVars nameMap (schemaNames: Set<string>) forWrite (entity: XrmEn
206206
let getFormattedVars (entity: XrmEntity) =
207207
entity.attributes
208208
|> List.filter hasFormattedValue
209+
|> List.sortBy (fun attr -> attr.logicalName)
209210
|> List.map (fun attr ->
210211
Variable.Create(
211212
formattedName attr,
212213
TsType.String,
213214
getAttributeComment attr (Some entity.optionSets),
214215
optional = true
215216
))
216-
|> sortByName
217217

218218
let getLookupNameVars (attrs: XrmAttribute list) =
219219
attrs
220220
|> List.filter (fun a -> a.specialType = SpecialType.EntityReference)
221+
|> List.sortBy (fun a -> a.logicalName)
221222
|> List.map (fun a ->
222223
let vType =
223224
match a.targetEntitySets with
@@ -234,7 +235,6 @@ let getLookupNameVars (attrs: XrmAttribute list) =
234235
Comment.Attribute(a.displayName, tes = a.targetEntitySets),
235236
optional = true
236237
))
237-
|> sortByName
238238

239239
let getScalarVars (filter: XrmAttribute -> bool) (entity: XrmEntity) =
240240
entity.attributes

0 commit comments

Comments
 (0)