-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Fix "Replace with method" refactoring for partial properties #81069
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
Conversation
…ctoring Co-authored-by: CyrusNajmabadi <4564579+CyrusNajmabadi@users.noreply.github.com>
… parts Co-authored-by: CyrusNajmabadi <4564579+CyrusNajmabadi@users.noreply.github.com>
|
|
||
| // A method or property is partial if it's either a partial definition or has a partial definition part | ||
| var isPartial = (method?.IsPartialDefinition == true || method?.PartialDefinitionPart != null) || | ||
| (property?.IsPartialDefinition == true || property?.PartialDefinitionPart != null); |
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.
@copilot check for events as well. Also, i think you need to check for any of PartialDefinitionPart, PartialImplementationPart or IsPartialDefinition
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.
Done. Added event support and now checking IsPartialDefinition, PartialDefinitionPart, and PartialImplementationPart for all three symbol types (methods, properties, and events). See commit f266974.
…ection Co-authored-by: CyrusNajmabadi <4564579+CyrusNajmabadi@users.noreply.github.com>
…-class-implementation
…-class-implementation
|
Superceded by #81067 |
Fix: "Replace with method" refactoring for partial properties
Problem
When using "Replace property with method" refactoring on a partial property:
Solution
This PR fixes the issue by:
DeclarationModifiers.Fromto correctly detect partial methods, properties, and eventsChanges Made
1. DeclarationModifiers.From (
src/Workspaces/Core/Portable/Editing/DeclarationModifiers.cs)IsPartialDefinition,PartialDefinitionPart, andPartialImplementationPartpartialmodifier is added to both declaration and implementation methods2. CSharpReplacePropertyWithMethodsService (
src/Features/CSharp/Portable/ReplacePropertyWithMethods/CSharpReplacePropertyWithMethodsService.cs)GetGetMethodWorkerwhengetMethod.IsPartialDefinitionis trueGetSetMethodWorkerwhensetMethod.IsPartialDefinitionis true3. Test Coverage (
src/Features/CSharpTest/ReplacePropertyWithMethods/ReplacePropertyWithMethodsTests.cs)TestPartialPropertyWithImplementation- Verifies getter-only partial property transformationTestPartialPropertyWithBody- Verifies partial property with getter and setter transformationExample Transformation
Before:
After (Expected):
Testing
Fixes #81068
Original prompt
partialmodifier #81068💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.