Winforms: Enable nullability across winforms

Created on 7 Jun 2019  路  8Comments  路  Source: dotnet/winforms

Once CoreFx and CoreCLR fully support nullability it would be great to do this in winforms

Probably a large project...

NRT enhancement up-for-grabs

Most helpful comment

I've done this for a few projects to date, and may be able to help here.

All 8 comments

Got a few things on the priority list, but we can consider adding this to the roadmap. @OliaG for Roadmap thoughts.

Implementing NRT to the whole code base would be a massive work, but enabling it only for the API surface would be much easier and yet very helpful for customers who uses both winforms and NRT.

Something we did on project system, CPS and other projects is to add <Nullable>enable</Nullable> to project files, then use a regular expression to add #nullable disable to each and every source file.

This encourages new code to be written using NRT, and provides an annotation to-do list by searching for #nullable disable.

For commonly used types where annotations would be useful, but it's too challenging to fix all generated warnings, it's possible to use #nullable annotations which allows adding ? to types without having to address any warnings.

Thank you @drewnoakes, this may be a way forward.

```c#

nullable annotations

```
@drewnoakes where is this documented? VS syntax highlight it, but the compiler is bothered:

CS8637 Expected 'enable', 'disable', or 'restore'

Edit: Oh, nevermind, got it. It's #nullable enable annotations.

I've done this for a few projects to date, and may be able to help here.

Now that #2702 and #2756 are merged, I encourage everyone interested to send PRs covering small parts of the API for NRT in SWF.

When annotating Windows Forms types verify that the Runtime types are NRT enabled (refer to https://github.com/dotnet/runtime/issues/2339).

Was this page helpful?
0 / 5 - 0 ratings