-
Notifications
You must be signed in to change notification settings - Fork 232
Null annotate FirstAncestorOrSelf #8383
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
Null annotate FirstAncestorOrSelf #8383
Conversation
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
| var csharp = owner.FirstAncestorOrSelf<CSharpCodeBlockSyntax>(); | ||
|
|
||
| return element.Body.Any(c => c is CSharpCodeBlockSyntax) || csharp is not null; | ||
| return element?.Body.Any(c => c is CSharpCodeBlockSyntax) ?? false || csharp is not null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💭 Is the ?? false necessary?
| return element?.Body.Any(c => c is CSharpCodeBlockSyntax) ?? false || csharp is not null; | |
| return element?.Body.Any(c => c is CSharpCodeBlockSyntax) ?? (csharp is not null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I find that confusing, and would have to spend a few minutes trying to understand the logic.
| var element = owner.FirstAncestorOrSelf<MarkupElementSyntax>(); | ||
| if (element is null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| var element = owner.FirstAncestorOrSelf<MarkupElementSyntax>(); | |
| if (element is null) | |
| if (owner.FirstAncestorOrSelf<MarkupElementSyntax>() is not { } element) |
|
Whoops! Sorry, hit merge from my phone without thinking about compiler reviews. @333fred let me know if you want me to revert, though its pretty minor. There are callers of the method in the compiler, but none of the callers are annotated anyway. |
Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1758057
Also should fix these faults:
https://prism.vsdata.io/failure/?query=fe%3Arazor%2Ffault&eventType=fault&failureType=hits&failureHash=9cfb44d6-ba55-60ab-9c03-17719a6d8c93
https://prism.vsdata.io/failure/?query=fe%3Arazor%2Ffault&eventType=fault&failureType=hits&failureHash=8ac6d32c-f098-a26d-a312-0abff8ff630c
https://prism.vsdata.io/failure/?query=fe%3Arazor%2Ffault&eventType=fault&failureType=hits&failureHash=53fd5f93-6e27-d7e7-85f7-b598754ccb70
https://prism.vsdata.io/failure/?query=fe%3Arazor%2Ffault&eventType=fault&failureType=hits&failureHash=eae8ed55-d35c-e440-a6d5-cd7094f88ab6