-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Edit & Continue support for field access in auto-properties #78289
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
base: main
Are you sure you want to change the base?
Edit & Continue support for field access in auto-properties #78289
Conversation
VB Note: EditingTestBase.vb already specifies LanguageVersion.Latest when parsing.
This is needed to support EnC for auto-props using the field keyword.
"Update [=> 1]@16 -> [=> field]@16"); | ||
|
||
edits.VerifySemantics( | ||
[SemanticEdit(SemanticEditKind.Update, c => c.GetMember<IPropertySymbol>("C.P").GetMethod)], |
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.
I can't remember, should this also have a field add in the list of edits? Or is that bit automatic for properties?
Perhaps a test in https://github.com/dotnet/roslyn/blob/main/src/Compilers/CSharp/Test/Emit2/Emit/EditAndContinue/EditAndContinueTests.cs would be a good idea, to make sure the right metadata is emitted.
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.
Should this also have a field add in the list of edits?
I don't believe so. At least, I don't see an insert for the backing field in other auto-property tests. The insert of the field is implicitly tested by verifying the diagnostics below when the AddInstanceFieldToExistingType capability isn't specified. I'll take a look at adding a test or two on the compiler side as well.
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 insert of the field is implicitly tested by verifying the diagnostics below when the AddInstanceFieldToExistingType capability isn't specified.
I missed this, that's a very good point.
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.
Added compiler layer tests
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.
We don't need the field insert. We just need to tell the compiler to emit the property and it will emit all symbols it needs to do so.
validator: g => | ||
{ | ||
g.VerifyTypeDefNames("HotReloadException"); | ||
g.VerifyFieldDefNames("Code"); |
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.
Hmm, where is "Code" coming from?
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.
It's from HotReloadException.Code
.
Fixes #77951
Field access in auto-properties mostly already worked in EnC.
AbstractEditAndContinueAnalyzer
to allow auto-properties to be detected from a set accessor.cc @tmat