Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
The BrotliStream constructors that take a CompressionLevel argument no longer allow values that aren't defined in the CompressionLevel enumeration. If you pass an invalid value, an ArgumentException is thrown.
BrotliStream allowed you to pass an arbitrary compression level to the constructor by casting the desired level directly to CompressionLevel. For example:
BrotliStream brotli = new BrotliStream(baseStream,
(CompressionLevel)5); // Use level 5
However, if an arbitrary level was provided, that was passed through as-is to the underlying library, resulting in inconsistent and potentially unexpected behavior.
BrotliStream only allows the values defined in CompressionLevel. If you pass an undefined value to the constructor, an ArgumentException is thrown.
.NET 7
This change can affect binary compatibility.
The purpose of the CompressionLevel enumeration is to let developers use compression algorithms without needing to understand the meaning of their tuning parameters.
If an arbitrary level was provided, that was passed through as-is to the underlying library, resulting in inconsistent and potentially unexpected behavior. With this change, the behavior is aligned with other compression streams, for example, DeflateStream.
With the new tuning of the CompressionLevel values and the addition of CompressionLevel.SmallestSize, it's now possible to have a variety of trade-offs in the compression algorithms. Users can continue to rely on CompressionLevel values as being abstractions of such trade-offs.
If you were relying on passing undefined values as the CompressionLevel, revisit your use case and decide which documented value is the most optimal for it.
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register now