Interface IProjectManager
Exposes base operations on NDepend project, including load/save/create/get most recent... A IProjectManager object can be obtained from the property NDependServicesProvider.ProjectManager.
public interface IProjectManager
- Extension Methods
Methods (10)
CreateBlankProject(IAbsoluteFilePath, string)
Creates a new blank project. This method doesn't create the project file, the method SaveProject(IProject) can be called for that.
IProject CreateBlankProject(IAbsoluteFilePath projectFilePath, string projectName)
Parameters
projectFilePathIAbsoluteFilePathThe absolute path to the project file, a project cannot be initialized without a valid project file path.
projectNamestringThe initial name of the project.
Returns
- IProject
The blank project object.
Remarks
Once the project object is created, the project file is then accessible through project.Properties.FilePath.
CreateTemporaryProject(ICollection<IAbsoluteFilePath>, TemporaryProjectMode)
Creates a new temporary project. Calling this method creates the temporary project file in a temporary directory.
IProject CreateTemporaryProject(ICollection<IAbsoluteFilePath> applicationAssemblies, TemporaryProjectMode temporaryProjectMode)
Parameters
applicationAssembliesICollection<IAbsoluteFilePath>Application assemblies file paths to analyze.
temporaryProjectModeTemporaryProjectModeThe temporary project mode: Temporary, TemporaryNewer or TemporaryOlder.
Returns
- IProject
The project object initialized.
Remarks
By working with temporary projects, you can create and experiment with a project without specifying a disk location or a project name.
Tree temporary projects can coexist corresponding to the three TemporaryProjectMode values, Temporary, TemporaryNewer and TemporaryOlder.
Be aware that calling this method erases the current temporary project corresponding to temporaryProjectMode.
Exceptions
- ProjectException
Problem with creating a temporary project.
- See Also
GetMostRecentlyUsedProjects()
Gets a read-only list of NDepend projects references object representing most recently used NDepend projects.
IReadOnlyList<IProjectRef> GetMostRecentlyUsedProjects()
Returns
LoadProject(IAbsoluteFilePath)
Loads a NDepend project, a IProject object, from the path of the project file.
IProject LoadProject(IAbsoluteFilePath projectFilePath)
Parameters
projectFilePathIAbsoluteFilePathThe path of the project file.
Returns
Exceptions
- ProjectException
The project cannot be loaded, the exception message describes the failure reason.
SaveProject(IProject)
Saves a NDepend project to the project file defined by project.Properties.FilePath.
void SaveProject(IProject project)
Parameters
projectIProjectThe project object to save.
Exceptions
- ProjectException
The project cannot be saved, the exception message describes the failure reason.
ShowDialogChooseAnExistingProject(IntPtr, out IProject)
Shows a dialog that allows the user select an existing NDepend project.
bool ShowDialogChooseAnExistingProject(IntPtr ownerWindowHandle, out IProject project)
Parameters
ownerWindowHandleIntPtrThe window handle of the parent window that shows the dialog.
projectIProjectThe project choosen.
Returns
- bool
true if the user clicked OK, false if the user clicked Cancel
Remarks
This method can only be invoked within a .NET Framework 4.x and Windows OS context else it throws a NotSupportedException.
Exceptions
- ThreadStateException
This operation needs the current thread to be a STA thread. To do so, just tag your Main() method with the [STAThread] attribute.
- See Also
-
ShowDialogBuildComparison(IntPtr, out IProject, out IAnalysisResultRef, out IProject, out IAnalysisResultRef)
ShowDialogSelectAssemblies(IntPtr, ICollection<IAbsoluteFilePath>, out ICollection<IAbsoluteFilePath>)
Shows a dialog that allows the user select a set of assemblies files.
bool ShowDialogSelectAssemblies(IntPtr ownerWindowHandle, ICollection<IAbsoluteFilePath> applicationAssembliesIn, out ICollection<IAbsoluteFilePath> applicationAssembliesOut)
Parameters
ownerWindowHandleIntPtrThe window handle of the parent window that shows the dialog.
applicationAssembliesInICollection<IAbsoluteFilePath>A collection of file paths to the assemblies that the dialog initially shows to the user.
applicationAssembliesOutICollection<IAbsoluteFilePath>Application assemblies file paths choosen
Returns
- bool
true if the user clicked OK, false if the user clicked Cancel.
Remarks
This method can only be invoked within a .NET Framework 4.x and Windows OS context else it throws a NotSupportedException.
Exceptions
- ThreadStateException
This operation needs the current thread to be a STA thread. To do so, just tag your Main() method with the [STAThread] attribute.
- See Also
-
ShowDialogBuildComparison(IntPtr, out IProject, out IAnalysisResultRef, out IProject, out IAnalysisResultRef)
ShowDialogSelectAssemblies(IntPtr, out ICollection<IAbsoluteFilePath>)
Shows a dialog that allows the user select a set of assemblies files.
bool ShowDialogSelectAssemblies(IntPtr ownerWindowHandle, out ICollection<IAbsoluteFilePath> applicationAssemblies)
Parameters
ownerWindowHandleIntPtrThe window handle of the parent window that shows the dialog.
applicationAssembliesICollection<IAbsoluteFilePath>Application assemblies file paths choosen
Returns
- bool
true if the user clicked OK, false if the user clicked Cancel.
Remarks
This method can only be invoked within a .NET Framework 4.x and Windows OS context else it throws a NotSupportedException.
Exceptions
- ThreadStateException
This operation needs the current thread to be a STA thread. To do so, just tag your Main() method with the [STAThread] attribute.
- See Also
-
ShowDialogBuildComparison(IntPtr, out IProject, out IAnalysisResultRef, out IProject, out IAnalysisResultRef)
TryApplyCoverageDir(IProject, IAbsoluteDirectoryPath)
Sets coverageDir as the coverage directory of project, with no filter, so that each analysis loads the newest coverage files found under it.
bool TryApplyCoverageDir(IProject project, IAbsoluteDirectoryPath coverageDir)
Parameters
projectIProjectThe project to modify.
coverageDirIAbsoluteDirectoryPathThe coverage directory, typically obtained from TryProbeCoverageDir(IEnumerable<IAbsoluteFilePath>, out IAbsoluteDirectoryPath, out ICoverageDirScan, out string, CancellationToken).
Returns
- bool
false, and the project is left unchanged, when the project coverage files settings are not at their default value: CoverageFiles is not empty, or CoverageDir, CoverageDirFilter or CoverageExclusionFile is set.
Remarks
The coverage directory of a temporary project is stored as an absolute path. For other projects it is stored with the path mode of
IProjectProperties.OutputDir, typically relative to the project file, absolute when this is not possible (other drive).
This method doesn't save the project.
- See Also
TryProbeCoverageDir(IEnumerable<IAbsoluteFilePath>, out IAbsoluteDirectoryPath, out ICoverageDirScan, out string, CancellationToken)
Finds the coverage directory to use for a set of Visual Studio solution files and/or assembly files, and what it contains. No analysis result is needed.
TryProbeCoverageDirResult TryProbeCoverageDir(IEnumerable<IAbsoluteFilePath> solutionOrAssemblyFilePaths, out IAbsoluteDirectoryPath coverageDir, out ICoverageDirScan scan, out string failureReason, CancellationToken cancellationToken = default)
Parameters
solutionOrAssemblyFilePathsIEnumerable<IAbsoluteFilePath>Solution, Visual Studio project and/or assembly file paths. Null items are ignored.
coverageDirIAbsoluteDirectoryPathThe coverage directory inferred and searched. It is null when no directory can be inferred from
solutionOrAssemblyFilePaths(no file path, no common parent directory, a drive root) or when the directory inferred doesn't exist.scanICoverageDirScanWhat
coverageDircontains, not null when the search completed: with TryProbeCoverageDirResult.CoverageFilesFound, and with TryProbeCoverageDirResult.NoCoverageFileFound whencoverageDiris not null.failureReasonstringNull with TryProbeCoverageDirResult.CoverageFilesFound, else a plain-english description of why no coverage file was found, or of the error and its exception details.
cancellationTokenCancellationTokenThe token to cancel the search.
Returns
- TryProbeCoverageDirResult
TryProbeCoverageDirResult.CoverageFilesFound if at least one coverage file has been found, else another value of the enumeration TryProbeCoverageDirResult.
Remarks
The directory searched is the parent directory of the solution files (.sln, .slnx) when there are some. Else, for assemblies and Visual Studio project files,
it is the nearest directory that contains a solution file, walking up from the common parent directory of the files (this directory included, at most 8 levels up, never a drive root),
or this common parent directory when no solution file is found.
Typically the solution directory, below which dotnet test --collect:"XPlat Code Coverage" writes its TestResults directories.
When no coverage file is found below the solution directory, its parent directory is searched the same way when it is the repository root:
it contains a .git directory or file, or a global.json file, and the solution directory doesn't (never a drive root nor the user profile directory).
This parent directory is then the coverage directory returned when it holds coverage files.
This way the test results of dotnet test src/X.slnx --results-directory TestResults run from the repository root are found.
A sub-directory that cannot be read (access denied, deleted meanwhile...) is skipped and the search goes on.
This method only reads the disk, it doesn't modify any project, and it can be called from any thread. Walking a large directory tree can take a few seconds:
call it from a background thread in a UI context and cancel it through cancellationToken when its result is not needed anymore.
Pass the coverageDir obtained to TryApplyCoverageDir(IProject, IAbsoluteDirectoryPath) to make it the coverage directory of a project.
Exceptions
- OperationCanceledException
cancellationTokenwas canceled.
- See Also