Reflection and interfaces

About Monkey 2 Forums Monkey 2 Programming Help Reflection and interfaces

This topic contains 6 replies, has 3 voices, and was last updated by  Arjailer 2 years, 7 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #4627

    Arjailer
    Participant

    Is there a way to find out if a TypeInfo implements a particular interface?

    When I try typeInfo.ExtendsType(Typeof<IInterface>) I get Type ‘Unknown@13480224 Ptr’ is not a class type

    #4634

    nerobot
    Participant

    Are u using the latest version. Mark fixed interfaces issue today (or yesterday ), may be it fixed this case too.

    #4636

    Arjailer
    Participant

    Yep – downloaded around 3 hours ago.

    Before that I was having that same problem with returning interfaces – it now all builds okay, but I can’t see a way of asking “does this type implement this interface?”

    #4638

    Mark Sibly
    Keymaster

    You can’t yet, only non-extern/non-generic classes are fully implemented right now.

    Other types can still be used with variants (so can be used as invoke parameters/return values) but will generate an ‘Unknown’ typeinfo.

    Interface support should be pretty easy to add, but support for generic types is a while off yet and I suspect that’ll be what you need next!

    #4639

    Arjailer
    Participant

    Hehe – don’t need generics (yet)  🙂

    I’m tying to simplify my unit test framework by dynamically finding test methods (rather than having to add them to a list). I did this in Monkey 1 by looking for classes that implement an ITestable interface, then looking in those classes for parameterless methods that start or end with “Test”. Was trying to replicate this now that M2 has reflection, but stumbling on the interface check.

    Got it working for now by just skipping that check  🙂

    #4643

    Mark Sibly
    Keymaster

    Ok, interfaces are in but not well tested!

    #4648

    Arjailer
    Participant

    That was quick!

    Got that working now – thanks  🙂

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.