Repository navigation
[7.0] Preserve sequential Unicode source buffers (#4945) - #4962
Conversation
Backport #4945 from 8dae635. Decode UTF-16LE code units without mutating consumed or unconsumed source bytes. Retain the release framework/dependency layout. Add focused Unicode round-trip coverage to manual test set 3 and document release commands in BUILDGUIDE.md instead of importing main's unrelated globalization tests or TESTGUIDE.md. Validated 11 decoder cases and 4 SQL round-trip cases per framework on net8.0, net9.0, net10.0 and net462, plus active legacy implementation builds. SQL tests used an isolated tempdb config; real big-endian execution remains outstanding. (cherry picked from commit 8dae635) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🔵 Needs a closer look
Runtime validation covers only x64/little-endian, leaving the decoder fix and sync/async SQL sequential-read regressions unverified on a real big-endian client.
No open issues 🎉
What changed in this PR
Backports #4945 to release/7.0, fixing corrupted sequential Unicode reads on big-endian platforms by decoding UTF-16LE code units without modifying source buffers.
Changes:
- Replaces in-place byte swapping with non-mutating decoding while preserving partial-read behavior.
- Adds decoder unit tests and sync/async SQL round-trip tests, registered in manual test set 3.
- Documents regression commands and platform limitations without changing public APIs or driver targets.
Reported validation passed on Windows x64; the big-endian path still requires validation on a real big-endian runtime.
| File | Description |
|---|---|
src/Microsoft.Data.SqlClient/tests/UnitTests/SqlUnicodeEncodingTests.cs |
Tests code-unit preservation, partial reads, offsets, and unchanged input buffers. |
src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/GlobalizationTest/GlobalizationEncodingTests.cs |
Adds Unicode round-trip coverage for buffered and streamed sync/async operations. |
src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTests.csproj |
Registers the integration tests in test set 3. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSequentialTextReader.cs |
Decodes consumed UTF-16LE bytes without mutating the source. |
BUILDGUIDE.md |
Documents focused regression commands and the big-endian validation requirement. |
Review effort: Balanced
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## release/7.0 #4962 +/- ##
===============================================
- Coverage 73.21% 66.30% -6.91%
===============================================
Files 296 291 -5
Lines 43453 66316 +22863
===============================================
+ Hits 31813 43970 +12157
- Misses 11640 22346 +10706
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Address review feedback; retain regression commands and platform validation limitations in the PR description. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🔵 Needs a closer look
The corrected corruption path runs only on big-endian runtimes, while reported validation covered only little-endian x64, leaving the affected branch unverified and requiring maintainer review and real big-endian regression testing.
No open issues 🎉
Review effort: Balanced
Description
Backport #4945 from commit
8dae63509ca17fa5b345596f7f3752bea7a4defdtorelease/7.0, persisted as944419b61280237996f4ba4b58cca594380e1c2e.Fix corrupted sequential
nvarcharreads on big-endian platforms: decode raw UTF-16LE code units without mutating consumed or unconsumed source bytes. Preserve offsets, partial reads, zero-capacity conversions, and isolated surrogate code units. The production change is unchanged from the original fix.Release-specific adaptations:
netcore/srcandnetfx/src) compile the single shared decoder source; no duplicate implementation needs patching.TESTGUIDE.md; document release-specific commands and the architecture limitation inBUILDGUIDE.mdinstead.No public API changes, deprecations, localization changes, or intentional breaking changes. Suggested release note: Fix corrupted Unicode text returned by sequential
SqlDataReader.GetTextReaderreads on big-endian platforms.The remote base was refreshed before implementation and again before opening this PR; it remains
0620c4cd441ceef4c83f75f190be4b321c6a2a3d, with no intervening fix. No existing PR matched this head branch.Issues
Backports #4945. This PR does not close the original issue independently of the source fix.
Testing
Windows x64/little-endian: 44 decoder cases and 16 SQL round-trip cases passed, with no skipped cases in the successful final runs. Both active legacy implementation projects built with zero warnings and errors.
Decoder coverage includes raw code-unit preservation, offsets, capacity limits, odd trailing bytes, flush variants, repeated partial reads, unchanged input bytes, and empty conversion. SQL coverage exercises all four sync/async and buffered/streamed parameter combinations, packet-spanning
nvarchar(max), single-character and mixed-size reads, destination sentinels, zero-length reads, and repeated EOF.Environment: the repository-root invocation initially failed because
global.jsonpins unavailable SDK10.0.109. Successful commands below were run fromC:\Users\cmalhotra\.copilot\session-state\87991f1b-e700-4ad8-a764-6e011c4f4a4f\files, using installed SDK10.0.403, without modifying the SDK pin.Exact validation commands and results:
The isolated JSON used
Data Source=tcp:localhost;Database=tempdb;Integrated Security=true;Encrypt=false;for TCP, the equivalentnp:localhoststring for named pipes,SupportsIntegratedSecurity=true, andUseManagedSNIOnWindows=false. It was removed after validation. Transient tables were cleaned by the existing RAII fixture; tracked configuration and server setup were unchanged.Outstanding coverage: no real big-endian runtime is available. These successful x64 runs validate only the little-endian decoder path; running the client on a real big-endian runtime such as s390x remains required to validate the original platform-specific symptom. Full test suites were not run.
Guidelines
Please review the contribution guidelines before submitting a pull request: