Skip to content

Commit

Permalink
use IsTextFile to respect text file convention from EmptyFiles
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Jan 12, 2025
1 parent a2a9075 commit 2720269
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<PackageVersion Include="Argon" Version="0.26.0" />
<PackageVersion Include="Argon.FSharp" Version="0.26.0" />
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
<PackageVersion Include="DiffEngine" Version="15.6.0" />
<PackageVersion Include="DiffEngine" Version="15.7.0" />
<PackageVersion Include="Expecto" Version="10.2.1" />
<PackageVersion Include="Fixie" Version="4.1.0" />
<PackageVersion Include="Fixie.TestAdapter" Version="4.1.0" />
Expand Down
21 changes: 7 additions & 14 deletions src/Verify/Verifier/InnerVerifier_Directory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,16 @@ async Task<List<Target>> ToTargets(

static async Task<Target> TargetFromFile(string path, string relativePath, FileScrubber? fileScrubber, Func<Stream> 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();
Expand All @@ -132,12 +133,4 @@ static async Task<Target> 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;
}
}

0 comments on commit 2720269

Please sign in to comment.