ReferentialConstraint, when applied to a declaration, prevents it from being used from a different assembly. This constraint can be used when a declaration must be made public for technical reasons, but its author does not want it to be used in external code.
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, TargetMemberAttributes = MulticastAttributes.Public, TargetTypeAttributes = MulticastAttributes.Public|MulticastAttributes.UserGenerated)]
public sealed class InternalAttribute : ReferentialConstraint, IReferentialConstraint, IConstraintRemarks
The constraint applies only to public declarations: applying it to a declaration that is not public emits the error AR0104.
A use from another assembly that is not granted access by InternalsVisibleToAttribute emits the warning AR0105. Set Severity to Error to make it an error.
SuppressWarningAttribute can suppress the warning where the declaration is used, but cannot suppress an error.
The referencing project must be processed by PostSharp for the constraint to be validated.
Constructors
| Name | Description |
|---|---|
| InternalAttribute() | Initializes a new instance of the InternalAttribute class. |
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 that the constraint has been applied to a valid element of code. When this
method returns |