-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Support null-conditional operator when the return value is a pointer type (including function pointers) #80694
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
Merged
CyrusNajmabadi
merged 25 commits into
main
from
copilot/support-null-conditional-operator
Dec 23, 2025
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
9bbba4a
Initial plan
Copilot 7384206
Add temporary tests to understand current pointer null-conditional be…
Copilot 807300e
Support null-conditional operator with pointer return types
Copilot 5de452e
Add WorkItem attributes to pointer null-conditional tests
Copilot b5ddcc3
Update tests
CyrusNajmabadi f011de2
Merge branch 'copilot/support-null-conditional-operator' of https://g…
CyrusNajmabadi 3db83b3
Merge remote-tracking branch 'upstream/main' into copilot/support-nul…
CyrusNajmabadi 74dd89c
Allow function pointers in null-conditional expressions
Copilot 3561f0a
Revert
CyrusNajmabadi d84e4de
Update comment to clarify pointer type treatment
Copilot 43fa887
Apply suggestion from @CyrusNajmabadi
CyrusNajmabadi 147919d
Merge remote-tracking branch 'upstream/main' into copilot/support-nul…
CyrusNajmabadi 6f2ce9a
Update existing tests
CyrusNajmabadi 7f3fbef
Add enhanced tests for pointer null-conditional operator
Copilot be4b981
Add conditional assignment tests for pointers and function pointers
Copilot 1807832
Remove validation
CyrusNajmabadi 3bf9f0c
Adjust test
CyrusNajmabadi fc1a2df
Update tests
CyrusNajmabadi 55c2b8c
MOve 'unsafe' modifier to members from types
CyrusNajmabadi acb516a
UPdate test
CyrusNajmabadi 5b81c4e
Merge remote-tracking branch 'upstream/main' into copilot/support-nul…
CyrusNajmabadi 5112bd6
Update tests
CyrusNajmabadi e408a35
remove test
CyrusNajmabadi 4422eb1
Add some tests
CyrusNajmabadi 8dd65d8
Add test for Nullable<T> receiver with method call
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
@dotnet/roslyn-compiler i think this is correct. The spec says this: https://github.com/dotnet/csharpstandard/blob/standard-v6/standard/expressions.md#1177-null-conditional-member-access
So my reading from teh spec is that this should be legal. #Resolved
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.
https://github.com/dotnet/csharpstandard/blob/draft-v8/standard/expressions.md#1288-null-conditional-member-access has revised the wording somewhat but I think Cyrus's interpretation still holds.
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.
The latest docs show this: