Closed caneva20 closed 3 years ago
Only one thing comes to my mind, those classes must be public, to be able to import them from *.mapper.g.dart
Also, it could be unused code as well. If you are not actually importing those classes anywhere in your code, they will be omitted.
Well, they are public and are imported in this file already, and it seems reflectable has generated all the info for them correctly,
Then we need some cases to investigate more closely. If you could extract or illustrate the case it would be helpful
I'll try to have something reproducible then, I'll be back when I get something.
Good news (I guess), I found something.
foo.dart
import 'package:dart_json_mapper/dart_json_mapper.dart';
@jsonSerializable
class Foo {
String name;
Foo(this.name);
}
in a file called bar.dart
export 'foo.dart';
in main.dart
import 'package:dart_json_mapper/dart_json_mapper.dart';
import 'bar.dart'; //<----- HERE IS THE PROBLEM! // import 'foo.dart'; //<----- Importing the model directly works fine! import 'main.mapper.g.dart';
void main(List
var json = JsonMapper.serialize([Foo('Jhon Doe')]);
var foo = JsonMapper.deserialize<List
> If you are not actually importing those classes anywhere in your code, they will be omitted.
It seems that if importing a model through a 'barrel' file, the model will not be recognized as 'used'
Thank you!
It's obviously a bug.
Here https://github.com/k-paxian/dart-json-mapper/blob/master/mapper/lib/src/builder/library_visitor.dart#L17 is the place, imports only is taken into account. We need to handle exports as well 😄
Hi @k-paxian!
I'm migrating one of my projects from mapper
1.5.24
to1.7.2
. In this new version the biggest change is the builder that generates most of the boilerplate code me (a nice addition btw), but almost half the types aren't being added to this list (valueDecorators
), all of those types are marked with@jsonSerializable
. Am I doing something wrong / missing something? Is there some way for me to make the build pick those types?