Skip to content

DeflateStream/GZipStream/BrotliStream .BaseStream when instance is disposed #84973

Open
@skyoxZ

Description

@skyoxZ

public Stream BaseStream => _deflateStream?.BaseStream!;

/// <summary>Gets a reference to the underlying stream.</summary>
/// <value>A stream object that represents the underlying stream.</value>
/// <exception cref="System.ObjectDisposedException">The underlying stream is closed.</exception>
public Stream BaseStream => _stream;

https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.deflatestream.basestream?view=net-7.0
https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.gzipstream.basestream?view=net-7.0
https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.brotlistream.basestream?view=net-7.0

The document says that getting BaseStream throws ObjectDisposedException when the underlying stream is closed. I believe the document is incorrect and current implement doesn't check the status of underlying stream. What I want to discuss here is what should BaseStream return if the compressionStream itself is disposed:
a. Null. This is current behavior. If so, the property should be nullable.
b. Throws ObjectDisposedException.
c. The original underlying stream.
d. Undefined.

Some related facts:
The comments of BrotliStream.BaseStream is backported from its document and the document is copied from GZipStream/DeflateStream's document.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions