The C# implementation of enum generation looks at all variants of an enum and, if all are of type Unit, it then generates a native enum and otherwise generates a class. The current Dart implementation simply generates all classes if c_style_enums = false or all enums if c_style_enums = true.
This PR changes the Dart logic to match C# (the only other language that currently implements the c_style_enums config. dart.rs will now generate all classes if c_style_enums = false and if it is true it will generate native Dart enums unless the enum contains data, then it will generate a class.
Test Plan
A test was added that verifies that when c_style_enums is enabled the generator will generate native Dart enums for the simple case but generate classes for data-containing enums.
Summary
The C# implementation of enum generation looks at all variants of an enum and, if all are of type
Unit
, it then generates a native enum and otherwise generates a class. The current Dart implementation simply generates all classes ifc_style_enums = false
or all enums ifc_style_enums = true
.This PR changes the Dart logic to match C# (the only other language that currently implements the
c_style_enums
config. dart.rs will now generate all classes ifc_style_enums = false
and if it istrue
it will generate native Dart enums unless the enum contains data, then it will generate a class.Test Plan
A test was added that verifies that when
c_style_enums
is enabled the generator will generate native Dart enums for the simple case but generate classes for data-containing enums.