Replies: 8 comments 19 replies
-
😿 A tremendous shame. |
Beta Was this translation helpful? Give feedback.
-
The general concept of parameter null checking is great but the syntax although short always felt to me out of place so I think you made the right decision. personally I prefer something like contracts. |
Beta Was this translation helpful? Give feedback.
-
This is As for contracts, they are an incredibly heavy solution, one mired in tons of policy. The flow analysis would be many, many orders of magnitude more complicated (and expensive) than NRTs. Contracts were one of the first proposals on CodePlex, and I have severe doubts that they'll go anywhere. |
Beta Was this translation helpful? Give feedback.
-
I'd prefer doing null check in the direction of NRT, e.g.: [GenerateNullCheck]
void M1(string a, string? b, string c)
{
// generate null checks for a & c
}
void M(string a, string? b, [GenerateNullCheck] string c)
{
// generate null checks for c only
} |
Beta Was this translation helpful? Give feedback.
-
The importance of parameter null checking actually depends on the code style. In BCL is mandatory so I can see the reason of eager adoption. In other projects people may be simply not checking nulls. |
Beta Was this translation helpful? Give feedback.
-
Was there a poll of some sort? I believe such things work if you can make silent majority express their voice. I don't see how this feature breaks something in the future. Even if roles (for example a role ensuring value is not null) or active patterns (apply active pattern checking for null on a parameter) get done they still feel like an overkill for a null check. Especially if I just need to ... check for null. With nrt days of all over the place nullchecks are gone and this feature could help with all the remaining noise. Nor attributes nor super special keywords help with that because they still litter your code just for a null check. I'm disappointed and I'm waiting for a poll. |
Beta Was this translation helpful? Give feedback.
-
Just a small note nothing stops you from doing features piece by piece just like all current pattern matching works (eg list patterns didnt land with 1.0v of pattern match features) as long as it useable and extensible |
Beta Was this translation helpful? Give feedback.
-
For the record, despite my reservations about void Foo(string s is not null) {} // or even
void Foo(string s not null) {} I know this is more verbose, and I would have preferred |
Beta Was this translation helpful? Give feedback.
-
https://github.com/dotnet/csharplang/blob/main/meetings/2022/LDM-2022-04-13.md
Agenda
Beta Was this translation helpful? Give feedback.
All reactions