views:

172

answers:

2

Hi all,

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

+1  A: 

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?

BFree
CompoundAspect provides a method (ProvideAspects) which I'm overloading to then insert a new attribute onto the object. As far as I know I have to inherit from 'CompoundAspect' for PostSharp to be able to do its thing.
Courtney de Lautour
You don't have to derive from CompoundAspect if you don't want to. You can derive from System.Attribute and implement interfaces ILaosAspect and ILaosAspectProvider.
Gael Fraiteur
A: 

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.

Marc Gravell