Table of Contents

Class ExtensionMethodsProject

Namespace
NDepend.Project
Assembly
NDepend.API.dll

Provides a set of extension methods to help working with NDepend project.

public static class ExtensionMethodsProject
Inheritance
ExtensionMethodsProject
Inherited Members

Property (1)

IDEFileRootDirResolvingInfoHintsDefaultValue

This string value is used to initialize IDEFileRootDirResolvingInfo.HintsDefaultValue.

public static string IDEFileRootDirResolvingInfoHintsDefaultValue { get; }

Property Value

string

Methods (15)

GetDefaultOutputDirectoryAbsolutePath(IProject)

Gets the output directory absolute path that is used during the analysis if the project output directory provided is not an absolute path and cannot be resolved.

public static IAbsoluteDirectoryPath GetDefaultOutputDirectoryAbsolutePath(this IProject project)

Parameters

project IProject

The project on which to get the default output directory.

Returns

IAbsoluteDirectoryPath

The output directory absolute path that is used during the analysis if the project output directory provided is not an absolute path and cannot be resolved.

Remarks

This path is the directory named "NDependOut" under the project file path parent directory.

GetOutputDirectoryAbsolutePath(IProject)

Gets the output directory absolute path that is used during the analysis.

public static IAbsoluteDirectoryPath GetOutputDirectoryAbsolutePath(this IProject project)

Parameters

project IProject

The project on which to get the output directory as absolute path.

Returns

IAbsoluteDirectoryPath

The output directory absolute path that is used during the analysis.

Remarks

If the project output directory provided is not an absolute path and cannot be resolved, the absolute path returned is the one returned by GetDefaultOutputDirectoryAbsolutePath(IProject).

GetRulesInProjectFileAndInRuleFiles(IProject)

Try get rules and queries declared in the project file and in rule files referenced by the project.

public static IController GetRulesInProjectFileAndInRuleFiles(this IProject project)

Parameters

project IProject

The NDepend project.

Returns

IController

A controller object that can be used to read and update the hierarchy of rules and queries.

Remarks

If some rules cannot be loaded, like rule in a rule file for example, a IGroup object will be present with a Name that will contains Failed to load rule file: RuleFileName. To get more information you can call the method TryLoadRuleFile(IProject, IRuleFileRef, out IGroup, out string) and read the out parameter failureReason.

GetRulesInProjectFileAndInRuleFilesAndDeclaredInSourceCode(IProject, IGroup)

Try get rules and queries declared in the project file, in rule files referenced by the project and in source code.

public static IController GetRulesInProjectFileAndInRuleFilesAndDeclaredInSourceCode(this IProject project, IGroup analysisResultRulesExtractedFromCode)

Parameters

project IProject

The NDepend project.

analysisResultRulesExtractedFromCode IGroup

The rules and queries extracted from source code obtained through IAnalysisResult.RulesExtractedFromCode.

Returns

IController

A controller object that can be used to read and update the hierarchy of rules and queries.

Remarks

If some rules cannot be loaded, like rule in a rule file for example, a IGroup object will be present with a Name that will contain Failed to load rule file: RuleFileName. To get more information you can call the method TryLoadRuleFile(IProject, IRuleFileRef, out IGroup, out string) and read the out parameter failureReason.

See Also

GetRulesInProjectFileAndInRuleFilesAndDeclaredInSourceCodeAndImported(IProject, IGroup, IRuleIssues[])

Try get rules and queries declared in the project file, in rule files referenced by the project and in source code and imported from SARIF files generated from Roslyn Analyzers at analysis time.

public static IController GetRulesInProjectFileAndInRuleFilesAndDeclaredInSourceCodeAndImported(this IProject project, IGroup analysisResultRulesExtractedFromCode, IRuleIssues[] analysisResultImportedRules)

Parameters

project IProject

The NDepend project.

analysisResultRulesExtractedFromCode IGroup

The rules and queries extracted from source code obtained through IAnalysisResult.RulesExtractedFromCode.

analysisResultImportedRules IRuleIssues[]

The imported from SARIF files generated from Roslyn Analyzers at analysis time obtained through IAnalysisResult.IssuesImported.

Returns

IController

A controller object that can be used to read and update the hierarchy of rules and queries.

Remarks

