-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Support parameterized argument completers #12708
Copy link
Copy link
Closed
Labels
Committee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionIssue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifIssue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.The issue is fixed.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime
Metadata
Metadata
Assignees
Labels
Committee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionIssue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifIssue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.The issue is fixed.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime
Add support for ArgumentCompletionAttributes with parameters
ArgumentCompleters are in the current implementation created by type, using a default constructor.
This makes it very hard to provide parameters to the completed, limiting their usefulness.
I propose that we add "Factory" support to the completion system, so that an attribute derived from
ArgumentCompleterFactoryAttributegets called on a method with a signature likeThis would allow the derived attribute to use attribute parameters to create the actual argument completer.
Deriving from ArgumentCompleterFactoryAttribute makes it possible to create generic completers, like
An sample usage could look like this:
Proposed technical implementation details (optional)
There are a couble of ways to go about this:
ArgumentCompleterFactoryAttributewith an abstractCreatemethod.IArgumentCompleterFactoryThat the attributes implement if they want the factory support.ArgumentCompleterFactoryAttributeimplementIArgumentCompleterFactoryPull request for implementation can be found here: #12605