locked
Reflect overshadowed member attributes RRS feed

  • Question

  • User-217557848 posted

    Hello,

    I've got a scenario something like this:

    class BaseClass
    {
        [FeatureAspect(typeof(FirstAdapter), PublishErrors = false)] // #1a
        [FeatureAspect(typeof(SecondAdapter))] // #2
        public virtual void TestMethod()
        {
        }
    }
    
    class DerivedClass : BaseClass
    {
        [FeatureAspect(typeof(FirstAdapter), PublishErrors = true)] // #1b
        [FeatureAspect(typeof(ThirdAdapter))] // #3
        public override void TestMethod()
        {
    base.TestMethod(); } }

    What I've got are some features identified as FirstAdapter, SecondAdapter, and ThirdAdapter. There are details in FeatureAspect that can be overshadowed by decorations found in derived classes, as in #1a and #1b., whereby we might want to PublishErrors differently.

    In this scenario, I want the FeatureAspect attributes to reflect as follows:

    BaseClass: TestMethodFirstAdapter(PublishErrors = false) #1a, SecondAdapter #2
    DerivedClass: TestMethod: FirstAdapter(PublishErrors = true) #1b, SecondAdapter #2, ThirdAdapter #3

    I'm diving into MethodInfo for the attributes and not sure which properties tell me that attributes are necessarily overshadowed, i.e. with properties like IsVirtual, IsHideBySig, and so on. Further, DeclaringType and ReflectedType do not seem to tell me the correct answer either.

    Regards,

    Michael Powell

    Sunday, October 23, 2016 5:18 PM

Answers

All replies