Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The public API is still missing nullable reference type annotations #1418

Open
stakx opened this issue Sep 4, 2023 · 1 comment
Open

The public API is still missing nullable reference type annotations #1418

stakx opened this issue Sep 4, 2023 · 1 comment

Comments

@stakx
Copy link
Contributor

stakx commented Sep 4, 2023

They should perhaps be added. Ideally not just for the public API surface, but for the whole code base. This could then replace quite a few Debug.Assertions that guard against null references internally.

(This might potentially be a good first issue for new contributors. I expect that there will be some code locations where it isn't immediately clear whether null is allowed or not, and where one would have to study the code & execution paths through it for a bit... but even that shouldn't be too tough.)

@rikrak
Copy link

rikrak commented Sep 6, 2023

I had a quick look at this last night and noticed that adding nullable markings started to cause a few false-positive warnings. This looks to be due to targeting of net462 and netstandard20, which are missing some of the nicer nullable compiler enhancements.

I could work around this by adding augmenting the Guard class so that is decorated with attributes that help the compiler understand what's going on (Example here, which uses polyfill attributes.

Is this the sort of direction that feels appropriate? One thing to note is that it results in a change in behaviour as there is potential for exceptions where previously there was not (although, if the nullability is interpreted correctly, all should be good).

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

No branches or pull requests

2 participants