Skip to content

Commit 57346ce

Browse files
authored
CompressionLevel validation breaking change (#27730)
1 parent 8ae7de9 commit 57346ce

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed

docs/core/compatibility/7.0.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
title: Breaking changes in .NET 7
3+
description: Navigate to the breaking changes in .NET 7.
4+
ms.date: 01/04/2022
5+
no-loc: [Blazor, Razor, Kestrel]
6+
---
7+
# Breaking changes in .NET 7
8+
9+
If you're migrating an app to .NET 7, the breaking changes listed here might affect you. Changes are grouped by technology area, such as ASP.NET Core or Windows Forms.
10+
11+
> [!NOTE]
12+
>
13+
> This article is a work in progress. It's not a complete list of breaking changes in .NET 7. To query breaking changes that are still pending publication, see [Issues of .NET](https://issuesof.net/?q=%20is:open%20-label:Documented%20is:issue%20(label:%22Breaking%20Change%22%20or%20label:breaking-change)%20(repo:dotnet%2Fdocs%20or%20repo:aspnet%2FAnnouncements)%20group:repo%20(label:%22:checkered_flag:%20Release:%20.NET%207%22%20or%20label:7.0.0)%20sort:created-desc).
14+
15+
## Core .NET libraries
16+
17+
| Title | Binary compatible | Source compatible | Introduced |
18+
| - | - | - | - |
19+
| [Validate CompressionLevel for BrotliStream](core-libraries/7.0/compressionlevel-validation.md) || ✔️ | Preview 1 |
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
title: ".NET 7 breaking change: Validate CompressionLevel for BrotliStream"
3+
description: Learn about the .NET 7 breaking change in core .NET libraries where the CompressionLevel parameter to BrotliStream constructors is now validated.
4+
ms.date: 01/04/2022
5+
---
6+
# Validate CompressionLevel for BrotliStream
7+
8+
The <xref:System.IO.Compression.CompressionLevel> argument that's passed to <xref:System.IO.Compression.BrotliStream> constructors is now validated to be one of the defined values of the enumeration.
9+
10+
## Previous behavior
11+
12+
Passing any value between 0 and 11 for the <xref:System.IO.Compression.CompressionLevel> parameter was considered valid. The value would either map to the one of the enumeration's defined values or passed as-is to the underlying Brotli implementation.
13+
14+
## New behavior
15+
16+
The only valid values for the <xref:System.IO.Compression.CompressionLevel> parameter of <xref:System.IO.Compression.BrotliStream> constructors are:
17+
18+
- <xref:System.IO.Compression.CompressionLevel.Optimal?displayProperty=nameWithType>
19+
- <xref:System.IO.Compression.CompressionLevel.Fastest?displayProperty=nameWithType>
20+
- <xref:System.IO.Compression.CompressionLevel.NoCompression?displayProperty=nameWithType>
21+
- <xref:System.IO.Compression.CompressionLevel.SmallestSize?displayProperty=nameWithType>
22+
23+
If you pass any other value, an <xref:System.ArgumentException> is thrown at run time.
24+
25+
## Version introduced
26+
27+
.NET 7 Preview 1
28+
29+
## Type of breaking change
30+
31+
This change can affect [binary compatibility](../../categories.md#binary-compatibility).
32+
33+
## Reason for change
34+
35+
Being able to pass arbitrary values that aren't defined by the <xref:System.IO.Compression.CompressionLevel> enumeration is unexpected and undocumented, and is likely to lead to mistakes.
36+
37+
## Recommended action
38+
39+
If necessary, change your code to pass in one of the valid <xref:System.IO.Compression.CompressionLevel> values.
40+
41+
## Affected APIs
42+
43+
- <xref:System.IO.Compression.BrotliStream.%23ctor(System.IO.Stream,System.IO.Compression.CompressionLevel,System.Boolean)>
44+
- <xref:System.IO.Compression.BrotliStream.%23ctor(System.IO.Stream,System.IO.Compression.CompressionLevel)>

docs/core/compatibility/toc.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ items:
1919
- name: Breaking changes by version
2020
expanded: true
2121
items:
22+
- name: .NET 7
23+
items:
24+
- name: Overview
25+
href: 7.0.md
26+
- name: Core .NET libraries
27+
items:
28+
- name: Default serialization format for TimeSpan
29+
href: core-libraries/7.0/compressionlevel-validation.md
2230
- name: .NET 6
2331
items:
2432
- name: Overview
@@ -623,6 +631,10 @@ items:
623631
href: code-analysis/5.0/ca2247-ctor-arg-should-be-taskcreationoptions.md
624632
- name: Core .NET libraries
625633
items:
634+
- name: .NET 7
635+
items:
636+
- name: Default serialization format for TimeSpan
637+
href: core-libraries/7.0/compressionlevel-validation.md
626638
- name: .NET 6
627639
items:
628640
- name: API obsoletions with non-default diagnostic IDs

0 commit comments

Comments
 (0)