commandlineparser / commandlineparser/commandline
Option Default type conversion
- Vorherrschende Sprache
- C#
- Sterne
- 4.8k
- Forks
- 478
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
Hi,
I'm wondering why the `Default` property of `OptionAttribute` is of type `object`. This makes it rather hard to have defaults for reference types as it has to be compile-time constant. Wouldn't it be better to have the `Default` property of type `string` and use the same conversion that is in place when the actual command line argument is parsed?
For example I'd like to have option of type `CultureInfo` with default value `en-US`, now it is not possible to have this default specified through attribute (I have to assign in in constructor of the option class)
Another quite elegant solution is adding `DefaultProperty` property to `OptionAttribute` that will specify name of property returning actual default value, this has been mentioned in issue #530 and similar to #191
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
OptionAttribute und den bestehenden Konvertierungspfad für Befehlszeilenargumente lokalisieren. Die vorgeschlagenen Ansätze mit string Default und DefaultProperty vergleichen, einschließlich ihrer Auswirkungen auf Defaults von Referenztypen wie CultureInfo. Als abgeschlossen gilt die Aufgabe, wenn eine endgültige API-Richtung festgelegt ist und die Konvertierung eines attributspezifizierten Defaults abgedeckt ist.
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
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100