- Notifications
You must be signed in to change notification settings - Fork5.2k
Fix the buffering bug that blocks SDK#51151
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -161,6 +161,31 @@ public async Task LengthIsNotCachedAfterHandleHasBeenExposed(FileAccess fileAcce | ||
| Assert.Equal(2, stream.Length); | ||
| Assert.Equal(2, createdFromHandle.Length); | ||
| } | ||
| [Fact] | ||
| public async Task WriteByteFlushesTheBufferWhenItBecomesFull() | ||
| { | ||
| string filePath; | ||
| List<byte> writtenBytes = new List<byte>(); | ||
| using (FileStream stream = (FileStream)await CreateWriteOnlyStreamCore(Array.Empty<byte>())) | ||
| { | ||
| filePath = stream.Name; | ||
| stream.WriteByte(0); | ||
| writtenBytes.Add(0); | ||
| byte[] bytes = new byte[BufferSize - 1]; | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Is it worth putting something other than zeros in here? So it's distinct from the first byte you wrote Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Doesn't really matter. What matters is that we are attempting to write an 11th character on the stream when the buffer can only hold 10 characters. Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. ...and the problem was that the internal buffer is not being reset/flushed when WriteByte is called when this buffer is already full. | ||
| stream.Write(bytes.AsSpan()); | ||
| writtenBytes.AddRange(bytes); | ||
| stream.WriteByte(1); | ||
| writtenBytes.Add(1); | ||
| } | ||
| byte[] allBytes = File.ReadAllBytes(filePath); | ||
| Assert.Equal(writtenBytes.ToArray(), allBytes); | ||
| } | ||
| } | ||
| public class UnbufferedSyncFileStreamStandaloneConformanceTests : FileStreamStandaloneConformanceTests | ||