Edit

Share via


Changes to nullability annotations (Windows Forms)

In .NET 9, some nullability annotations on the Windows Forms APIs have changed.

Previous behavior

Previously, some parameters were marked as nullable.

New behavior

Starting in .NET 9, these parameters are marked as non-nullable. If you pass an argument that might be null, you'll get a compiler warning.

Version introduced

.NET 9 Preview 1

Type of breaking change

This change can affect source compatibility.

Reason for change

The parameter on IWindowsFormsEditorService.DropDownControl(Control) was previously marked as nullable, but there's no guidance for implementers on how they should handle null input. Also, logically this method should not accept null.

Affected APIs

The following table lists the affected APIs:

API What changed Recommended action
IWindowsFormsEditorService.DropDownControl(Control) The control parameter is non-nullable Make sure you're not passing a nullable Control to this method. Also, update any implementations of IWindowsFormsEditorService to remove nullability of the DropDownControl method's parameter.