meetings/2022/LDM-2022-04-13.md
https://github.com/dotnet/csharplang/issues/2145
We're following up to last week's discussion on parameter null checking, deciding on our answers to two questions:
To think about the first question, we put up some syntax ideas. Some of these have been previously discussed, others arose from community discussion on this feature. We also went through and listed some pros and cons for each syntax form.
void M(string s!!); - The current form
void M(string! s);
! can be put on types in other locations, and we don't have any idea on how we'd actually enable
such a feature in the future. It also negatively affects usage in lambdas, as users would be required to add a type to their lambda declarations to use the feature.Type! could be used on a local, which would force a null check whenever something is assigned to that local. There was not much support
this extension after consideration, however.void M(string s!);
! character. However, we're concerned about confusing all the different meanings of !; for example, the !'s in this
example mean different things: x! => x!;.void M(notnull string s);
NotNull attribute.void M(string s ?? throw);
?? throw is already legal expression syntax (provided there's an exception type on the other side). However, we're
concerned with the interaction with default parameters, as string s ?? throw = "" looks very confusing, and string s = "" ?? throw looks like ?? throw is part of
the default parameter value.void M(string s is not null);
void M(checked string s);
checked already deals with exceptions, and it feels like the right word to use: when used with arithmetic, it ensures that users aren't violating the
bounds of a type, which is very similar to parameter null checking. However, checked can already be applied to expressions, or even turned on project-wide, and we're
not sure how we'd apply the null-checking feature in these locations: should all parameters be null-checked if the project-wide setting is on, for example? Or should a
! in a checked block be checked for null?void M(string s) where s is not null;
After the discussion leading to the above points, we felt that only two of the options had enough support to continue discussion: option 1, the current form, and option 3, the less shouty version of the current form.
We then turned our focus to question 2: do we still feel confident in this feature at all? As part of this, we also looked at the initial feedback we received on this feature by a number of channels: GitHub, social media, MVPs, conference audiences, internal reviewers, and the LDT itself. We do see a majority of positive reactions to the feature, but it isn't the large majority we normally like to see for C# features, particularly ones that are as broadly applicable as this feature will be, and even the LDT is split on the feature itself. While we think the preview provided us with valuable feedback and was worth pursuing, we ultimately decided that, between options 1, 3, or pulling the feature from C# 11 entirely, pulling the feature is the right move. We may revisit at a later date, if we ever want to pursue more generalized contracts, but for C# 11 this feature will removed.
Parameter null checking is removed from C# 11.
https://github.com/dotnet/csharplang/issues/5529
https://github.com/dotnet/csharplang/issues/6011
This next change in design of this feature pares it back significantly, basically back to the original design, but with a couple of key differences:
private keyword here, which was a significant stumbling block in understanding of the feature and unintended feature creep.In particular, this version solves the immediate source-generator issues that the BCL is running into, while allowing us design room if we ever want to expand the
feature in the future. We do need to validate that the restrictions around partial types and signatures will solve all the issues the BCL source-generators have, but
we think it's a forward direction we can make progress on.
The updated proposal can move forward, and we should validate the restrictions on partial types will solve the scenarios in the BCL.