www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Is runtime introspection in a working state?

After exploring object.d/di I've found upon some functions I can use on a type
returned by .classinfo. But "getMembers" which I'm interested in doesn't seem
to work:

import std.stdio;

class Foo
    int x;
    void bar()

void main()
    Foo foo = new Foo();
    auto info = foo.classinfo;
    auto barField = info.getMembers("bar");
    writeln(typeid(barField));  // const(const(object.MemberInfo)[])
    writeln(barField.length);   // 0
    auto fields = info.getMembers(null);
    writeln(typeid(fields));    // const(const(object.MemberInfo)[])
    writeln(fields.length);     // 0

I can get other methods to work, such as toString and tsize. But no luck with
Feb 02 2011