-
Notifications
You must be signed in to change notification settings - Fork 179
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
Expose nullability annotations (and enable nullability warnings internally in production code) #1613
Comments
I thought I'd start out by submitting a few PRs that clean up some our internal code. Nothing that requires a language or framework change at this point, but that would reduce the pain we have in the future. |
What exactly do you have in mind for nullable ref types? |
I wasn't anticipating a question of this type! Now I fear I do not understand the feature. I guess technically I'm more interested in non-nullable reference types. I'd hoped to enable the nullable annotation context as well as the nullable warning context. Clients would know which arguments must not be null (and which return values won't be) and we would know the same about our own methods. Do you think this is a bad idea? Not worthwhile? |
Not at all. I was just wondering if you just wanted to enable it for internal use, or actually expose the nullability annotations to package consumers (both are useful, of course). |
Both, yes. Anyway, I don't think we could do the first without the second (for public types) |
I think I've gone about as far as I can without taking advantage of the new language features. Or at least without a discussion. Next steps, as I see them, not necessarily in this order:
Addressing warnings will be interesting. As I type, there are about 90 warnings, although #1680 will take care of about 20 of those. There are at least 4 major classes of remaining warnings:
I haven't looked closely at the analyzer warnings. Most of them come from our calls to external methods that might return My overall feelings are that the more "private" a usage is, the more likely I am to be happy with a At some point, we may find that we want to introduce a standalone Maybe or Either. If so, we'll have to consider whether we want to roll our own or take a package dependency, but I think we can hold off on that. I may just be buying trouble. |
For internal methods, yes. For public methods, we have to keep them. And we can probably decorate
Oh? Examples?
Yes,
👍
I like the idea of an either-style type. Something like
Yeah, it's a mess...
Did you check again after the upgrade to .NET Standard 2.0? I updated to the latest Roslyn packages, they might have nullability annotations.
Sounds good to me. Nullables aren't that bad, since the compiler will force us to check them before use.
Even though I wrote my own Option type, I think we should avoid taking a dependency for this. It's easy to roll our own, and we can tailor it to our needs. |
Of course
Maybe I spoke too soon. But it's something to keep our eyes out for!
I don't understand that usage. But let's worry about it when we get to it
I've been building the world (all TFMs) and accumulating unique warnings, like this: .\build.cmd build |
Select-String -CaseSensitive \bwarning\b |
Sort-Object -Unique |
Out-File -Encoding utf8 -Width 1000 ../nullwarnings/HEAD
copy ..\nullwarnings\HEAD "../nullwarnings/$(git branch --show-current)"
copy ..\nullwarnings\HEAD "../nullwarnings/$(git rev-parse HEAD)" I didn't notice a drop in the number of warnings. But maybe I wasn't paying attention. There are only about 17 in there now. |
This change has been released as part of FakeItEasy 6.0.0-beta.1. |
We'll need to support .NET Core 3.0 and C# 8.0.
I fear there may be challenges with the
PublicApiGenerator
. At least there were a few months ago when I started looking at this and eventually dropped it.The text was updated successfully, but these errors were encountered: