Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetDrives on mac returns a DriveInfo.Name "/:\\" -- the colon and backslashes is not expected #927

Open
mikeatdjp opened this issue Dec 22, 2022 · 1 comment
Labels
area: testinghelpers Issues that address the testing helpers state: ready to pick Issues that are ready for being worked on type: bug Issues that describe misbehaving functionality

Comments

@mikeatdjp
Copy link

mikeatdjp commented Dec 22, 2022

Describe the bug
GetDrives on mac returns a DriveInfo.Name "/:\" -- the colon and backslashes is not expected

To Reproduce
Steps to reproduce the behavior:
In latest dotnet core on mac, something like this-

            var fs = new MockFileSystem();
            fs.AddFile("/Users/User/Downloads/file.txt", new MockFileData(""));
            var drives = fs.DriveInfo.GetDrives().ToArray();
            Assert.Equal("/", drives[0].Name);

Expected behavior
Drive names on mac are usually something like "/", "/Volumes/NO NAME", "/Volumes/AMD" without colons.

Additional context
Also, Is there any workaround where I can define the DriveInfos in a MockFileSystem? Or do I have to create Nodes from which MFS derives the DriveInfos?

@mikeatdjp mikeatdjp added state: needs discussion Issues that need further discussion type: bug Issues that describe misbehaving functionality labels Dec 22, 2022
@mikeatdjp mikeatdjp changed the title GetDrives on mac returns a DriveInfo.Name "/:" -- the colon is not expected GetDrives on mac returns a DriveInfo.Name "/:\\" -- the colon and backslashes is not expected Dec 22, 2022
@fgreinacher
Copy link
Contributor

fgreinacher commented Jan 9, 2023

Yes, the available drives are derived from the existing files.
It seems the logic in https://github.com/TestableIO/System.IO.Abstractions/blob/main/src/TestableIO.System.IO.Abstractions.TestingHelpers/MockDriveInfoFactory.cs#L22 does not work properly for macOS.

@fgreinacher fgreinacher added state: ready to pick Issues that are ready for being worked on area: testinghelpers Issues that address the testing helpers and removed state: needs discussion Issues that need further discussion labels Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: testinghelpers Issues that address the testing helpers state: ready to pick Issues that are ready for being worked on type: bug Issues that describe misbehaving functionality
Projects
None yet
Development

No branches or pull requests

2 participants