Skip to content
Prev Previous commit
Next Next commit
Ensure that readWriteVars and readOnlyVars are also marked as isEnum …
…and isPrimitiveType where appropriate
  • Loading branch information
gbrown-ce committed Apr 24, 2020
commit c735e51115e3424efd3e7975ef4ff2fee43c8907
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,32 @@ private void postProcessEnumRefs(final Map<String, Object> models) {
var.isPrimitiveType = true;
}
}
for (CodegenProperty var : model.readWriteVars) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously this only flagged things in the allVars array which are not actually references to the objecsts in the readWrite or readOnly arrays, so it was missing out on this decoration

if (enumRefs.containsKey(var.dataType)) {
// Handle any enum properties referred to by $ref.
// This is different in C# than most other generators, because enums in C# are compiled to integral types,
// while enums in many other languages are true objects.
CodegenModel refModel = enumRefs.get(var.dataType);
var.allowableValues = refModel.allowableValues;
var.isEnum = true;

// We do these after updateCodegenPropertyEnum to avoid generalities that don't mesh with C#.
var.isPrimitiveType = true;
}
}
for (CodegenProperty var : model.readOnlyVars) {
if (enumRefs.containsKey(var.dataType)) {
// Handle any enum properties referred to by $ref.
// This is different in C# than most other generators, because enums in C# are compiled to integral types,
// while enums in many other languages are true objects.
CodegenModel refModel = enumRefs.get(var.dataType);
var.allowableValues = refModel.allowableValues;
var.isEnum = true;

// We do these after updateCodegenPropertyEnum to avoid generalities that don't mesh with C#.
var.isPrimitiveType = true;
}
}

// We're looping all models here.
if (model.isEnum) {
Expand Down