Open sandboxFocus

Class ComponentInternalAttribute

ReferentialConstraint that, when applied to a declaration, limits the scope (namespace or type) in which this declaration can be used. This constraint is useful to isolate several components from each other, even if they are implemented in the same assembly. The ComponentInternal constraint sets the visibility of a declaration between internal and private.

Namespace: PostSharp.Constraints
Assembly: PostSharp.dll
Syntax
public sealed class ComponentInternalAttribute : ReferenceConstraint, IReferentialConstraint, IConstraint
Remarks

With the default constructor, the declaration can be used only from the namespace of its declaring type. The other constructors accept a list of friend types or namespaces. A friend namespace also grants access to its child namespaces. Code in the same top-level type as the target declaration always has access.

A violation emits the warning AR0102. Set Severity to Error to make it an error. SuppressWarningAttribute can suppress the warning where the declaration is used, but cannot suppress an error.

References from other assemblies are validated only when the target declaration is public and the referencing project is processed by PostSharp.

Constructors

Name Description
ComponentInternalAttribute()

Initializes a new instance of the ComponentInternalAttribute class that prevents the target declaration from being used from a namespace other than the namespace of the declaration.

ComponentInternalAttribute(params string[])

Initializes a new instance of the ComponentInternalAttribute class that prevents the target declaration from being used outside of the given types or namespaces, which are specified as strings.

ComponentInternalAttribute(params Type[])

Initializes a new instance of the ComponentInternalAttribute class that prevents the target declaration from being used outside of the given types or namespaces, which are specified as Type objects.

Properties

Name Description
Severity

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

Methods

Name Description
ValidateReference(ICodeReference)

Validates a reference to the target declaration of the current constraint.

See Also