Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.

transformer generated setter missing original metadata #73

Open
Ticore opened this issue Jun 28, 2015 · 1 comment
Open

transformer generated setter missing original metadata #73

Ticore opened this issue Jun 28, 2015 · 1 comment

Comments

@Ticore
Copy link

Ticore commented Jun 28, 2015

issue find in stackoverflow

Wrong decode() from redstone_mapper about observable object in web app

original class:

class User extends Object with ChangeNotifier {
  @Field()
  @observable
  String username;
  @Field()
  @observable
  String password;
  toString() => 'User("$username", "$password");';
}

transformer generated:

class User extends Object with ChangeNotifier {
  @reflectable @Field()
  @observable
  String get username => __$username; String __$username; @reflectable set username(String value) { __$username = notifyPropertyChange(#username, __$username, value); }
  @reflectable @Field()
  @observable
  String get password => __$password; String __$password; @reflectable set password(String value) { __$password = notifyPropertyChange(#password, __$password, value); }
  toString() => 'User("$username", "$password");';
}

@Field() metadata missing in generated setter

@sigmundch
Copy link
Contributor

Patches are welcome :)

I'd prefer that rather than always adding it to the setter, to only do it if you specify a flag in the pubspec.yaml file, though. In particular, the current behavior is by design (see https://github.com/dart-lang/observe/blob/master/lib/transformer.dart#L368), because most of the time only getters need the annotation. This indirectly helps reduce some redundant metadata dart2js would preserve for a deployed app.

Another alternative, could redstone_mapper to use the annotation from the getter in their automatic encode/decode logic?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants