Open sandboxFocus

Class ProtectedAttribute

Custom attribute that, when applied to a target declaration, causes PostSharp to emit a warning if the declaration is being referenced from classes that are not derived from the target class. This constraint is similar to the C# keyword protected and should be used only when the target declaration must be made public or internal for non-architectural reasons.

Namespace: PostSharp.Constraints
Assembly: PostSharp.dll
Syntax
[AttributeUsage(AttributeTargets.Assembly|AttributeTargets.Module|AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Enum|AttributeTargets.Constructor|AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Field|AttributeTargets.Event|AttributeTargets.Interface|AttributeTargets.Delegate, AllowMultiple = true)]
[MulticastAttributeUsage(MulticastTargets.AnyType|MulticastTargets.Field|MulticastTargets.Method|MulticastTargets.InstanceConstructor, TargetTypeAttributes = MulticastAttributes.Internal|MulticastAttributes.Public|MulticastAttributes.UserGenerated, TargetMemberAttributes = MulticastAttributes.Internal|MulticastAttributes.Public)]
public sealed class ProtectedAttribute : ReferentialConstraint, IReferentialConstraint, IConstraint

Constructors

Name Description
ProtectedAttribute()

Initializes a new ProtectedAttribute.

Properties

Name Description
Severity

Gets or sets the severity of messages emitted by this constraint.

Methods

Name Description
ValidateCode(object, Assembly)

Validates the constraint.

ValidateConstraint(object)

Validates the fact that the constraint has been applied on a valid element of code. When this method returns false, the constraint is silently ignored.