C# 14: Support the field keyword.
#21309
Draft
+414
−2
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.
In this PR we make support for the C# 14
fieldkeyword in properties. Using the keywordfieldin property accessors implicitly make a synthetic backing field.That is, you can declare
Some notes on the implementation.
PropertyFieldobjects are hashed on the (field,property) pair and not only on the field itself. The symbol visitor is being applied to all backing fields, which means thatFieldobjects are created for backing fields as well - however, the DB is not populated based on these as they are implicitly declared.fieldkeyword. That is, we only extract the backing field, if we are encountering an expression withFieldExpressionkind.