-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Support changing return types of methods, properties, events #63486
Conversation
a5287fd
to
cb3c277
Compare
0777608
to
7aee05a
Compare
src/EditorFeatures/Test/EditAndContinue/EditAndContinueWorkspaceServiceTests.cs
Show resolved
Hide resolved
src/Features/Core/Portable/EditAndContinue/AbstractEditAndContinueAnalyzer.cs
Outdated
Show resolved
Hide resolved
So this got a lot bigger. Sorry! The TL;DR is that whilst just pretending properties and events were the same as methods for deletes, for changes that didn't hold up, and we have to properly track them as deleted members, and issue inserts for the actual property/event not just the accessors. |
src/Compilers/Core/Portable/Emit/EditAndContinue/DeletedEventDefinition.cs
Outdated
Show resolved
Hide resolved
src/Compilers/Core/Portable/Emit/EditAndContinue/DeletedEventDefinition.cs
Outdated
Show resolved
Hide resolved
src/Compilers/Core/Portable/Emit/EditAndContinue/DeltaMetadataWriter.cs
Outdated
Show resolved
Hide resolved
// If this is a field that is being added, but it's part of a property or event that has been deleted | ||
// and is now being re-added, we don't want to add the field twice, so we ignore the change. | ||
// Unlike properties and methods, since we can't replace a field with a MissingMethodException | ||
// we don't need to update it at all. |
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'll want to update the field's name to "_Deleted" at some point (see dotnet/runtime#75154)
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 support deleting fields at all yet, so the comment could definitely have a "for now" modifier.
I did see that issue though, and it's not clear to me whether we would want our deleted symbols here to have the name "_Deleted" or if we'd just write the name to the metadata table as "_Deleted", to ensure that we can still find the symbols in order to "undelete" them later.. or if thats just an implementation detail of Roslyn.. or if indeed that matters at all 🤷♂️
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 think that's impl detail. If we remember the token of the deleted member and can update it back to a new name when re-added/renamed back it doesn't matter much if the symbol has the _Deleted name or the metadata writer special cases deleted members.
src/Compilers/Core/Portable/Emit/EditAndContinue/DeltaMetadataWriter.cs
Outdated
Show resolved
Hide resolved
Reviewed (commit 16) |
foreach (var eventDef in typeDef.GetEvents(this.Context)) | ||
{ | ||
if (!_eventMap.Contains(typeRowId)) | ||
{ | ||
_eventMap.Add(typeRowId); | ||
} | ||
|
||
this.AddDefIfNecessary(_eventDefs, eventDef); | ||
var eventChange = _changes.GetChange(eventDef); | ||
eventChange = _changes.FixSymbolChangeForReAddedMembers(eventDef, eventChange, DefinitionExistsInAnyPreviousGeneration); |
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.
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.
Yeah, that should work. I originally tried to put all the logic in GetChange
itself, so everything just worked magically, but that broke too many other things
foreach (var eventDef in typeDef.GetEvents(this.Context)) | ||
{ | ||
if (!_eventMap.Contains(typeRowId)) | ||
{ | ||
_eventMap.Add(typeRowId); | ||
} | ||
|
||
this.AddDefIfNecessary(_eventDefs, eventDef); | ||
var eventChange = _changes.GetChange(eventDef); | ||
eventChange = _changes.FixSymbolChangeForReAddedMembers(eventDef, eventChange, DefinitionExistsInAnyPreviousGeneration); |
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.
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.
IMO that would make things messy. The problem is that FixSymbolChangeForReAddedMembers
is a little bit recursive so we'd have to bring some of that logic out to here. Personally I like that its all in that one method.
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 see, did not noticed that.
Reviewed (commit 17) |
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 compiler changes LGTM, with a few minor comments.
Thanks @cston will get out a follow up today, just to close the loop |
No description provided.