Skip to content

[Breaking change]: Validate CompressionLevel for BrotliStream #25665

Closed
@i3arnon

Description

@i3arnon

Description

The change validates that the CompressionLevel argument of the System.IO.Compression.BrotliStream constructors is a defined value of the enum: Optimal, Fastest, NoCompression or SmallestSize.

Previously any underlying value from 0 to 11 would be valid and passed on as the level to Brotli, unless it's mapped to any of the CompressionLevel enum values.

Version

.NET 7 Preview 1

Previous behavior

Passing any value between 0 and 11 to the CompressionLevel parameter BrotliStream would be valid.
The value would either map to the one of the enum's defined values or passed as is to the underlying Brotli implementation.

New behavior

Only Optimal, Fastest, NoCompression or SmallestSize are valid values for the CompressionLevel parameter.

Type of breaking change

  • Binary incompatible: Existing binaries may encounter a breaking change in behavior, such as failure to load/execute or different run-time behavior.
  • Source incompatible: Source code may encounter a breaking change in behavior when targeting the new runtime/component/SDK, such as compile errors or different run-time behavior.

Reason for change

Being able to pass arbitrary values which are not defined by the CompressionLevel enum is unexpected and undocumented with a probability for mistakes.

Recommended action

Pass in only one of the valid values for CompressionLevel

Feature area

Core .NET libraries

Affected APIs

All System.IO.Compression.BrotliStream constructors that accept CompressionLevel

Metadata

Metadata

Assignees

Labels

🏁 Release: .NET 7Work items for the .NET 7 releasebinary incompatibleExisting binaries may encounter a breaking change in behavior.breaking-changeIndicates a .NET Core breaking changesource incompatibleSource code may encounter a breaking change in behavior when targeting the new version.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions