Repository navigation
feat!: target .NET 11 and use its span decoders - #1
Merged
Merged
Conversation
Text files are stored with LF and checked out with the platform's line endings. Before, editors that write CRLF made every line of a touched file show up as changed. Co-Authored-By: Claude Opus 5.5 (xhigh) <noreply@anthropic.com>
Also updates the test packages (Microsoft.NET.Test.Sdk 18.11.1, xunit.v3 4.0.3, xunit.runner.visualstudio 4.0.1, coverlet.collector 10.1.0) and runs dotnet test on Microsoft.Testing.Platform via global.json. Co-Authored-By: Claude Opus 5.5 (xhigh) <noreply@anthropic.com>
Pull requests to master now run the build and test steps. Packing and the NuGet push still only run for pushes to master. Co-Authored-By: Claude Opus 5.5 (xhigh) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (xhigh) <noreply@anthropic.com>
On net11.0, Deflate, Gzip and Zlib use DeflateDecoder, GZipDecoder and ZLibDecoder, and Zstd is registered with ZstandardDecoder. net10.0 keeps the stream-based implementation. On both target frameworks, every built-in decompressor now follows the rules of BrotliDecoder.TryDecompress: bytes after the compressed data are ignored, but a destination that is too small or an incomplete source fails. Further gzip members and Zstandard frames are decompressed as well. TryDecompress reports 0 bytes written whenever it fails. BREAKING CHANGE: Deflate, Gzip and Zlib returned true with truncated output when the destination was too small or the source was incomplete. They now return false. Co-Authored-By: Claude Opus 5.5 (xhigh) <noreply@anthropic.com>
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.
Adds a
net11.0target. On .NET 11 the built-in decompressors use the new span-based decoders (DeflateDecoder,GZipDecoder,ZLibDecoder), andCompressionAlgorithm.Zstdis registered withZstandardDecoder.net10.0keeps the stream-based implementation.Behavior
Every built-in decompressor now follows the rules of
BrotliDecoder.TryDecompress, on both target frameworks:true, truncated outputfalsetrue, partial outputfalseTryDecompressreportsbytesWritten = 0whenever it returnsfalse. Before, a failing handler's partial count leaked through, e.g. Brotli with a too-small destination.Breaking change: callers that relied on truncated output for a too-small destination or an incomplete source now get
false, andDecompressthrowsInvalidDataException.Decisions worth a look
TryDecompressmethods on .NET 11. The static methods also fail when any byte follows the compressed data. The instance API stops at the end of the data, which keeps padding and trailing bytes working as before.Reset():GZipStreamrule from .NET 10 (Inflater.ResetStreamForLeftoverInput): another member starts if the rest begins with1F, followed by8Bwhen a second byte exists.ZstandardStream: another frame starts if the next 4 bytes are a frame or skippable-frame magic number.DestinationTooSmallfor an empty buffer even when nothing is left to write, e.g. an empty trailing gzip member or a skippable frame.TryDecompressStreamandSourceStream):DeflateStreamonly reads from its base stream while the inflater is unfinished and out of input. SoSourceStream, a smallUnmanagedMemoryStreamsubclass, flags any read past the end as an incomplete source.GZipStreamreads once more after a member that ends exactly at the end of the source. A sentinel byte (0xFF, which can't start a member) answers that read. Deflate and Zlib don't get one.Other changes
src/global.jsonrunsdotnet teston Microsoft.Testing.Platform.master. Pack, artifact upload and the NuGet push only run for pushes tomaster..gitattributeswith* text=auto. The repository already stores LF, so no file changes.JsonUtilsno longer has an unneededunsafemodifier.masterafter merging won't publish a new package (--skip-duplicate).Validation
New tests in
IDecompressorTests.cs(the 3.2.0 tests are unchanged):Checks run locally on Windows with SDK 11.0.100:
Tests:
dotnet test -c Releaseon this branch in a clean worktree: 90 passed on net10.0 and net11.0, 0 build warnings.Same results on both target frameworks: 61,120 generated inputs, decoded on .NET 10 and .NET 11: every prefix of the compressed data, padding variants, destination sizes, concatenated streams, flipped bytes. 0 mismatches. The net10.0 build running on the .NET 11 runtime (roll-forward) gave 0 mismatches as well.
Mutation check: 13 deliberate bugs in
IDecompressor.cs, run against the new tests:0x00instead of0xFF, behaves identically: any value except0x1Fworks.net10.0 overhead vs. 3.2.0 (Stopwatch, exact-size destination):
🤖 Generated by Opus 5.5 (xhigh) with Claude Code in T3 Code