-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Closed
Labels
🏁 Release: .NET 6Issues and PRs for the .NET 6 releaseIssues and PRs for the .NET 6 releasebreaking-changeIndicates a .NET Core breaking changeIndicates a .NET Core breaking change
Description
Version introduced
.NET 6 Preview 1
Old behavior
Several types derived from System.IO.Stream overrode methods with different parameter names than was used by the base type. For example, DeflateStream.Read's byte[] argument was named array even though the base Stream.Read's corresponding argument is named buffer.
New behavior
All System.IO.Stream types that had such mismatched parameter names have been brought into conformance with the base type, using the same parameter names on the derived types as on the base type.
Reason for change
There are several reasons for the change:
- If an invalid argument was passed and an exception was thrown, that exception might have contained the base parameter's name or the derived parameter's name, depending on the implementation. Since the caller may have been using a reference typed as the base or as the derived type, it is impossible for the argument name in the exception to always be correct.
- Having different parameter names makes it harder to consistently validate behavior across all Stream implementations.
- .NET 6 adds a public method on Stream for validating arguments, and it needs to have a consistent name it can use.
Recommended action
The effect of this breaking change is minimal:
- For existing binaries, its impact is limited to code using reflection to examine the names of parameters on the derived types.
- For source code, its impact is limited to code using named parameters to invoke methods on the derived stream type using a variable typed as that derived type.
In both cases, the recommended action is to consistently use the base parameter name.
Category
- ASP.NET Core
- C#
- Code analysis
- Core .NET libraries
- Cryptography
- Data
- Debugger
- Deployment
- Globalization
- Interop
- JIT
- LINQ
- Managed Extensibility Framework (MEF)
- MSBuild
- Networking
- Printing
- Security
- Serialization
- Visual Basic
- Windows Forms
- Windows Presentation Foundation (WPF)
- XML, XSLT
Issue metadata
- Issue type: breaking-change
Metadata
Metadata
Assignees
Labels
🏁 Release: .NET 6Issues and PRs for the .NET 6 releaseIssues and PRs for the .NET 6 releasebreaking-changeIndicates a .NET Core breaking changeIndicates a .NET Core breaking change