Augment tests for FileMode.Append#55513
Conversation
|
Tagging subscribers to this area: @dotnet/area-system-io Issue DetailsTo validate that seeking and writing are valid in the region of the file since its initial length. Codifying my comments from:
|
To validate that seeking and writing are valid in the region of the file since its initial length.
064f696 to
4ad205c
Compare
| fs.Write(Encoding.ASCII.GetBytes("abcde")); | ||
| Assert.Equal(5, fs.Length); | ||
| Assert.Equal(5, fs.Position); | ||
| Assert.Equal(1, fs.Seek(1, SeekOrigin.Begin)); |
There was a problem hiding this comment.
I would expect that FileMode.Append means "I want to append data to EOF" rather than "I want to write data at requested offset". The official doc for FileMode.Append says:
Trying to seek to a position before the end of the file throws an IOException exception
I believe that current implementation of Append is buggy and we should fix it instead of adding a test that ensures that it's buggy. I am going to reopen #55465 for that
There was a problem hiding this comment.
I interpret that to mean before the end of the file at the time it was opened, and the current implementation is consistent with that and has been for 20 years. If you believe it's worth taking a breaking change, that's a fine discussion to have, but it's absolutely a breaking change.
There was a problem hiding this comment.
adding a test that ensures that it's buggy
The tests validate the expected behavior.
To validate that seeking and writing are valid in the region of the file since its initial length. Codifying my comments from:
#55465 (comment)
#55465 (comment)
#55465 (comment)