-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Fix managed/unmanaged keyword completion after typing in function pointer contexts #81017
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
…after delegate* Co-authored-by: CyrusNajmabadi <[email protected]>
| delegate*$$ | ||
| """); | ||
|
|
||
| [Fact] |
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 use [Fact, WorkItem("...")]. Also, test the specific case i n the original bug, where the function pointer type was being written inside a cast.
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 a9e5e87. Added WorkItem attribute and test for the cast expression case from the original bug report.
| return targetToken.IsKind(SyntaxKind.AsteriskToken) && | ||
| targetToken.Parent is FunctionPointerTypeSyntax functionPointerType && | ||
| targetToken == functionPointerType.AsteriskToken; | ||
| // Check if we're at or after delegate* |
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 you just need to check that the target token is an asterix, and the .GetPreviousToken() from it is the delegate keyword. That's 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.
Done in a9e5e87. Simplified to just check that targetToken is an asterisk and the previous token is the delegate keyword.
…ests Co-authored-by: CyrusNajmabadi <[email protected]>
src/EditorFeatures/CSharpTest2/Recommendations/ManagedKeywordRecommenderTests.cs
Outdated
Show resolved
Hide resolved
src/EditorFeatures/CSharpTest2/Recommendations/ManagedKeywordRecommenderTests.cs
Outdated
Show resolved
Hide resolved
src/EditorFeatures/CSharpTest2/Recommendations/UnmanagedKeywordRecommenderTests.cs
Outdated
Show resolved
Hide resolved
…dRecommenderTests.cs
Fix "managed" and "unmanaged" keywords not appearing after typing in function pointer expressions
Problem
The
managedandunmanagedkeywords were not offered in IntelliSense completion after the user started typing followingdelegate*in function pointer declarations. The keywords only appeared when the completion list was opened immediately after typingdelegate*.Example:
Root Cause
The
IsFunctionPointerCallingConventionContextmethod only checked if thetargetTokenwas the asterisk token with complex parent type checks, which failed when the user started typing afterdelegate*.Solution
Simplified
IsFunctionPointerCallingConventionContextto just check:This ensures that keywords appear both:
delegate*→ keywords appear ✓delegate*manag→ keywords appear ✓(delegate*manag)&M→ keywords appear ✓Changes
IsFunctionPointerCallingConventionContextimplementationWorkItemattributes to testsOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.