-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Description
For the historical reasons described here, .NET was so far throwing if the value of isAsync boolean flag did not match the value returned by SafeFileHandle.IsAsync.
We have agreed to remove these checks:
| if (isAsync && !handle.IsAsync) | |
| { | |
| ThrowHelper.ThrowArgumentException_HandleNotAsync(nameof(handle)); | |
| } | |
| else if (!isAsync && handle.IsAsync) | |
| { | |
| ThrowHelper.ThrowArgumentException_HandleNotSync(nameof(handle)); | |
| } |
And simply pass the actual value of handle.IsAsync to the layer that chooses the right strategy, just like we do when the flag was not provided by the user:
| _strategy = FileStreamHelpers.ChooseStrategy(this, handle, access, bufferSize, handle.IsAsync); |
So the following lines need to be updated:
| _strategy = FileStreamHelpers.ChooseStrategy(this, handle, access, bufferSize, isAsync); |
| _strategy = FileStreamHelpers.ChooseStrategy(this, safeHandle, access, bufferSize, isAsync); |
And all unused code (like the throw helpers) needs to be removed as well. The tests also need to be updated accordingly.
Copilot