On 2014-10-25 13:37:54 +0000, Rares Pop said:

Hello everyone,

I am trying to understand UDA traits scoping while mixing in code.
Aiming to generate code based on UDA I wonder if the following is possible:

class A
{
    @Inject
    Logger logger;

    @Inject
    SomeOtherClass dependency;

    mixin injections!(A)

...
}

In "injections" function I want to iterate through members annotated with the @Inject attribute and generate some specific code.
So far in my attempts the compiler complains about unknown identifier A.
Should the A class be available to the compiler at the time of the mixin invocation?

Thanks for your help,
Rares

Very much possible. Since I don't see what your template is doing, I'm going to give it a guess:

class A{
        mixin injections;
}

template injections
{

.... typeof(this); // e.g. foreach( tra; __traits(getAttributes, typeof(this)))


}


typeof(this) will be A.

Reply via email to