Fix TarFactory extension hinting in TryOpenReader, TryOpenReaderAsync, and GetCompressionType#1256
Draft
Copilot wants to merge 2 commits into
Draft
Fix TarFactory extension hinting in TryOpenReader, TryOpenReaderAsync, and GetCompressionType#1256Copilot wants to merge 2 commits into
Copilot wants to merge 2 commits into
Conversation
…e, and TryOpenReaderAsync Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix tar archive extension hinting in key functions
Fix TarFactory extension hinting in TryOpenReader, TryOpenReaderAsync, and GetCompressionType
Mar 17, 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.
TarFactory.IsArchiveandGetCompressionTypehad no path to receiveReaderOptions, soExtensionHintand customProviderswere silently dropped wheneverFactory.TryOpenReaderdrove detection. Every call fell back to brute-forcing allTarWrappercandidates and the GZip probe lacked itsCompressionContext.Changes
TarFactory— overrideTryOpenReader/TryOpenReaderAsyncTryOpenReader: replaces the base-class pattern ofIsArchive→Rewind(true)→OpenReaderwith a direct wrapper loop that passesoptions.Providersand fullReaderOptionsintoCreateProbeDecompressionStream. Usesstream.Rewind(true)(notStopRecording()) to correctly reset both seekable (SeekableSharpCompressStream) and ring-buffer streams.TryOpenReaderAsync: wraps the incomingSharpCompressStreamin a fresh ring-bufferSharpCompressStreambefore probing. This is required because decompressor constructors (e.g.LZipStream,XZStream) perform synchronous reads; the ring buffer lets those sync reads replay data that was fetched asynchronously — critical for async-only transports.TarFactory.GetCompressionType/GetCompressionTypeAsyncAdded optional
IReaderOptions? readerOptions = nullparameter, threaded through toCreateProbeDecompressionStream/CreateProbeDecompressionStreamAsync.For
GetCompressionTypeAsyncthe new parameter is inserted beforeCancellationToken; all in-tree callers are updated.TarArchive.Factory.csAll
GetCompressionType/GetCompressionTypeAsynccall-sites now passsourceStream.ReaderOptions, so archive-open paths also benefit from hint propagation.Tests
Added
TarReaderTestscases that open compressed tar archives viaReaderFactory.OpenReaderwith an explicitExtensionHint(.tar.gz,.tar.bz2,.tar.xz,.tar), exercising the previously broken detection path.Original prompt
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.