dimanche 6 novembre 2016

Use dart reflectable on external lib

I need to use reflectable on a third party lib but it is not working.

Consider this scenario:

Library A has the reflector declaration:

class Reflector extends Reflectable {
    const Reflector()
        : super(invokingCapability,
        typeRelationsCapability,
        metadataCapability,
        superclassQuantifyCapability,
        reflectedTypeCapability);
}

const Reflector reflector = const Reflector();

Library B has the classes that are annotated with the reflector:

import 'package:library_a/library_a.dart' show reflector;

@reflector
class whateverz {}

Now the application C needs to use reflection on whateverz class that is within library B.

My problem is that the reflectable lib can't see the whateverz class annotated. The build warns "reflector.dart: This reflector does not match anything"

And if I do "print(reflector.annotatedClasses);" it prints [] within the console.

Is this possible? To annotate the classes on a third party lib that I will end up using in an application with reflection? If yes, what am I doing wrong?





Aucun commentaire:

Enregistrer un commentaire