dotnet / dotnet/command-line-api
Naming mismatch between options/arguments and handler parameters is non-obvious
- Vorherrschende Sprache
- C#
- Sterne
- 3.7k
- Forks
- 428
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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.~
Beitragsleitfaden
Rechercherichtung
Beginne damit, das in diesem Issue beschriebene Verhalten bei der Bindung von Handler-Parametern und die in #1012 und #1362 diskutierten alternativen APIs zu prüfen. Das Issue nennt keine Dateien, Tests oder abgestimmte Vorgehensweise; Umfang und Verifizierungskriterien müssten vor der Implementierung mit den Maintainer:innen abgestimmt werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- csharp
- Bereich
- cli
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100