zefchain / serde-reflection

Rust libraries and tools to help with interoperability and testing of serialization formats based on Serde.
Apache License 2.0
137 stars 26 forks source link

[Dart] Remove unnecessary "Item" suffix from enum variant names #20

Closed jerel closed 1 year ago

jerel commented 2 years ago

Summary

My original implementation of Dart followed one of the other language's enum implementations in that it appended Item to the name of each variant. After using it for a while it turns out it's rather annoying and seems to be wholly unnecessary as the enum name is prepended to each variant when generating class based enums and this seems to avoid any chance of collision. Considering that Dart is still considered "under development" I figured it was a good time to walk this back.

For Rust enum:

enum Choice {
  A,
  B,
  C
}

Current output:

abstract class Choice {}

class ChoiceAItem extends Choice {}
class ChoiceBItem extends Choice {}
class ChoiceCItem extends Choice {} 

This PR's output:

abstract class Choice {}

class ChoiceA extends Choice {}
class ChoiceB extends Choice {}
class ChoiceC extends Choice {} 

Test Plan

Uses existing test.

ma2bd commented 2 years ago

Looks like the CI has some unrelated issue

ma2bd commented 1 year ago

@jerel Would it be possible to rebase to run the CI again? (after @kturney's improvements)

(I'll wait a bit and close this PR myself otherwise.)

ma2bd commented 1 year ago

Thanks!