Repository navigation
[6.1] Preserve sequential Unicode source buffers (#4945) - #4963
Merged
cheenamalhotra merged 1 commit intoNov 3, 2026
Merged
Conversation
Backport #4945 from commit 8dae635. Keep the shared decoder fix and ownership/boundary tests. Adapt SQL Unicode regression coverage to the 6.1 explicit test includes, net8.0/net9.0/net462 targets, and connection-scoped temporary tables; omit unrelated UTF-8 coverage and main-only fixtures. Validated 11 decoder cases and 4 LocalDB round-trip cases per framework on Windows x64. Real big-endian execution remains required. Co-authored-by: Copilot App <[email protected]>
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Reported validation covers only little-endian x64, leaving the corrected big-endian decoding path untested on its target runtime and requiring maintainer review of release risk.
No open issues 🎉
What changed in this PR
Backports #4945 to release/6.1 to fix corrupted sequential nvarchar reads on big-endian platforms. The shared decoder now reads UTF-16LE directly into the destination without modifying the source buffer.
Changes:
- Preserves raw code units, offsets, and partial-read behavior without public API or dependency changes.
- Adds decoder unit tests and SQL round-trip tests, registered in manual test set 3.
- Documents release-specific test commands and the requirement for real big-endian validation.
Reported x64 validation passed across all three target frameworks; the big-endian path remains unvalidated.
| File | Description |
|---|---|
TESTGUIDE.md |
Documents regression commands and platform validation limits. |
src/Microsoft.Data.SqlClient/tests/UnitTests/SqlUnicodeEncodingTests.cs |
Tests source preservation, code units, offsets, and capacity boundaries. |
src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/GlobalizationTest/GlobalizationEncodingTests.cs |
Tests Unicode SQL round trips with buffered and streamed input and synchronous/asynchronous reads. |
src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj |
Includes the regression in manual test set 3. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSequentialTextReader.cs |
Replaces source-buffer byte swapping with non-mutating decoding. |
Review effort: Balanced
benrr101
approved these changes
Nov 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Backport #4945 (source commit
8dae63509ca17fa5b345596f7f3752bea7a4defd) torelease/6.1.Sequential
nvarcharreads could corrupt text on big-endian platforms because the decoder byte-swapped the caller's source buffer, including bytes not consumed by a capacity-limited conversion. Decode UTF-16LE directly into the destination instead, preserving raw code units, offsets, partial reads, zero-capacity behavior, and source ownership. The production decoder change matches the merged fix.Release-specific adaptations:
net8.0,net9.0, andnet462targets and existing dependencies. No project restructuring, package updates, or public API changes.TestSet=3compile list. This branch does not have main's globalization test file or DatabaseObjects fixtures, so use a connection-scoped temporary table, created by a separate unparameterized command to preserve its session scope.TESTGUIDE.md; omit unrelated UTF-8 globalization coverage.Issues
Backports #4945.
Remote
release/6.1was fetched before implementation and again before publication; it remains atb133d8a7defa7919125e961638c5ac5b256f187c. No existing matching backport or conflicting fix was found.Testing
Windows x64: 33 decoder unit cases and 12 SQL round-trip cases passed, with zero skips on the final runs. SQL integration used existing SQL LocalDB 17.0.4025.3 with native SNI and the
masterdatabase; only connection-scoped temporary tables were created. Coverage includes raw UTF-16LE/unpaired surrogates, immutable input, offsets, partial consumption, odd trailing bytes, zero capacity, buffered/streamed parameters, synchronous/asynchronous readers, packet-spanning values, read sizes 1/3/mixed, sentinels, and repeatable EOF.The repository-pinned SDK 9.0.312 was unavailable. Commands were executed from the session directory against absolute project paths using installed SDK 10.0.403 without modifying
global.json.-p:NuGetAudit=falsebypassed an inaccessible vulnerability-data feed that otherwise caused NU1900-as-error; dependency versions and feeds were unchanged.Exact successful commands and results:
Temporary output-directory
config.jsonoverrides supplied LocalDB connection strings for TCP/NP configuration fields. For net8/net9, the existing pinned SNI runtime 6.0.3 win-x64 DLL was copied from the restored package into test output; net462 already had the required architecture DLLs. Overrides were deleted after validation. Initial unconfigured/skipped and missing-native-DLL runs were not counted as passes; all four SQL cases executed on each final run.git diff --checkandgit diff HEAD^ HEAD --check: passed. No source changes have been made since validation.Outstanding validation: x64 runs exercise only the little-endian decoder path. The big-endian branch still requires a real big-endian client runtime (for example s390x); these results do not claim big-endian execution. The original customer platform/repro was not available. Full suites were not run.
Guidelines
Please review the contribution guidelines before submitting a pull request: