System.IO.Abstractions icon indicating copy to clipboard operation
System.IO.Abstractions copied to clipboard

feat: Add `Name` to `IFile.Create` (and others)

Open BrianMcBrayer opened this issue 4 years ago • 4 comments

Added draft implementation of a FileStream-like class It is not plumbed in at all because I want to discuss the approach first.

@fgreinacher is this kind of what you were thinking in #779 ? I figured if this is correct, I can go through and update all the related Stream references to return FileStream with the Name property properly set.

BrianMcBrayer avatar Jan 08 '22 18:01 BrianMcBrayer

Just for reference, there are a few other fields that I am not sure I want to tackle now that we could eventually add here:

  • Handle (obsolete)
  • IsAsync - Gets a value that indicates whether the FileStream was opened asynchronously or synchronously
  • SafeFileHandle - Gets a SafeFileHandle object that represents the operating system file handle for the file that the current FileStream object encapsulates

(see https://docs.microsoft.com/en-us/dotnet/api/system.io.filestream?view=net-6.0#properties)

BrianMcBrayer avatar Jan 08 '22 18:01 BrianMcBrayer

@fgreinacher is this kind of what you were thinking in #779 ? I figured if this is correct, I can go through and update all the related Stream references to return FileStream with the Name property properly set.

Yes, that's what I had In mind, thanks for taking care!

fgreinacher avatar Jan 09 '22 20:01 fgreinacher

Just for reference, there are a few other fields that I am not sure I want to tackle now that we could eventually add here:

  • Handle (obsolete)
  • IsAsync - Gets a value that indicates whether the FileStream was opened asynchronously or synchronously
  • SafeFileHandle - Gets a SafeFileHandle object that represents the operating system file handle for the file that the current FileStream object encapsulates

(see https://docs.microsoft.com/en-us/dotnet/api/system.io.filestream?view=net-6.0#properties)

I think we can ignore Handle and SafeFileHandle as these would be impossible to mock in a useful way. I'm unsure about IsAsync - do you have an idea what this is commonly used for?

fgreinacher avatar Jan 09 '22 21:01 fgreinacher

Just for reference, there are a few other fields that I am not sure I want to tackle now that we could eventually add here:

  • Handle (obsolete)
  • IsAsync - Gets a value that indicates whether the FileStream was opened asynchronously or synchronously
  • SafeFileHandle - Gets a SafeFileHandle object that represents the operating system file handle for the file that the current FileStream object encapsulates

(see https://docs.microsoft.com/en-us/dotnet/api/system.io.filestream?view=net-6.0#properties)

I think we can ignore Handle and SafeFileHandle as these would be impossible to mock in a useful way. I'm unsure about IsAsync - do you have an idea what this is commonly used for?

IsAsync is something that can be specified when opening a file that will hint to the system whether IO should be on a ThreadPool thread or not. I'm not very familiar with it.

I think I should add it anyway, since it's just a pass-through property and it's readonly. I'll do that and the other things in the review today, and then I'll start wiring this in.

BrianMcBrayer avatar Jan 10 '22 16:01 BrianMcBrayer

I think this pull request could be closed, as it is now implemented as FileSystemStream in #906. Do you agree, @BrianMcBrayer ?

vbreuss avatar Apr 10 '23 18:04 vbreuss

I agree. I feel bad I did not get around to getting this PR in when it was needed 😬

BrianMcBrayer avatar Apr 11 '23 04:04 BrianMcBrayer