If some rules cannot be loaded, like rule in a rule file for example, a IGroup object will be present with a Name that will contain Failed to load rule file: RuleFileName. To get more information you can call the method TryLoadRuleFile(IProject, IRuleFileRef, out IGroup, out string) and read the out parameter failureReason.

See Also

TryLoadRuleFile(IAbsoluteFilePath, bool, out IGroup, out string)

Try load code rules and queries defined in the rule file defined by ruleFilePath.

public static bool TryLoadRuleFile(this IAbsoluteFilePath ruleFilePath, bool isActive, out IGroup group, out string failureReason)

Parameters

ruleFilePath IAbsoluteFilePath

The absolute path to the rule file.

isActive bool

A value that indicates whether the loaded rule file is active or not.

group IGroup

The group of code queries and rules, not null only if this method returns true.

failureReason string

If the method returns false, failureReason is not null not empty, and explains in plain-english why the rule files' code queries and rules haven't been loaded.

Returns

bool

true if the rules have been properly loaded from the rule file, else returns false.

Remarks

isActive is defined in the project file and can be obtained from IRuleFileRef.IsActive.

TryLoadRuleFile(IProject, IRuleFileRef, out IGroup, out string)

Try load code rules and queries defined in the rule file defined by ruleFileRef.

public static bool TryLoadRuleFile(this IProject project, IRuleFileRef ruleFileRef, out IGroup group, out string failureReason)

Parameters

project IProject

The NDepend project used to resolve rule file absolute path from ruleFileRef

ruleFileRef IRuleFileRef

The reference to the rule file.

group IGroup

The group of code queries and rules, not null only if this method returns true.

failureReason string

If the method returns false, failureReason is not null not empty, and explains in plain-english why the rule files' code queries and rules haven't been loaded.

Returns

bool

true if the rules have been properly loaded from the rule file, else returns false.

TryResolveAbsolutePathFromProject(IProject, IDirectoryPath, out IAbsoluteDirectoryPath)

This method attempts to resolve an absolute directory path from a directory path

public static bool TryResolveAbsolutePathFromProject(this IProject project, IDirectoryPath directoryPath, out IAbsoluteDirectoryPath absoluteDirectoryPath)

Parameters

project IProject

The project used for resolving the absolute path.

directoryPath IDirectoryPath

The directory path to resolve as absolute.

absoluteDirectoryPath IAbsoluteDirectoryPath

The result absolute directory path if the resolving succeed.

Returns

bool

true if the absolute path resolving succeed, else returns false.

Remarks

If directoryPath is prefixed with an environment variable, project is not used for resolving the absolute path.
If directoryPath contains path variable(s), variables declared in project.PathVariables are used for resolving the absolute path.
If directoryPath is relative to the project file, project.Properties.FilePath is used for resolving the absolute path.

TryResolveAbsolutePathFromProject(IProject, IDirectoryPath, out IAbsoluteDirectoryPath, out string)

This method attempts to resolve an absolute directory path from a directory path

public static bool TryResolveAbsolutePathFromProject(this IProject project, IDirectoryPath directoryPath, out IAbsoluteDirectoryPath absoluteDirectoryPath, out string failureReason)

Parameters

project IProject

The project used for resolving the absolute path.

directoryPath IDirectoryPath

The directory path to resolve as absolute.

absoluteDirectoryPath IAbsoluteDirectoryPath

The result absolute directory path if the resolving succeed.

failureReason string

A plain english failure description if the resolving fails.

Returns

bool

true if the absolute path resolving succeed, else returns false.

Remarks

If directoryPath is prefixed with an environment variable, project is not used for resolving the absolute path.
If directoryPath contains path variable(s), variables declared in project.PathVariables are used for resolving the absolute path.
If directoryPath is relative to the project file, project.Properties.FilePath is used for resolving the absolute path.

TryResolveAbsolutePathFromProject(IProject, IFilePath, out IAbsoluteFilePath)

This method attempts to resolve an absolute file path from a file path

public static bool TryResolveAbsolutePathFromProject(this IProject project, IFilePath filePath, out IAbsoluteFilePath absoluteFilePath)

Parameters

project IProject

The project used for resolving the absolute path.

filePath IFilePath

The file path to resolve as absolute.

absoluteFilePath IAbsoluteFilePath

The result absolute file path if the resolving succeed.

Returns

bool

true if the absolute path resolving succeed, else returns false.

