-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Bump .NET core framework to 3.1-preview.2 #10993
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bump .NET core framework to 3.1-preview.2 #10993
Conversation
e05f615 to
312f84a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| // The change was made in https://github.com/dotnet/coreclr/pull/27229 | ||
| // The recommendation from .NET team is to not check for 'completed' if 'flush' is false. | ||
| // Break out of the loop if all bytes have been read. | ||
| if (!flush && bytesRead == byteIndex) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that complete is useless, I think we'd better change this implementation a bit more. Like the following:
while (true)
{
// Read at most the number of bytes that will fit in the input buffer. The
// return value is the actual number of bytes read, or zero if no bytes remain.
bytesRead = stream.Read(bytes, 0, useBufferSize * 4);
if (bytesRead == 0)
{
break;
}
bool completed = false;
int byteIndex = 0;
int bytesUsed;
int charsUsed;
while (bytesRead > byteIndex)
{
// If this is the last input data, flush the decoder's internal buffer and state.
bool flush = (bytesRead == 0);
decoder.Convert(bytes, byteIndex, bytesRead - byteIndex,
chars, 0, useBufferSize, flush,
out bytesUsed, out charsUsed, out completed);
// The conversion produced the number of characters indicated by charsUsed. Write that number
// of characters to our result buffer
result.Append(chars, 0, charsUsed);
// Increment byteIndex to the next block of bytes in the input buffer, if any, to convert.
byteIndex += bytesUsed;
}
} while (bytesRead != 0);There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind. Change of the API makes it hard to reason about -- does decoder.Convert needs to be called again when bytesRead is 0? If it's needed, then will it produce any chars? If not, what's the purpose of doing so?
Without the understanding of those questions, let's keep the change as safe as possible, at least for now.
|
🎉 Handy links: |
PR Summary
Move to .NET core 3.1-preview.2
PR Context
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.