Support renaming anonymous type members - #80701
Merged
Merged
Conversation
Co-authored-by: CyrusNajmabadi <4564579+CyrusNajmabadi@users.noreply.github.com>
Co-authored-by: CyrusNajmabadi <4564579+CyrusNajmabadi@users.noreply.github.com>
Co-authored-by: CyrusNajmabadi <4564579+CyrusNajmabadi@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix renaming support for anonymous type members
Support renaming anonymous type members
Oct 14, 2025
CyrusNajmabadi
approved these changes
Oct 14, 2025
CyrusNajmabadi
marked this pull request as ready for review
October 14, 2025 13:05
JoeRobich
approved these changes
Oct 14, 2025
CyrusNajmabadi
enabled auto-merge (rebase)
October 14, 2025 13:14
CyrusNajmabadi
force-pushed
the
copilot/support-anonymous-type-members
branch
from
October 14, 2025 15:31
699f1db to
f3ceb52
Compare
Member
|
@CyrusNajmabadi @JoeRobich I was just about to block this PR. It's missing any tests for the cases where anonymous type members have names that are inferred from the use, where renaming it will involve updating the syntax with an explicit rename. I'll see if Copilot can fix this up, otherwise we'll need to revert this. |
6 tasks
Contributor
|
@jasonmalinowski i don't know why we'd need to revert this. even if that case doesn't work, we can still make cases like this work fine. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #883
This PR enables renaming of anonymous type members, which was previously blocked with a "not supported" error dialog.
Problem
Renaming anonymous type members was artificially restricted, even though the underlying infrastructure (Find References) already correctly finds all references to these members. For example:
Both inline rename and rename tracking would show an error message instead of allowing the rename operation.
Solution
Removed the blocking check in
SymbolicRenameInfo.csthat prevented renaming properties whensymbol.ContainingType.IsAnonymousTypewas true. Since Find References already correctly identifies all references to anonymous type members, no additional infrastructure changes were needed.Testing
Added comprehensive tests covering:
x.Prop)argsparameter becomes a member namedargs)IEditorInlineRenameService.GetRenameInfoAsyncreturnsCanRename = truefor anonymous type membersAll tests follow existing patterns in
RenameEngineTests.vbandCSharpInlineRenameServiceTests.cs.Cleanup
Removed the now-obsolete error message resource "Renaming_anonymous_type_members_is_not_yet_supported" from
FeaturesResources.resxand all localization files.Original prompt
Fixes #18425
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.