Remarks

If filePath is prefixed with an environment variable, project is not used for resolving the absolute path.
If filePath contains path variable(s), variables declared in project.PathVariables are used for resolving the absolute path.
If filePath is relative to the project file, project.Properties.FilePath is used for resolving the absolute path.

TryResolveAbsolutePathFromProject(IProject, IFilePath, out IAbsoluteFilePath, out string)

This method attempts to resolve an absolute file path from a file path

public static bool TryResolveAbsolutePathFromProject(this IProject project, IFilePath filePath, out IAbsoluteFilePath absoluteFilePath, out string failureReason)

Parameters

project IProject

The project used for resolving the absolute path.

filePath IFilePath

The file path to resolve as absolute.

absoluteFilePath IAbsoluteFilePath

The result absolute file path if the resolving succeed.

failureReason string

A plain english failure description if the resolving fails.

Returns

bool

true if the absolute path resolving succeed, else returns false.

Remarks

If filePath is prefixed with an environment variable, project is not used for resolving the absolute path.
If filePath contains path variable(s), variables declared in project.PathVariables are used for resolving the absolute path.
If filePath is relative to the project file, project.Properties.FilePath is used for resolving the absolute path.

TryResolveAbsolutePathFromProject(IProject, IPath, out IAbsolutePath)

This method attempts to resolve an absolute path from a path

public static bool TryResolveAbsolutePathFromProject(this IProject project, IPath path, out IAbsolutePath absolutePath)

Parameters

project IProject

The project used for resolving the absolute path.

path IPath

The path to resolve as absolute.

absolutePath IAbsolutePath

The result absolute path if the resolving succeed.

Returns

bool

true if the absolute path resolving succeed, else returns false.

Remarks

If path is prefixed with an environment variable, project is not used for resolving the absolute path.
If path contains path variable(s), variables declared in project.PathVariables are used for resolving the absolute path.
If path is relative to the project file, project.Properties.FilePath is used for resolving the absolute path.

TryResolveAbsolutePathFromProject(IProject, IPath, out IAbsolutePath, out string)

This method attempts to resolve an absolute path from a path

public static bool TryResolveAbsolutePathFromProject(this IProject project, IPath path, out IAbsolutePath absolutePath, out string failureReason)

Parameters

project IProject

The project used for resolving the absolute path.

path IPath

The path to resolve as absolute.

absolutePath IAbsolutePath

The result absolute path if the resolving succeed.

failureReason string

A plain english failure description if the resolving fails.

Returns

bool

true if the absolute path resolving succeed, else returns false.

Remarks

If path is prefixed with an environment variable, project is not used for resolving the absolute path.
If path contains path variable(s), variables declared in project.PathVariables are used for resolving the absolute path.
If path is relative to the project file, project.Properties.FilePath is used for resolving the absolute path.

TrySaveRuleFile(IAbsoluteFilePath, IGroup, QueryPersistenceKind, out string)

Try save code rules and queries defined in the rule file defined by ruleFilePath.

public static bool TrySaveRuleFile(this IAbsoluteFilePath ruleFilePath, IGroup group, QueryPersistenceKind queryPersistenceKind, out string failureReason)

Parameters

ruleFilePath IAbsoluteFilePath

The absolute path to the rule file.

group IGroup

The group of code queries and rules, not null only if this method returns true.

queryPersistenceKind QueryPersistenceKind

The group of code queries and rules, not null only if this method returns true.

failureReason string

If the method returns false, failureReason is not null not empty, and explains in plain-english why code queries and rules haven't been saved to the rule file.

Returns

bool

true if the rules have been properly saved to the rule file, else returns false.

TrySaveRuleFile(IProject, IRuleFileRef, IGroup, out string)

Try save code rules and queries defined in a rule file defined by ruleFileRef.

public static bool TrySaveRuleFile(this IProject project, IRuleFileRef ruleFileRef, IGroup group, out string failureReason)

Parameters

project IProject

The NDepend project used to resolve rule file absolute path from ruleFileRef

ruleFileRef IRuleFileRef

The reference to the rule file.

group IGroup

The group of code queries and rules to save.

failureReason string

If the method returns false, failureReason is not null not empty, and explains in plain-english why code queries and rules haven't been saved to the rule file.

Returns

bool

true if the rules have been properly saved to the rule file, else returns false.