Class ExtensionMethodsProject
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
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
projectIProjectThe 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
projectIProjectThe 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
projectIProjectThe 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
projectIProjectThe NDepend project.
analysisResultRulesExtractedFromCodeIGroupThe 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
projectIProjectThe NDepend project.
analysisResultRulesExtractedFromCodeIGroupThe rules and queries extracted from source code obtained through IAnalysisResult.RulesExtractedFromCode.
analysisResultImportedRulesIRuleIssues[]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
ruleFilePathIAbsoluteFilePathThe absolute path to the rule file.
isActiveboolA value that indicates whether the loaded rule file is active or not.
groupIGroupThe group of code queries and rules, not null only if this method returns true.
failureReasonstringIf the method returns false,
failureReasonis 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
projectIProjectThe NDepend project used to resolve rule file absolute path from
ruleFileRefruleFileRefIRuleFileRefThe reference to the rule file.
groupIGroupThe group of code queries and rules, not null only if this method returns true.
failureReasonstringIf the method returns false,
failureReasonis 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
projectIProjectThe project used for resolving the absolute path.
directoryPathIDirectoryPathThe directory path to resolve as absolute.
absoluteDirectoryPathIAbsoluteDirectoryPathThe 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
projectIProjectThe project used for resolving the absolute path.
directoryPathIDirectoryPathThe directory path to resolve as absolute.
absoluteDirectoryPathIAbsoluteDirectoryPathThe result absolute directory path if the resolving succeed.
failureReasonstringA 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
projectIProjectThe project used for resolving the absolute path.
filePathIFilePathThe file path to resolve as absolute.
absoluteFilePathIAbsoluteFilePathThe 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
projectIProjectThe project used for resolving the absolute path.
filePathIFilePathThe file path to resolve as absolute.
absoluteFilePathIAbsoluteFilePathThe result absolute file path if the resolving succeed.
failureReasonstringA 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
projectIProjectThe project used for resolving the absolute path.
pathIPathThe path to resolve as absolute.
absolutePathIAbsolutePathThe 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
projectIProjectThe project used for resolving the absolute path.
pathIPathThe path to resolve as absolute.
absolutePathIAbsolutePathThe result absolute path if the resolving succeed.
failureReasonstringA 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
ruleFilePathIAbsoluteFilePathThe absolute path to the rule file.
groupIGroupThe group of code queries and rules, not null only if this method returns true.
queryPersistenceKindQueryPersistenceKindThe group of code queries and rules, not null only if this method returns true.
failureReasonstringIf the method returns false,
failureReasonis 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
projectIProjectThe NDepend project used to resolve rule file absolute path from
ruleFileRefruleFileRefIRuleFileRefThe reference to the rule file.
groupIGroupThe group of code queries and rules to save.
failureReasonstringIf the method returns false,
failureReasonis 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.