-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Fix "Introduce local" generating invalid code for function pointer types #80983
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
|
@copilot check normal pointers as well. |
Co-authored-by: CyrusNajmabadi <[email protected]>
Co-authored-by: CyrusNajmabadi <[email protected]>
src/Features/CSharpTest/IntroduceVariable/IntroduceVariableTests.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: CyrusNajmabadi <[email protected]>
| case IPointerTypeSymbol pointerType: | ||
| type = pointerType.PointedAtType; | ||
| continue; | ||
| case IPointerTypeSymbol: |
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 undo the change to pointers. If the user has Customer* we want to still make that as if it was just Customer. Add tests for this as well and add a 'why, not what's comment for this in the 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.
Done in b81b069. Restored pointer unwrapping so Customer* generates "customer". Added "why" comments explaining that normal pointers unwrap to get meaningful names while function pointers use the default. Updated test to use Customer* → customer.
Co-authored-by: CyrusNajmabadi <[email protected]>
…ce-local-code-gen
Fixes the "Introduce local" refactoring generating invalid code for function pointer types by using the type's display string as the variable name (e.g.,
delegate*<void> delegate*<void> = field;).Changes
ITypeSymbolExtensions.CreateParameterName: Added case forIFunctionPointerTypeSymbolto return default parameter name "value" instead of type display stringCustomer*continue to unwrap to the pointed-at type to generate meaningful names (e.g.,Customer*→customer)TestFunctionPointerTypeandTestPointerTypecovering both function pointers and custom pointer typesExample
Before:
After:
Fixes #80982
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.