Skip to content

Annotations do not support enums and user defined constant objects #12

Closed
@matanlurey

Description

@matanlurey

From @ds84182 on February 28, 2016 18:13

For example, lets say you wanted to extend the JSON serializer to support value validation:

Something like this works just fine:

@JsonSerializable()
class ProtocolHandshake extends Object with _$ProtocolHandshakeMixin {
  @Equals(47) 
  final int version;
  //...
}

But something like this does not:

@JsonSerializable()
class ProtocolEntityData extends Object with _$ProtocolEntityDataMixin {
  @KeyValidator(const TypeValidator(String))
  @ValueValidator(const TypeValidator(String))
  Map<String, String> data;
}

Or something using enums like this:

enum Side {
  SERVER,
  CLIENT
}

@PacketDef(target: Side.CLIENT)
class ProtocolIntList extends Object with _$ProtocolIntListMixin {
  //...
}

Copied from original issue: dart-lang/source_gen#78

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions