Hiding inherited named parameters on attributes C# (3.5)
-
05-07-2019 - |
Question
I am using PostSharp to add some compile time logic to my attributes - in once case [IndexedCategory ("CatName", CatIndex)]
. The trouble comes comes in because IndexedCategory
derives from CompoundAspect
- which has a reasonable number of named params.
Is there any way which I can prevent these from being accessed / shown by intellisence?
Cheers
Solution
I tried a few things... one sure fire way of getting it not to compile would be to re-declare the properties as obsolete or take away the setter - not nice, though.
I tried a few other settings (non-browsable, marked immutable*), but it didn't help much:
[ImmutableObject(true)] // I'm sure this used to toggle intellisense for attribs
public class FooAttribute : BarAttribute
{
[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
[ReadOnly(true)]
public new string Name { get { return base.Name; } }
}
Anyway, in the above Name
can't be set for an attribute, even though it can on the base. Hacky and ugly.
OTHER TIPS
I think you should rethink your design. I'm not sure inheritance is the way to go, maybe composition would better suite your needs. Without knowing more about what you're trying to accomplish, it's really hard to give concrete examples, but if you don't need the properties of the base class, why are you inheriting from it?