nunit-console: DirectoryFinder.GetDirectories throws for a path with the drive specified

DirectoryFinder.GetDirectories() is a method used when locating engine extensions. (See locating addins in the docs, for background) It searches file paths for wildcard characters, and returns all possible directories that could match the wildcard.

It currently throws when passed a path containing a drive, e.g. C:\Users\Chris\mock-event-listener.dll. It should be able to handle such paths in the normal way.

Tagging this as a nice, approachable issue for a first time contributor. If I was tackling this, my first step would be to create a unit test which reproduces the issue, and look at why the exception is thrown, and how this could be prevented.

Below is the stack trace currently thrown:

System.ArgumentException
  HResult=0x80070057
  Message=Second path fragment must not be a drive or UNC name.
Parameter name: path2
  Source=mscorlib
  StackTrace:
   at System.IO.Path.InternalCombine(String path1, String path2)
   at System.IO.FileSystemEnumerableIterator`1.GetFullSearchString(String fullPath, String searchPattern)
   at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)
   at System.IO.DirectoryInfo.InternalGetDirectories(String searchPattern, SearchOption searchOption)
   at NUnit.Engine.Internal.DirectoryFinder.ExpandOneStep(IList`1 dirList, String pattern) in C:\Users\Chris\Documents\git\nunit-console\src\NUnitEngine\nunit.engine.core\Internal\DirectoryFinder.cs:line 147
   at NUnit.Engine.Internal.DirectoryFinder.GetDirectories(DirectoryInfo baseDir, String pattern) in C:\Users\Chris\Documents\git\nunit-console\src\NUnitEngine\nunit.engine.core\Internal\DirectoryFinder.cs:line 76
   at NUnit.Engine.Internal.DirectoryFinder.GetFiles(DirectoryInfo baseDir, String pattern) in C:\Users\Chris\Documents\git\nunit-console\src\NUnitEngine\nunit.engine.core\Internal\DirectoryFinder.cs:line 102
   at NUnit.Engine.Services.ExtensionService.ProcessAddinsFile(DirectoryInfo baseDir, String fileName, Boolean fromWildCard) in C:\Users\Chris\Documents\git\nunit-console\src\NUnitEngine\nunit.engine.core\Services\ExtensionService.cs:line 351
   at NUnit.Engine.Services.ExtensionService.ProcessAddinsFiles(DirectoryInfo startDir, Boolean fromWildCard) in C:\Users\Chris\Documents\git\nunit-console\src\NUnitEngine\nunit.engine.core\Services\ExtensionService.cs:line 315
   at NUnit.Engine.Services.ExtensionService.FindExtensionAssemblies(DirectoryInfo startDir) in C:\Users\Chris\Documents\git\nunit-console\src\NUnitEngine\nunit.engine.core\Services\ExtensionService.cs:line 289
   at NUnit.Engine.Services.ExtensionService.StartService() in C:\Users\Chris\Documents\git\nunit-console\src\NUnitEngine\nunit.engine.core\Services\ExtensionService.cs:line 185

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 21 (20 by maintainers)

Commits related to this issue

Most upvoted comments

I can do that πŸ˜ƒ. It has been assigned to you @x789.

I will tackle the original issue first. I think absolute path support on Unix systems is priority 2.

The short answer to the question if we can use IsPathFullyQualified(string) is β€œyes”. The long answer is: On systems that use β€˜/’ as root, any path that starts with a β€˜/’ is an absolute path. On Windows systems, the first three characters of the path must be examined, with the second character being the DriveSeparator and the third character being the DirectorySeparator.

If you want to see how that part of IsPathFullyQualified(string) is implemented, check out the method IsPartiallyQualified in PathInternal.Windows.cs and PathInternal.Unix.cs.