-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Use is null syntax
#13277
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
Use is null syntax
#13277
Conversation
|
@iSazonov Can you review? |
|
@xtqqczze The PR contains very many files. Please re-pack to 20-30-40 commits by 20-30 files. This will very seed up the code review. Thanks! |
|
@iSazonov Could you use the Reviewable link instead? |
|
@xtqqczze Please resolve merge conflicts |
|
@daxian-dbw Could you please help to resolve the merge conflict? |
|
@iSazonov I will resolve conflicts now |
|
@iSazonov Merge conflicts are resolved. |
|
@xtqqczze Please rebase to pass CIs |
|
Since there is high risk to catch merge conflicts I will merge. |
|
This one too. I don't understand why we do this. I think we should revert this PR as soon as possible. /cc @TravisEz13 @adityapatwardhan @anmenaga @rjmholt |
|
@iSazonov and @xtqqczze First, I want to thank both of you for continuously driving the code clean-up efforts and it's really appreciated! As for this PR, the rest of maintainers discussed about it offline, and we all agree that we shouldn't force To make it work better in future, @TravisEz13 submitted #13321 to add an action to label the size of a PR. Large size PRs would require a vote of the maintainers to accept. Also, @iSazonov it would be great if you can join our maintainer meetings, which happens every two weeks. @adityapatwardhan will chat with you about it and decide the time that works for all of us. |
Different? It is clearly documented for constants. After Mads Torgersen announced this on .Net Conf 2019 it has become a favorite feature for many developers. I'd expect they will be amazed if we do not modernized PowerShell code.
We already have great experience in the area. We had many such PRs. After we fixed most of CodeFactor issues and all code base is in the same style we no longer have style discussions with contributors (and no new CodeFactor issues) - (1) they follow code style, (2) they follow standard and expected style rules, (3) they see CodeFactor warnings. I understand that MSFT team follows the traditional conservatism that is well characteristic of closed source projects, but open source projects work differently, which has already been clearly demonstrated many times in this project - they require polishing and modernizing OSS code. |
|
I'm still for keeping this PR personally. Yes, it's resulted in merge conflicts that I've fixed (twice now, guess I should have been slower on the uptake hehe) but the merge conflicts it tends to create are relatively small and simple to resolve, so I don't see it as being a big deal. However, if we're concerned about merge conflicts, it's the order of merging PRs that matters, so we'd be better off focusing on improvements to the triage process than the exact nature of a given PR and how that affects it being accepted or not. |
Tbh it's really not that clear that when you're doing a simple null check you need to worry about a type having a wonky
I don't really disagree here, but keep in mind that readability is subjective. Less definitive language would probably be advisable.
Yeah I agree with that. |
|
Only after C# 8.0 the different scenarios is possible. And I am very curious why anyone could implement such an unusual |
I've absolutely seen |
|
This is exactly the reason why this PR should be adopted as quickly as possible. (re-reverted :-) ) |
|
This is exactly the discussion that I tried to avoid getting into 😄
I don't think it's the same for this case. A contributor shouldn't be forced to choose the pattern matching over the conventional As for the |
~25% files. They usually force after creating a Roslyn analyzer. |
|
@daxian-dbw I'd be surprised that PowerShell is expected to find bugs in someone else's utilization of an Surely it's preferable to use the more robust implementation that avoids treading on the proverbial broken glass here? 😕 |
|
How do you know for sure that's a bug then? The type could be purposefully considered as a null, something like the |
|
It depends on the purpose, perhaps, but in general just because the author of a type decided that their type is equivalent to null doesn't mean that for all cases in the internals of another library / PowerShell it should be considered equivalent. Additionally, while I don't really know a great way to phrase this (but I do think it needs to be raised nonetheless), I don't think the argument of "we've always done it this way" holds literally any water, frankly. If we wait for a bug to show up even when there's a clear way to avoid it ever becoming a concern, I think that's cause for concern. Reactive solutions are often rushed; proactive solutions give us the opportunity to consider more robust solutions and avoid problems in the first place, fix coding practices and set in stone less error-prone practices. Are there places you might want to use Just because a tool is new and it would be some amount of work to move to it doesn't mean it's not worth using. Additional food for thought:
|
I'd say it is always bug if we see comparison with All nullability support in Roslyn follow this too. I understand if somebody has some branches in backlog and have to rebase and resolve merge conflicts occasionally it is annoying. Also I understand MSFT team has to spend a time on minor commit reviews. |
|
What I tried to say is that your argument goes both way. With the current use of If a custom type doesn't handle |
If I understand correctly a root of your concern is that PowerShell may call third-party |
|
My comment is completely based on the behavior difference between All I want to say is that I don't think the Let's be aware of the subtle differences between those 2 syntax, and choose what to use based on the problem you are solving, instead of just preferring one over another universally. |
|
Sure, absolutely. But I think the vast majority of the cases where we currently use |
The best case scenario for that is less efficient code gen (even if inlined probably). I have a really hard time thinking of a situation where it would be genuinely useful to return Is there a big risk of a bad |
|
@iSazonov @daxian-dbw Too many merge conflicts to re-revert this PR now. I think this should be revisited once dotnet/runtime has made started widespread '== null' -> 'is null' changes. |
It already was reverted.
I'd expect they will do this after fork to .Net 6.0. |
These changes are now being made: dotnet/runtime#42692 |
PR Summary
-replace '== null', 'is null'PR Context
#13090 (comment)
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.This change is