Skip to content

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

Closed

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

Activity

  1. added
    ⌚ Not Triaged
    breaking-change
    on Feb 14, 2020
  2. added
    🏁 Release: .NET 5
    and removed
    ⌚ Not Triaged
    on Apr 17, 2020
  3. self-assigned this
    on Apr 17, 2020
  4. RussKie commented on Oct 21, 2020

    @RussKie
    ContributorAuthor

    I'll have new ones opened for 6.0 😉
    Thank you for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

🏁 Release: .NET 5breaking-changewinforms/subsvc

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions