NDepend.API Documentation
DepthOfIsUsing Method (ExtensionMethodsCQLinqDependency)
NDepend.Reserved.CQLinq Namespace > ExtensionMethodsCQLinqDependency Class : DepthOfIsUsing Method
This NDepend.CodeModel.IUser object. A NDepend.CodeModel.IUser object can be a NDepend.CodeModel.IAssembly, NDepend.CodeModel.INamespace, NDepend.CodeModel.IType or NDepend.CodeModel.IMethod object.
The NDepend.CodeModel.ICodeElement.FullName of the code element used.
The string usedCodeElementFullName can contain wildcard '*' characters but cannot be just a single wildcard string "*".
If one or several code elements are matched by usedCodeElementFullName, this method has a using any behavior.

If usedCodeElementFullName 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 usedCodeElementFullName, the CQLinq query will emit a compilation error, except if usedCodeElementFullName is prefixed with "OPTIONAL:".
Alternatively, the string extensions methods AllowNoMatch can be used instead, to insert the "OPTIONAL:" prefix.
Returns a non-null depth of usage value, if userCodeElement is directly or indirectly using a NDepend.CodeModel.ICodeElement whose NDepend.CodeModel.ICodeElement.FullName is usedCodeElementFullName. This method can only be called in a ICQLinqExecutionContext, otherwise the extension method NDepend.CodeModel.ExtensionMethodsSequenceUsage.NDepend.CodeModel.ExtensionMethodsSequenceUsage.DepthOfIsUsingAny<TUser,TUsed> must be called instead.
Syntax

Parameters

userCodeElement
This NDepend.CodeModel.IUser object. A NDepend.CodeModel.IUser object can be a NDepend.CodeModel.IAssembly, NDepend.CodeModel.INamespace, NDepend.CodeModel.IType or NDepend.CodeModel.IMethod object.
usedCodeElementFullName
The NDepend.CodeModel.ICodeElement.FullName of the code element used.
The string usedCodeElementFullName can contain wildcard '*' characters but cannot be just a single wildcard string "*".
If one or several code elements are matched by usedCodeElementFullName, this method has a using any behavior.

If usedCodeElementFullName 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 usedCodeElementFullName, the CQLinq query will emit a compilation error, except if usedCodeElementFullName is prefixed with "OPTIONAL:".
Alternatively, the string extensions methods AllowNoMatch can be used instead, to insert the "OPTIONAL:" prefix.

Return Value

usedCodeElement being a NDepend.CodeModel.ICodeElement whose NDepend.CodeModel.ICodeElement.FullName is usedCodeElementFullName:
Returns null if userCodeElement is not directly nor indirectly using a usedCodeElement.
Returns 0 if userCodeElement is, or belongs to, a usedCodeElement.
Returns 1 if userCodeElement is directly using a usedCodeElement.
Returns 2 if userCodeElement is directly using a code element that directly uses a usedCodeElement.
...
If a non-null number is returned, returns the lowest possible number.
Exceptions
ExceptionDescription
This extension method cannot be called from a program consuming NDepend.API. In such context, the extension method NDepend.CodeModel.ExtensionMethodsSequenceUsage.NDepend.CodeModel.ExtensionMethodsSequenceUsage.DepthOfIsUsingAny<TUser,TUsed> must be called instead.
Remarks
If one or several code elements are matched by usedCodeElementFullName, 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
IsIndirectlyUsing Method
MatchAssembly Method
MatchNamespace Method
MatchType Method
MatchMethod Method
MatchField Method
MatchProperty Method
MatchEvent Method
AllowNoMatch Method