dotnet / dotnet/command-line-api
Naming mismatch between options/arguments and handler parameters is non-obvious
- Lingua principale
- C#
- Stelle
- 3.7k
- Fork
- 428
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
System.CommandLine's most common usability issue is that handler parameters whose name doesn't match an option or argument will never be successfully bound at invocation time.
For example, it may seem intuitive that the following should work, but handler parameter `i` will never be bound:
```cs
var command = new RootCommand
{
new Option("--an-int")
};
command.Handler = CommandHandler.Create( i => /* */ );
```
The alternative APIs were introduced here:
* #1012
A more flexible approach (using a similar API pattern but generating the handlers using source generators) is being worked out here:
* #1362
Possible approaches include:
* ~Add an ordering-based matching strategy. This possibly suffers from other non-obviousness problems. Maybe the two strategies can operate together.~
* ~Add an error checking mechanism. Ideally this would not be a runtime check since, once compiled, it would be a continual performance hit while the answer would never change. An analyzer might be a good approach.~
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia esaminando il comportamento di binding dei parametri dell'handler descritto nell'issue e le API alternative discusse in #1012 e #1362. L'issue non identifica file, test o un approccio concordato; prima dell'implementazione sarebbe necessario concordare con i maintainer l'ambito e i criteri di verifica.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- csharp
- Ambito
- cli
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100