k-paxian / dart-json-mapper

Serialize / Deserialize Dart Objects to / from JSON
https://pub.dev/packages/dart_json_mapper
Other
399 stars 33 forks source link

`main.mapper.g.dart` is not generating all `@jsonSerializable` classes #205

Closed jeansebastienZ closed 1 year ago

jeansebastienZ commented 1 year ago

Hello @k-paxian !

It seems that main.mapper.g.dart is not generating all @jsonSerializable classes.

Capture d’écran 2022-12-12 à 20 14 49

In this folder only FieldGroupMDL is automatically generated :

import 'package:dart_json_mapper/dart_json_mapper.dart';
import '../../../engine/utils/wording/identifiers_wording.dart';

import '../abstract_mdls/form_item_mdl.dart';

@jsonSerializable
@Json(discriminatorValue: 'fieldGroup', ignoreNullMembers: true)
class FieldGroupMDL extends FormItemMdl {
  String? icon;
  String? fieldGroupId;
  String? groupParentId;

  FieldGroupMDL({this.icon});

  String getIdentifiers() {
    return IdentifiersWording.fieldGroupMDL;
  }
}

For instance , this classe TextFieldMdl is not generated :

import 'package:dart_json_mapper/dart_json_mapper.dart';

import '../../../engine/utils/wording/identifiers_wording.dart';
import '../../../engine/utils/enum_classes.dart';
import '../abstract_mdls/field_mdl.dart';

@jsonSerializable
@Json(discriminatorValue: 'fileField', ignoreNullMembers: true)
class FileFieldMdl extends FieldMdl {
  FileType? fileType;
  dynamic mimeType;
  String? fieldGroupId;
  int? maxFiles;

  FileFieldMdl({this.fileType, this.mimeType, this.maxFiles,this.fieldGroupId});

  String getIdentifiers() {
    return IdentifiersWording.fileFieldMdl;
  }
}

nor this one :

import 'package:dart_json_mapper/dart_json_mapper.dart';

import '../../../../engine/utils/wording/identifiers_wording.dart';
import '../abstract_mdls/field_mdl.dart';

@jsonSerializable
@Json(discriminatorValue: 'geoField', ignoreNullMembers: true)
class GeoFieldMdl extends FieldMdl {
  String? lat;
  String? long;
  String? uuid;
  String? fieldGroupId;

  GeoFieldMdl({this.lat, this.long, this.uuid, this.fieldGroupId});

  String getIdentifiers() {
    return IdentifiersWording.geoFieldMdl;
  }
}

However if i put the class in an adapter it will be generated :

 JsonMapper().useAdapter(JsonMapperAdapter(
      valueDecorators: {
        typeOf<Map<String, ValueMdl>>(): (value) =>
            value.cast<String, ValueMdl>(),
        typeOf<List<GeoFieldMdl>>(): (value) => value.cast<GeoFieldMdl>(),
      },
    ));

I don't know if it's a path related problem but i've seen 1 , kinda, equivalent tickets : https://github.com/k-paxian/dart-json-mapper/issues/87 and it began happen after some structure refacto .

Regards, Z. Jean-Sébastien


ps : we can't support you thought sponsoring as it is greyed, is it a bug ?

Capture d’écran 2022-12-12 à 20 39 30
k-paxian commented 1 year ago

When configuring your entry points

.....
generate_for:
    # here should be listed entry point files having 'void main()' function
    - lib/main.dart
..... 

Code is generated only for the used/referenced classes (in the main.dart), in other words NO code is generated upfront for the dead code which is not referenced anywhere in your main entry point project.

When you are mentioning this class in an adapter, you are creating reference and it means this code is compiled to the app, so it generates the stuff inside main.mapper.g.dart

If you would like to generate upfront your entire model with all the classes, you can also do that, take a look at the modular approach example here

and then you can use it as an adapter in your main project like this

Probably you could separate your core or core/models folder as a standalone library project following the modular approach, then you can re-use this code in different apps, other projects, etc.

as to sponsoring widget have no idea 🤷 is it the same for the "one time" or "monthly" options?

jeansebastienZ commented 1 year ago

Oh ok thanks you i see !

ps : Yes for the sponsoring look the video below , i can't either "one time" or "monthly" . https://user-images.githubusercontent.com/65148275/207164681-eef8ecf8-6689-4713-9b8c-ebb541f4aee8.mov

Edit : Seems pretty weird , but i tried with someone else and it seems the custom is not available too but it allow me to select a pre-determined amount , can you try to add some to test please ? @k-paxian

Capture d’écran 2022-12-12 à 23 07 01
k-paxian commented 1 year ago

@jeansebastienZ well, I've added few tiers, both monthly and one-time. It seems github changed the way it works, so I don't have any tiers defined. Previously there was an option to custom amount "one-time" 🤷‍♂️ even if you don't have predefined tiers.

Can I treat this issue as resolved then?

jeansebastienZ commented 1 year ago

Their tools is totally f*cked up. Can't pay directly ( their payment process does not work ) and can't connect my Paypal account , it's loading ad vitam eternam . Do you get paypal account ? It will be faster to sponsor you directly it seem ... I wanted my sponsor logo tho 😭 .

k-paxian commented 1 year ago

At least they gave you a badge 😄 nice done image it's not a bug, it's a feature, like MS Access in the good old days: "You've changed 0 rows, are you sure you wanna save?"

you can paypal me then, https://www.paypal.me/alexanderMazuruk

jeansebastienZ commented 1 year ago

Wtf Github is doing 😂 .

Sent men , thanks you for your hard work on this package.