Last post Oct 23, 2016 07:41 PM by mwpowellhtx
Oct 23, 2016 05:18 PM|mwpowellhtx|LINK
I've got a scenario something like this:
[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()
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: TestMethod: FirstAdapter(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.
Oct 23, 2016 05:34 PM|mwpowellhtx|LINK
Inheritance-of-custom-attributes-on-abstract-properties on StackOverflow
sheds some light on the topic. Will try following up on that avenue.
Oct 23, 2016 07:41 PM|mwpowellhtx|LINK
Also, detect-if-a-method-was-overridden-using-reflection-c, is interesting,
to note GetBaseDefinition as a means of discovering the base method definition.