-
Notifications
You must be signed in to change notification settings - Fork 266
Open
Labels
area: testinghelpersIssues that address the testing helpersIssues that address the testing helpersstate: ready to pickIssues that are ready for being worked onIssues that are ready for being worked ontype: bugIssues that describe misbehaving functionalityIssues that describe misbehaving functionality
Description
Describe the bug
When using FileSystem
and MockFileSystem
I noticed there is different behavior when creating a new IFileInfo
using only whitespaces.
The "error" trails down to the PathVerifier that the MockFileSystem
uses
To Reproduce
// Both throw in Linux and windows
var mfs = new MockFileSystem();
mfs.FileInfo.New(" "); // ASCII space
mfs.FileInfo.New("\u00A0"); // Unicode char that's treated as whitespace
// Both pass in Linux
mfs.FileInfo.New("./ ") // Explicit relative path
mfs.FileInfo.New("/ ") // Explicit absolute path
// Passes in Linux
var fs = new FileSystem();
fs.FileInfo.New(" "); // ASCII space
// Passes in Linux and Windows (.NET Core); throws on NET4.8
fs.FileInfo.New("\u00A0"); // Unicode char that's treated as whitespace
Expected behavior
Both calls throw an exception when they should not.
For Linux
(whitespace) is a valid file name
For Windows and Linux \u00A0
is a valid file name. However under .NET Framework it also fails
Additional context
In PathInternal.OS.cs
.NET has a bool IsEffectivelyEmpty(string? path)
method which behaves differently to linux and windows, just to cover those cases.
Currently PathVerifier
uses the string.Trim()
method, which causes the two explained scenarios
- valid unicode chars get trimmed (
\u00A0
) - a whitespace-only relative path is considered to be illegal when it actually is not under linux.
Metadata
Metadata
Assignees
Labels
area: testinghelpersIssues that address the testing helpersIssues that address the testing helpersstate: ready to pickIssues that are ready for being worked onIssues that are ready for being worked ontype: bugIssues that describe misbehaving functionalityIssues that describe misbehaving functionality