Skip to content

Commit

Permalink
Explicitly stripping dots from path end for comparison
Browse files Browse the repository at this point in the history
.NET behavior changed with 4.6.2. See here for more details: https://learn.microsoft.com/th-th/dotnet/framework/migration-guide/mitigation-path-normalization

4.6.1 DirectoryInfo apparently strips ... (and maybe similar tokens, too), particularly for its FullName property, which is being used here. This changed in 4.6.2.

Assuming that the test indicates a desire for support, the simplest thing to do is to strip dots for comparison.

I also experimented with "Switch.System.IO.UseLegacyPathHandling=true" in the app.config, but this had no discernible impact and generally seems ill-advised.
  • Loading branch information
josephmyers committed Jul 26, 2024
1 parent ecd8213 commit d24fafe
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion SIL.Core/IO/DirectoryHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static bool AreEquivalent(DirectoryInfo dirInfo1, DirectoryInfo dirInfo2)
: StringComparison.InvariantCulture;
var backslash = new[]
{
'\\', '/'
'\\', '/', '.'
}; // added this step because mono does not implicitly convert from char to char[]
return string.Compare(dirInfo1.FullName.TrimEnd(backslash),
dirInfo2.FullName.TrimEnd(backslash), comparison) == 0;
Expand Down

0 comments on commit d24fafe

Please sign in to comment.