Skip to content

Code generation creates duplicate names #441

@tjarvstrand

Description

@tjarvstrand

Hi! I currently have code which looks something like this:

@GenerateMocks(
  [AuthenticationRepository, UserRepository],
)
void main() {
  ...
}

AuthenticationRepository internally uses User from the firebase_auth package whereas UserRepository (and most of the rest of my application) uses my own representation of a user. This currently results in code generation producing something like this:

...
class _FakeUser extends _i1.Fake implements _i2.User {
  @override
  String toString() => super.toString();
}
...
class _FakeUser extends _i1.Fake implements _i5.User {}
...

Which gives me this error when trying to run the code: Error: Can't use '_FakeUser' because it is declared more than once.

I've tried adding customMocks: [MockSpec<firebase.User>(as: #FirebaseUser) which does generate the FirebaseUser class but it is not used by the AuthenticationRepository mock. Is there any way to solve this?

Metadata

Metadata

Assignees

Labels

P2A bug or feature request we're likely to work ontype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions