Handled System.NotSupportedException but can be avoided? #745

Closed
opened 2026-01-29 22:16:47 +00:00 by claunia · 0 comments
Owner

Originally created by @sherlock1982 on GitHub (Dec 22, 2025).

Originally assigned to: @adamhathcock, @Copilot on GitHub.

Open xz file like this:

            using var fileStream = new FileStream(updateFilename, FileMode.Open, FileAccess.Read);
            using var reader = ReaderFactory.Open(fileStream, new SharpCompress.Readers.ReaderOptions()
            {
                LeaveStreamOpen = true,
            });

SharpCompressStream is wrapped around ReadOnlyStream and ReadOnlyStream doesnt' support Position get. In SharpCompressStream exception is handled:

    try
    {
        _baseInitialPos = stream.Position;
    }
    catch
    {
        _baseInitialPos = 0;
    }

But this is still exception thrown for each entry I think which causes performance issues. Can it be avoided? Check for CanSeek ?

Originally created by @sherlock1982 on GitHub (Dec 22, 2025). Originally assigned to: @adamhathcock, @Copilot on GitHub. Open xz file like this: using var fileStream = new FileStream(updateFilename, FileMode.Open, FileAccess.Read); using var reader = ReaderFactory.Open(fileStream, new SharpCompress.Readers.ReaderOptions() { LeaveStreamOpen = true, }); `SharpCompressStream` is wrapped around `ReadOnlyStream` and `ReadOnlyStream` doesnt' support Position get. In `SharpCompressStream` exception is handled: try { _baseInitialPos = stream.Position; } catch { _baseInitialPos = 0; } But this is still exception thrown for each entry I think which causes performance issues. Can it be avoided? Check for `CanSeek` ?
claunia added the bug label 2026-01-29 22:16:47 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#745