NDepend.API Documentation
CodeElement Property (IIssue)
NDepend.Issue Namespace > IIssue Interface : CodeElement Property
Gets the code element that has the issue.
Syntax
ICodeElement CodeElement {get;}
Remarks
A code rule can rely on a NDepend.CodeModel.ICompareContext object to query the diff between 2 snapshots of a code base, the newer snapshot and the baseline snapshot. For example rules to detect API breaking changes fall in this category. Such rule can match code elements in the baseline code base snapshot.

However the issue code element returned by this property necessarily belongs to the newer code base snapshot. In such situation CodeElementInBaseline is the matched code element declared in the baseline code base, and the code element returned by this property is the most inner parent code element of CodeElementInBaseline, that has an equivalent in the newer code base snapshot. For example if a removed method is matched, and its parent type hasen't been removed, this property returns its parent type declared in the newer code base.

Notice the particular case when the matched code element is an assembly removed or is a namespace/type/method/field declared in an assembly removed. In such situation there is no most inner parent code element that has an equivalent in the newer code base snapshot and this property returns the first application assembly of newer code base.
The reason an issue must be be declared in the newer code base snapshot, is because an IIssuesSet object is related to a code base snapshot and not to the diff between 2 snapshots of a code base. It wouldn't make sense that an IIssuesSet object contain some issues declared on elements of the baseline snapshot.
Requirements

Target Platforms: Windows 11, 10, 8, 7 and Linux, MacOS with net8.0, net7.0 or net6.0 installed

See Also

Reference

IIssue Interface
IIssue Members