Skip to content

[WinForms] API validate input parameters and throw ANE #17085

@RussKie

Description

@RussKie

Selected API validate input parameters and throw ArgumentNullException.

Selected API now validate input parameters and throw ArgumentNullException where previously a NullReferenceException could be thrown, if APIs were invoked with null input arguments.
Throwing ArgumentException is inline with the behaviours in .NET Runtime, and provides developers with a better debug experience clearly communicating which argument caused the exception.

Old behavior

The listed API would throw NullReferenceException if invoked with null input arguments.

New behavior

The listed API would throw ArgumentNullException if invoked with null input arguments.

Reason for change

Throwing ArgumentNullException is inline with the behaviours in .NET Runtime, and provides developers with a better debug experience clearly communicating which argument caused the exception.

Recommended action

  • Review and, if necessary, update the code to prevent passing null input arguments in the listed API.
  • If the code is handling NullReferenceException replace (or supplement) it with handling ArgumentNullException.

Category

  • Windows Forms

Version introduced: .NET 5.0 Preview 1

Affected APIs

Version introduced: .NET 5.0 Preview 2

Affected APIs

Version introduced: .NET 5.0 Preview 5

Affected APIs

Version introduced: .NET 5.0 Preview 6

Affected APIs

Version introduced: .NET 5.0 Preview 7

Affected APIs

Version introduced: .NET 5.0 Preview 8

Affected APIs

Version introduced: .NET 5.0 RC1

Affected APIs


Issue metadata

  • Issue type: breaking-change

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions