8000 Bump .NET core framework to 3.1-preview.2 by adityapatwardhan · Pull Request #10993 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@adityapatwardhan
Copy link
Member
@adityapatwardhan adityapatwardhan commented Nov 5, 2019

PR Summary

Move to .NET core 3.1-preview.2

PR Context

PR Checklist

@adityapatwardhan adityapatwardhan added this to the 7.0.0-preview.6 milestone Nov 5, 2019
@adityapatwardhan adityapatwardhan added the CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log label Nov 5, 2019
Copy link
Member
@daxian-dbw daxian-dbw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@adityapatwardhan adityapatwardhan self-assigned this Nov 7, 2019
@adityapatwardhan adityapatwardhan merged commit 08e120c into PowerShell:master Nov 7, 2019
@adityapatwardhan adityapatwardhan deleted the UpdateDotNet3_1_p2 branch November 7, 2019 19:45
// 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)
Copy link
Member

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);

Copy link
Member

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.

@ghost
Copy link
ghost commented Nov 21, 2019

🎉v7.0.0-preview.6 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

0