diff --git a/docs/naming.md b/docs/naming.md index e4716c4fe..1acbcd576 100644 --- a/docs/naming.md +++ b/docs/naming.md @@ -673,6 +673,8 @@ Debug.WriteLine(Namer.RuntimeAndVersion); * `type`: The class the test method exists in. * `method`: The test method. +Any value provided in [UseDirectory](#directory) will take precedence over the value provided in `PathInfo.Directory`. + Return null to any of the values to use the standard behavior. The returned path can be relative to the directory sourceFile exists in. `DerivePathInfo` can also be useful when deriving the storage directory on a [build server](build-server.md#custom-directory-and-file-name) diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index d5700ae4a..4afb2c427 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -7,7 +7,7 @@ - + diff --git a/src/Verify/Verifier/InnerVerifier_Directory.cs b/src/Verify/Verifier/InnerVerifier_Directory.cs index d951ece24..4b82a3143 100644 --- a/src/Verify/Verifier/InnerVerifier_Directory.cs +++ b/src/Verify/Verifier/InnerVerifier_Directory.cs @@ -108,15 +108,16 @@ async Task> ToTargets( static async Task TargetFromFile(string path, string relativePath, FileScrubber? fileScrubber, Func openStream) { - if (!TryGetExtension(path, out var extension)) + var extension = Path + .GetExtension(path) + .Replace(".", string.Empty); + + if (extension.Length == 0) { - return new( - "noextension", - openStream(), - relativePath); + extension = "noextension"; } - if (FileExtensions.IsTextExtension(extension)) + if (FileExtensions.IsTextFile(path)) { using var stream = openStream(); var builder = await stream.ReadStringBuilderWithFixedLines(); @@ -132,12 +133,4 @@ static async Task TargetFromFile(string path, string relativePath, FileS openStream(), relativePath); } - - static bool TryGetExtension(string path, [NotNullWhen(true)] out string? extension) - { - extension = Path - .GetExtension(path) - .Replace(".", string.Empty); - return extension.Length > 0; - } } \ No newline at end of file