question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add a .NET API to add native completers

See original GitHub issue

Summary of the new feature/enhancement

Currently there are ways to register a scriptblock as a completer with Register-ArgumentCompleter, and on cmdlets it’s possible to use the [ArgumentCompleter()] attribute to specify an IArgumentCompleter for a parameter. But there’s no way to specify a completer for an ordinary command that I know of that doesn’t involve executing a scriptblock.

By this I mean, you can use Register-ArgumentCompleter or you can use override TabCompletion2, but I’d really like a nicer hook for:

  • General completions
  • Command completions
  • Native command completions, especially

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:8
  • Comments:14

github_iconTop GitHub Comments

5reactions
SeeminglySciencecommented, Oct 7, 2019

I’d love to see more ways of extending completion! One of the biggest things that’s always stopped me from working on anything to extend general completion is that it’s all or nothing. If you override TabExpansion2, then anyone else trying to do the same will completely override you. I’d love to see something like an interface that can be registered in the engine to incrementally augment completion. Something like:

public interface ICompletionExtension
{
    IEnumerable<CompletionResult> CompleteComment(CompletionContext context);

    IEnumerable<CompletionResult> CompleteMember(CompletionContext context);

    IEnumerable<CompletionResult> CompleteCommandParameter(CompletionContext context);

    IEnumerable<CompletionResult> CompleteCommandArgument(CompletionContext context);

    // Other cherry picked methods from CompletionCompleters/CompletionAnalysis here.
}

public class CompletionEngine
{
    public void RegisterCompletionExtension(ICompletionExtension extension);

    public void UnregisterCompletionExtension(ICompletionExtension extension);

    // Mirroring CommandCompletion.CompleteInput
    public CommandCompletion CompleteInput(
        Ast ast,
        Token[] tokens,
        IScriptPosition positionOfCursor,
        Hashtable options);
}

public partial class EngineIntrinsics
{
    public CompletionEngine Completion { get; }
}
2reactions
iSazonovcommented, Aug 4, 2020

So we could discuss follow signatures:

Register-ArgumentCompleter -Command <string[]>  -CompleterType [Custom type with ICommandCompleter]
Register-ArgumentCompleter -ParameterName <string> [-Command <string[]>]  -CompleterType [Custom type with ICommandCompleter]
public void RegisterArgumentCompleter(string commandName, ICommandCompleter completer);
public void RegisterArgumentCompleter(string[] commandName, ICommandCompleter completer);
public void RegisterArgumentCompleter(IEnumerable<string> commandName, ICommandCompleter completer);

public void RegisterArgumentCompleter(string? commandName, string parameterName, IArgumentCompleter completer);
public void RegisterArgumentCompleter((string? commandName, string parameterName) commandparameterPair, IArgumentCompleter completer);
public void RegisterArgumentCompleter(IEnumerable<string?, string> commandparameterPair, IArgumentCompleter completer);


Read more comments on GitHub >

github_iconTop Results From Across the Web

ASP.NET Core support for native AOT
In this article. Why use native AOT with ASP.NET Core; ASP.NET Core and native AOT compatibility; Native AOT publishing; The Web API ( ......
Read more >
React with .NET Web API – Basic App Tutorial - YouTube
Learn how to create a basic React application that leverages a . NET Web API Component (that we write using C#). In order...
Read more >
Support publishing ASP.NET Core API apps with Native ...
Overview .NET 7 introduced support for publishing .NET console projects as native AOT, producing a self-contained, platform-specific executable without any ...
Read more >
React Native with Asp.net Core Web Api
I have a website written in React JS and want to add apps using React Native. All the services are working and in...
Read more >
Building an ASP.NET Web API with ASP.NET Core
In this article, I'll be covering: How to create a REST API from scratch using .NET Core, EF Core, AutoMapper, and XUnit; How...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found