Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generator does not recognize inherited methods #56

Closed
dustincatap opened this issue Jun 14, 2022 · 1 comment
Closed

Generator does not recognize inherited methods #56

dustincatap opened this issue Jun 14, 2022 · 1 comment

Comments

@dustincatap
Copy link

dustincatap commented Jun 14, 2022

Hi!

I have below an abstract class that maps one object to another:

abstract class ContractFromEntityMapper<C extends DataContract, E extends DomainEntity> {
  C? fromEntity(E? entity);
}

Then I inherit this to another class which will also be used to generate the mapper:

@Mapper(useInjection: true)
abstract class UserLoginContractFromEntityMapper extends ContractFromEntityMapper<UserLoginContract, UserLoginEntity> {}

After running build_runner, the generated file does not include fromEntity method:

// GENERATED CODE - DO NOT MODIFY BY HAND

part of 'user_login_mapper.dart';

// **************************************************************************
// MapperGenerator
// **************************************************************************

@LazySingleton(as: UserLoginContractFromEntityMapper)
class UserLoginContractFromEntityMapperImpl
    extends UserLoginContractFromEntityMapper {
  UserLoginContractFromEntityMapperImpl() : super();
}

But when explicitly adding the fromEntity method in UserLoginContractFromEntityMapper:

@Mapper(useInjection: true)
abstract class UserLoginContractFromEntityMapper extends ContractFromEntityMapper<UserLoginContract, UserLoginEntity> {
  @override
  UserLoginContract? fromEntity(UserLoginEntity? entity);
}

the generated file is complete:

// GENERATED CODE - DO NOT MODIFY BY HAND

part of 'user_login_mapper.dart';

// **************************************************************************
// MapperGenerator
// **************************************************************************

@LazySingleton(as: UserLoginContractFromEntityMapper)
class UserLoginContractFromEntityMapperImpl
    extends UserLoginContractFromEntityMapper {
  UserLoginContractFromEntityMapperImpl() : super();

  @override
  UserLoginContract? fromEntity(UserLoginEntity? entity) {
    if (entity == null) {
      return null;
    }
    ;
    final userlogincontract =
        UserLoginContract(email: entity.email, password: entity.password);
    return userlogincontract;
  }
}
@smotastic
Copy link
Owner

Fixed with #60

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

No branches or pull requests

2 participants