Skip to content

[WinForms] API validate input parameters and throw AE #17096

Closed
@RussKie

Description

@RussKie

Selected API validate input parameters and throw ArgumentException.

Selected API now validate input parameters and throw ArgumentException where previous behaviour could lead to indeterminate state, if APIs were invoked with input arguments of unexpected or incorrect type.
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.

Version introduced

.NET 5.0 Preview 1

Old behavior

The listed API would lead to indeterminate state if invoked with input arguments of unexpected or incorrect type.

New behavior

The listed API would throw ArgumentException if invoked with input arguments of unexpected or incorrect type.

Reason for change

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

Recommended action

  • Review and, if necessary, update the code to prevent passing input arguments of incorrect type to the listed API.
  • Handle ArgumentException, if necessary.

Category

  • Windows Forms

Version introduced: .NET 5.0 Preview 1

Affected APIs

Version introduced: .NET 5.0 Preview 5

Affected APIs

  • DataFormats
    • GetFormat(String), parameter format - throws AE, if format is null, string.Empty or whitespace (e.g. string.IsNullOrWhispace(format)).
      NB: Win32Exception remains to be thrown, if registration failed

Version introduced: .NET 5.0 Preview 7

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