Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
carlossanlop merged 2 commits intodotnet:mainfromadamsitnik:anotherBufferingBug
Apr 13, 2021
Merged
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
NextNext commit
add a failing test that mimcs the SDK bug
  • Loading branch information
@adamsitnik
adamsitnik committedApr 12, 2021
commit7c5ecf2836303a68acd3b84de1a6b71a4ba10c5c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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];
Copy link
Member

Choose a reason for hiding this comment

The 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

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

danmoseley reacted with thumbs up emoji
Copy link
Member

@jozkeejozkeeApr 12, 2021
edited
Loading

Choose a reason for hiding this comment

The 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
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp