Table of Contents

Class CodeRuleAttribute

Namespace
NDepend.Attributes
Assembly
NDepend.API.dll

This attribute can be used to declare a code rule (or query) in your source code.

[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
public sealed class CodeRuleAttribute : Attribute
Inheritance
CodeRuleAttribute
Inherited Members
Extension Methods

Remarks

The code rule is a CQLinq or CQL string.
It is extracted automatically from assemblies analyzed at analysis time.
A code rule gathered from a CodeRuleAttribute appears under a group named: "Rules extracted from Source Code".
Under this rule, code rules are grouped under the parent namespaces of code elements tagged by CodeRuleAttribute.
More information at Rules extracted from code

Constructor (1)

CodeRuleAttribute(string)

Initializes a new instance of the CodeRuleAttribute class, from the specified codeRuleString.

public CodeRuleAttribute(string codeRuleString)

Parameters

codeRuleString string

The string that contains the CQLinq or CQL code rule or query.

Remarks

When declaring a code rule in source file, you can use one of the tags \(FullName\) or \(Name\) to paste in the rule string the Name of the code element tagged or the FullName of the member (type/method/field) tagged.

Properties (6)

Active

Gets or sets a value that indicates whether the code rule is active.

public bool Active { get; set; }

Property Value

bool

Remarks

The default value is true.

CodeRuleString

Gets the CQLinq or CQL code rule string or query string.

public string CodeRuleString { get; }

Property Value

string

DisplayListInReport

Gets or sets a value that indicates whether if the code rule is violated, the code rule matched code elements are listed into the report.

public bool DisplayListInReport { get; set; }

Property Value

bool

Remarks

The default value is true.

DisplaySelectionViewInReport

Gets or sets a value that indicates whether if the code rule is violated, the code rule matched code elements are shown in a treemap picture embedded into the report.

public bool DisplaySelectionViewInReport { get; set; }

Property Value

bool

Remarks

The default value is false.

DisplayStatInReport

Gets or sets a value that indicates whether if the code rule is violated, the code rule matched code elements statistics are shown into the report.

public bool DisplayStatInReport { get; set; }

Property Value

bool

Remarks

The default value is true.

IsCriticalRule

Gets or sets a value that indicates whether the code rule is critical or not.

public bool IsCriticalRule { get; set; }

Property Value

bool

Remarks

The default value is false.
A critical code rule is useful to break the build process once the rule is violated.
More information at: Critical Rules and Build Failure

Methods (2)

Equals(object)

System.Object.GetHashCode() is overridden for this class CodeRuleAttribute.

public override bool Equals(object obj)

Parameters

obj object

Returns

bool

GetHashCode()

System.Object.GetHashCode() is overridden for this class CodeRuleAttribute.

public override int GetHashCode()

Returns

int

See Also