Interface IVisualStudioManager
- Namespace
- NDepend.DotNet.VisualStudio
- Assembly
- NDepend.API.dll
Exposes base operations concerning Visual Studio files, including getting debug assemblies built from a VS solution. A IVisualStudioManager object can be obtained from the property NDependServicesProvider.VisualStudioManager.
public interface IVisualStudioManager
- Extension Methods
Methods (9)
GetAssembliesFromVisualStudioSolutionOrProject(IAbsoluteFilePath)
Returns a read-only list of assemblies file paths compiled in Debug mode, from the Visual Studio solution or project file path.
IReadOnlyList<IAbsoluteFilePath> GetAssembliesFromVisualStudioSolutionOrProject(IAbsoluteFilePath visualStudioSolutionOrProjectFilePath)
Parameters
visualStudioSolutionOrProjectFilePathIAbsoluteFilePathThe path to the Visual Studio solution or project file path.
Returns
Exceptions
- FileNotFoundException
visualStudioSolutionOrProjectFilePathdoesn't refer to an existing file.
GetMostRecentlyUsedVisualStudioSolutionOrProject(VisualStudioVersion)
Returns a read-only list of most recently used Visual Studio solutions or projects file paths, for the specified visualStudioVersion.
IReadOnlyList<IAbsoluteFilePath> GetMostRecentlyUsedVisualStudioSolutionOrProject(VisualStudioVersion visualStudioVersion)
Parameters
visualStudioVersionVisualStudioVersionThe Visual Studio version.
Returns
Remarks
This list is stored in the registry and is used by the Start Page of Visual Studio.
Returns an empty collection if the specified Visual Studio version is not installed.
GetVisualStudioInstallPaths()
Return Visual Studio 2017 and upper install paths.
IAbsoluteDirectoryPath[] GetVisualStudioInstallPaths()
Returns
- IAbsoluteDirectoryPath[]
For example it can return a list of path like these ones, depending on the Visual Studio 2017 and upper instances on the current machine. C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview C:\Program Files (x86)\Microsoft Visual Studio\2019\Community C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise
IsVisualStudioVersionInstalled(VisualStudioVersion)
Returns true if the specified Visual Studio version is installed on the current machine.
bool IsVisualStudioVersionInstalled(VisualStudioVersion visualStudioVersion)
Parameters
visualStudioVersionVisualStudioVersionThe Visual Studio version.
Returns
ShowDialogSelectVisualStudioSolutionsOrProjects(IntPtr, out ICollection<IAbsoluteFilePath>)
Shows a dialog that lets the user select one or several Visual Studio solutions or projects files.
bool ShowDialogSelectVisualStudioSolutionsOrProjects(IntPtr ownerWindowHandle, out ICollection<IAbsoluteFilePath> visualStudioSolutionsOrProjectsFilePaths)
Parameters
ownerWindowHandleIntPtrThe window handle of the parent window that shows the dialog.
visualStudioSolutionsOrProjectsFilePathsICollection<IAbsoluteFilePath>Visual Studio solutions or projects 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
-
ShowDialogSelectAssemblies(IntPtr, ICollection<IAbsoluteFilePath>, out ICollection<IAbsoluteFilePath>)ShowDialogBuildComparison(IntPtr, out IProject, out IAnalysisResultRef, out IProject, out IAnalysisResultRef)
TryGetNDependProjectFilePathAttachedToVisualStudioSolution(IAbsoluteFilePath, out IAbsoluteFilePath)
Returns true if the visualStudioSolutionFilePath exists, and contains a ndependProjectFilePath that can be resolved to an absolute path.
bool TryGetNDependProjectFilePathAttachedToVisualStudioSolution(IAbsoluteFilePath visualStudioSolutionFilePath, out IAbsoluteFilePath ndependProjectFilePath)
Parameters
visualStudioSolutionFilePathIAbsoluteFilePathThe path to the Visual Studio solution file.
ndependProjectFilePathIAbsoluteFilePathThe path to the NDepend project file.
Returns
Remarks
If project attachment is done through the VS solutionn user options file (.suo) this method won't be able to retrieve the project attached. This method only deal with VS solution files (.sln).
TryGetNDependProjectFilePathAttachedToVisualStudioSolution(IAbsoluteFilePath, out IAbsoluteFilePath, out string)
Returns true if the visualStudioSolutionFilePath exists, and contains a ndependProjectFilePath that can be resolved to an absolute path.
bool TryGetNDependProjectFilePathAttachedToVisualStudioSolution(IAbsoluteFilePath visualStudioSolutionFilePath, out IAbsoluteFilePath ndependProjectFilePath, out string failureReason)
Parameters
visualStudioSolutionFilePathIAbsoluteFilePathThe path to the Visual Studio solution file.
ndependProjectFilePathIAbsoluteFilePathThe path to the NDepend project file.
failureReasonstringIf this method returns false, this string contains a plain-english description of the reason why a NDepend project file path cannot be resolved.
Returns
Remarks
If project attachment is done through the VS solutionn user options file (.suo) this method won't be able to retrieve the project attached. This method only deal with VS solution files (.sln).
TryResolveVisualStudioSolutionFromAssemblies(IEnumerable<IAssembly>, out IAbsoluteFilePath)
Returns true if a Visual Studio solution file (.sln or .slnx) that builds the assemblies can be inferred from their Visual Studio project files.
bool TryResolveVisualStudioSolutionFromAssemblies(IEnumerable<IAssembly> assemblies, out IAbsoluteFilePath visualStudioSolutionFilePath)
Parameters
assembliesIEnumerable<IAssembly>The assemblies whose Visual Studio project files are used to infer the solution.
visualStudioSolutionFilePathIAbsoluteFilePathThe path to the Visual Studio solution file inferred, null if this method returns false.
Returns
Remarks
The inference relies on VisualStudioProjectFilePath of each assembly, obtained at analysis time. Assemblies with no existing project file (third-party assembly, no PDB, non C# project) are ignored.
Solution files are searched in the parent directories of each project file, up to the repository root (the first directory that contains a .git folder or file) or the drive root.
The solution chosen is the one that contains all the project files with the fewest other projects. If no solution contains them all, the one that contains the most is chosen.
When two solutions are equally good candidates, typically a .sln and its .slnx conversion, no solution is inferred and this method returns false.
To resolve distinct solutions for application and test code, call this method once with Assemblies of Application and once with the ones of TestCode.
TryResolveVisualStudioSolutionFromAssemblies(IEnumerable<IAssembly>, out IAbsoluteFilePath, out string)
Returns true if a Visual Studio solution file (.sln or .slnx) that builds the assemblies can be inferred from their Visual Studio project files.
bool TryResolveVisualStudioSolutionFromAssemblies(IEnumerable<IAssembly> assemblies, out IAbsoluteFilePath visualStudioSolutionFilePath, out string failureReason)
Parameters
assembliesIEnumerable<IAssembly>The assemblies whose Visual Studio project files are used to infer the solution.
visualStudioSolutionFilePathIAbsoluteFilePathThe path to the Visual Studio solution file inferred, null if this method returns false.
failureReasonstringIf this method returns false, this string contains a plain-english description of the reason why no solution file can be inferred, else it is null.
Returns
Remarks
The inference relies on VisualStudioProjectFilePath of each assembly, obtained at analysis time. Assemblies with no existing project file (third-party assembly, no PDB, non C# project) are ignored.
Solution files are searched in the parent directories of each project file, up to the repository root (the first directory that contains a .git folder or file) or the drive root.
The solution chosen is the one that contains all the project files with the fewest other projects. If no solution contains them all, the one that contains the most is chosen.
When two solutions are equally good candidates, typically a .sln and its .slnx conversion, no solution is inferred and this method returns false.
To resolve distinct solutions for application and test code, call this method once with Assemblies of Application and once with the ones of TestCode.