public static HashSet <string> CreateTargetsSet(IEnumerable <string> targetSpecifiers, bool recurse) { HashSet <string> targets = new HashSet <string>(StringComparer.OrdinalIgnoreCase); foreach (string specifier in targetSpecifiers) { string normalizedSpecifier = specifier; Uri uri; if (Uri.TryCreate(specifier, UriKind.RelativeOrAbsolute, out uri)) { if (uri.IsAbsoluteUri && (uri.IsFile || uri.IsUnc)) { normalizedSpecifier = uri.LocalPath; } } // Currently, we do not filter on any extensions. var fileSpecifier = new FileSpecifier(normalizedSpecifier, recurse); foreach (string file in fileSpecifier.Files) { targets.Add(file); } } return(targets); }
public void ResolveDirectoriesAndFiles(string input, bool recurse, int expectedCount) { string currentWorkingDirectory = Environment.CurrentDirectory; try { Environment.CurrentDirectory = _fixture.RootDirectory; // This test provides basic verification that simple patterns // matching one or more files in the current directory succeed var specifier = new FileSpecifier(input, recurse: recurse); specifier.Files.Count.Should().Be(expectedCount); specifier = new FileSpecifier(Path.Combine(_fixture.RootDirectory, input), recurse: recurse); specifier.Files.Count.Should().Be(expectedCount); Environment.CurrentDirectory = currentWorkingDirectory; specifier = new FileSpecifier(Path.Combine(_fixture.RootDirectory, input), recurse: recurse); specifier.Files.Count.Should().Be(expectedCount); } finally { Environment.CurrentDirectory = currentWorkingDirectory; } }
private HashSet <string> CreateTargetsSet(TOptions analyzeOptions) { HashSet <string> targets = new HashSet <string>(StringComparer.OrdinalIgnoreCase); foreach (string specifier in analyzeOptions.TargetFileSpecifiers) { string normalizedSpecifier = specifier; Uri uri; if (Uri.TryCreate(specifier, UriKind.RelativeOrAbsolute, out uri)) { if (uri.IsAbsoluteUri && (uri.IsFile || uri.IsUnc)) { normalizedSpecifier = uri.LocalPath; } } // Currently, we do not filter on any extensions. var fileSpecifier = new FileSpecifier(normalizedSpecifier, recurse: analyzeOptions.Recurse, fileSystem: FileSystem); foreach (string file in fileSpecifier.Files) { targets.Add(file); } } return(targets); }
public void ResolveFiles(string input, int expectedCount) { // This test provides basic verification that simple patterns // matching one or more files in the current directory succeed var specifier = new FileSpecifier(input); specifier.Files.Count.Should().Be(expectedCount); specifier = new FileSpecifier(Path.Combine(Environment.CurrentDirectory, input)); specifier.Files.Count.Should().Be(expectedCount); }