NDepend.API Documentation
IsUsedBy Method (ExtensionMethodsCQLinqDependency)
NDepend.Reserved.CQLinq Namespace > ExtensionMethodsCQLinqDependency Class : IsUsedBy Method
This NDepend.CodeModel.IUsed object. A NDepend.CodeModel.IUsed object can be a NDepend.CodeModel.IAssembly, NDepend.CodeModel.INamespace, NDepend.CodeModel.IMember, NDepend.CodeModel.IType, NDepend.CodeModel.IMethod or NDepend.CodeModel.IField object.
The NDepend.CodeModel.ICodeElement.FullName of the code element user.

The string userCodeElementFullName can contain wildcard '*' characters but cannot be just a single wildcard string "*".
If one or several code elements are matched by userCodeElementFullName, this method has a used by any behavior.

If userCodeElementFullName matches several code elements of different kinds (like some assemblies and some namespaces) a compilation resolving error is emitted.
To solve this issue, the string can be prefixed with "ASSEMBLY:", "NAMESPACE:", "TYPE:", "METHOD:", "FIELD:", "PROPERTY:" or "EVENT:" to precise the kind of code element to match.
Alternatively, the string extensions methods MatchAssembly, MatchNamespace, MatchType, MatchMethod, MatchField, MatchProperty or MatchEvent can be used instead, to insert this prefix.

If no code element is matched by userCodeElementFullName, the CQLinq query will emit a compilation error, except if userCodeElementFullName is prefixed with "OPTIONAL:".
Alternatively, the string extensions methods AllowNoMatch can be used instead, to insert the "OPTIONAL:" prefix.
Returns true if this usedCodeElement is directly used by a NDepend.CodeModel.ICodeElement whose NDepend.CodeModel.ICodeElement.FullName is userCodeElementFullName. This method can only be called in a ICQLinqExecutionContext, otherwise the method NDepend.CodeModel.IUsed.NDepend.CodeModel.IUsed.IsUsedBy must be called instead.
Syntax

Parameters

usedCodeElement
This NDepend.CodeModel.IUsed object. A NDepend.CodeModel.IUsed object can be a NDepend.CodeModel.IAssembly, NDepend.CodeModel.INamespace, NDepend.CodeModel.IMember, NDepend.CodeModel.IType, NDepend.CodeModel.IMethod or NDepend.CodeModel.IField object.
userCodeElementFullName
The NDepend.CodeModel.ICodeElement.FullName of the code element user.

The string userCodeElementFullName can contain wildcard '*' characters but cannot be just a single wildcard string "*".
If one or several code elements are matched by userCodeElementFullName, this method has a used by any behavior.

If userCodeElementFullName matches several code elements of different kinds (like some assemblies and some namespaces) a compilation resolving error is emitted.
To solve this issue, the string can be prefixed with "ASSEMBLY:", "NAMESPACE:", "TYPE:", "METHOD:", "FIELD:", "PROPERTY:" or "EVENT:" to precise the kind of code element to match.
Alternatively, the string extensions methods MatchAssembly, MatchNamespace, MatchType, MatchMethod, MatchField, MatchProperty or MatchEvent can be used instead, to insert this prefix.

If no code element is matched by userCodeElementFullName, the CQLinq query will emit a compilation error, except if userCodeElementFullName is prefixed with "OPTIONAL:".
Alternatively, the string extensions methods AllowNoMatch can be used instead, to insert the "OPTIONAL:" prefix.
Exceptions
ExceptionDescription
This extension method cannot be called from a program consuming NDepend.API. In such context, the method NDepend.CodeModel.IUsed.NDepend.CodeModel.IUsed.IsUsedBy must be called instead.
Remarks
If one or several code elements are matched by userCodeElementFullName, they will be listed in NDepend.CodeQuery.IQueryExecutionSuccessResult.TargetCodeElements.
In the context of a CQLinq compiled query, this method has a constant time complexity.
Requirements

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

See Also

Reference

ExtensionMethodsCQLinqDependency Class
ExtensionMethodsCQLinqDependency Members
MatchAssembly Method
MatchNamespace Method
MatchType Method
MatchMethod Method
MatchField Method
MatchProperty Method
MatchEvent Method
AllowNoMatch Method