atreeon / morphy

Provides a clean class definition with extra functionality including; copy with, json serializable, tostring, equals that supports inheritance and polymorphism
4 stars 2 forks source link

Defining a Morphy class with no members produces corrupt dart #21

Closed Adam-Langley closed 1 month ago

Adam-Langley commented 4 months ago

As per the title - fairly easy to replicate.

Sometimes I have intermediary classes, who have no members... so I need this to function - don't see a technical reason why it shouldn't.

Thanks,

atreeon commented 4 months ago

Hi Adam, so sorry, I've been snowed under. There are a couple of bugs in the program but I'm really hoping I'll have time to fix them this week. The simple stuff should work though. If you can share an example that might help. All the best.

Edit - oh I just read the title properly! I'll take a look this week all being well

Adam-Langley commented 3 months ago

Hi @atreeon Some more specifics, it appears the failure case is specifically where the root class has no members. I.e, here's a failure case

import 'package:morphy_annotation/morphy_annotation.dart';

part 'eula_state.morphy.dart';

@Morphy(
  explicitSubTypes: [
    $AgreedEulaState,
  ]
)
abstract class $EulaState
{
 // lack of members causes error
}

@Morphy()
abstract class $AgreedEulaState implements $EulaState
{
  bool get test;
}

And this is a passing case

import 'package:morphy_annotation/morphy_annotation.dart';

part 'eula_state.morphy.dart';

@Morphy(
  explicitSubTypes: [
    $AgreedEulaState,
  ]
)
abstract class $EulaState
{
  bool get test;
}

@Morphy()
abstract class $AgreedEulaState implements $EulaState
{
  // lack of members here does NOT cause error
}
atreeon commented 3 months ago

Thank you for the update, I'll try to update tomorrow.

Adam-Langley commented 3 months ago

Hi there @atreeon - any progress on this? Thanks

atreeon commented 1 month ago

Apologies for such terrible service! Thanks for your edit much appreciated, things kept coming up in life so I didn't have any time when I thought I had time. New version has a breaking change so mind out and read the changelog but it isn't a major change I hope.