-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Refactor Tooltip/ListItemText mapping to use CompletionDisplayInfoMapper
delegate
#25395
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
Refactor Tooltip/ListItemText mapping to use CompletionDisplayInfoMapper
delegate
#25395
Conversation
src/Microsoft.PowerShell.Commands.Management/commands/management/NewPropertyCommand.cs
Outdated
Show resolved
Hide resolved
…nt/NewPropertyCommand.cs
src/Microsoft.PowerShell.Commands.Utility/commands/utility/Join-String.cs
Outdated
Show resolved
Hide resolved
9074808
to
96170ce
Compare
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.
Pull Request Overview
This PR refactors the mapping of tooltip and list item text for completion results by replacing separate mapping delegates with a single delegate returning a CompletionDisplayInfo instance.
- Replaced toolTipMapping and listItemTextMapping with a unified CompletionDisplayInfoMapper delegate.
- Introduced the CompletionDisplayInfo class and its default mapper in CompletionHelpers.cs.
- Updated separator and registry property type mappings in Join-String.cs and NewPropertyCommand.cs to use the new delegate.
Reviewed Changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.
File | Description |
---|---|
CompletionHelpers.cs | Replaced two mapping delegates with CompletionDisplayInfoMapper and added helper types. |
Join-String.cs | Updated separator mapping to use the new delegate-based approach. |
NewPropertyCommand.cs | Updated registry property type mappings to use CompletionDisplayInfoMapper. |
Files not reviewed (1)
- test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1: Language not supported
Comments suppressed due to low confidence (2)
src/Microsoft.PowerShell.Commands.Management/commands/management/NewPropertyCommand.cs:233
- Consider adding tests that cover each registry property type mapping provided by RegistryPropertyTypeDisplayInfoMapper to ensure all mapping cases are correctly handled.
displayInfoMapper: RegistryPropertyTypeDisplayInfoMapper,
src/Microsoft.PowerShell.Commands.Utility/commands/utility/Join-String.cs:175
- [nitpick] Ensure that the SeparatorDisplayInfoMapper switch expression and the s_separatorValues list remain consistent; adding a brief comment may help future maintainers keep both updated simultaneously when new separators are introduced.
private static readonly CompletionHelpers.CompletionDisplayInfoMapper SeparatorDisplayInfoMapper = separator => separator switch
src/System.Management.Automation/engine/CommandCompletion/CompletionHelpers.cs
Outdated
Show resolved
Hide resolved
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
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.
LGTM with one style comment.
src/System.Management.Automation/engine/CommandCompletion/CompletionHelpers.cs
Outdated
Show resolved
Hide resolved
…letionHelpers.cs Co-authored-by: Ilya <darpa@yandex.ru>
Thanks @iSazonov. I have resolved style comment and also fixed some Codefactor issues. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
📣 Hey @@ArmaanMcleod, how did we do? We would love to hear your feedback with the link below! 🗣️ 🔗 https://aka.ms/PSRepoFeedback |
PR Summary
Replaced
Func<string, string> toolTipMapping
andFunc<string, string> listItemTextMapping
withCompletionDisplayInfoMapper
delegate.This is to allow any delegate to be passed into
GetMatchingResults
and reduces mapping parameters. TheToolTip
andListItemText
is wrapped in a tuple.I realised as well there is a lack of tests for
ToolTip
andListItemText
so added those as well.PR Context
PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright header