Skip to content

[Feature] Add properties to track bytes compressed/decompressed to CompressionStream/DecompressionStream #59

Open

Description

@bill-poole

It is sometime useful to know the number of bytes compressed by a CompressionStream and decompressed by a DecompressionStream. There is currently no easy way to determine this. Therefore, it would be great if properties were to be added to the CompressionStream and DecompressionStream classes that count the number of bytes compressed/decompressed.

Activity

  1. oleg-st commented on Sep 24, 2025

    @oleg-st
    Owner

    In .NET the standard approach to add new functionality to a Stream is to wrap it. This will work with any streams, including the built-in DeflateStream and BrotliStream. You can simply override Read/Write and count the bytes.

  2. bill-poole commented on Sep 24, 2025

    @bill-poole
    Author

    In .NET the standard approach to add new functionality to a Stream is to wrap it.

    That's what I meant when I said there was no "easy way". .NET doesn't provide any such wrapper in the standard library, which means we each need to write our own wrapper to count the bytes.

    Note that Utf8JsonWriter has BytesWritten and BytesPending properties for this purpose.

    But yes, I recognize that other compression stream types in the .NET standard library have the same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions