Skip to content

Commit

Permalink
Fix static mapping - skip map, set and list types as well
Browse files Browse the repository at this point in the history
  • Loading branch information
petrnymsa committed Aug 12, 2022
1 parent 1c3755f commit c32d2c8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion example/.packages
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# For more info see: https://dart.dev/go/dot-packages-deprecation
#
# Generated by pub on 2022-08-09 15:30:02.206771.
# Generated by pub on 2022-08-12 11:14:37.192298.
_fe_analyzer_shared:file:///C:/Users/nymsa/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/_fe_analyzer_shared-44.0.0/lib/
analyzer:file:///C:/Users/nymsa/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/analyzer-4.4.0/lib/
args:file:///C:/Users/nymsa/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/args-2.1.1/lib/
Expand Down
7 changes: 6 additions & 1 deletion example/lib/list/list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ part 'list.mapper.g.dart';
class Source {
final List<int> intList;
final List<SourceEntry> entryList;
final List<String> propList;

Source(this.intList, this.entryList);
Source(this.intList, this.entryList, this.propList);
}

class SourceEntry {
Expand All @@ -32,6 +33,10 @@ class TargetEntry {

@Mapper()
abstract class ListMapper {
static List<String> _mapPropList(Source source) =>
source.entryList.map((e) => e.prop).toList();

@Mapping(target: 'propList', source: _mapPropList)
Target fromSource(Source source);
TargetEntry fromSourceEntry(SourceEntry source);
}
5 changes: 4 additions & 1 deletion generator/lib/code_builders/class_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ bool _isPrimitive(DartType type) {
type.isDartCoreInt ||
type.isDartCoreNum ||
type.isDartCoreString ||
(type is InterfaceType && type.superclass?.isDartCoreEnum == true);
(type is InterfaceType && type.superclass?.isDartCoreEnum == true) ||
type.isDartCoreList ||
type.isDartCoreSet ||
type.isDartCoreMap;
}

Class _generateMapperImplementationClass(
Expand Down

0 comments on commit c32d2c8

Please sign in to comment.