Does the Options attribute class really need to be sealed?
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 35/100
Rechercherichtung
Es ist keine Datei und kein Test genannt. Beginne damit, die C#-Deklaration von Options/OptionAttribute und ihren sealed-Modifizierer zu finden; untersuche dann, wie Attribute verwendet und durch Tests abgedeckt werden. Als abgeschlossen gilt die Aufgabe, wenn das Projekt eine explizite, überprüfte Entscheidung darüber getroffen hat, ob abgeleitete Option-Attribute unterstützt werden, mit entsprechenden API- und Testaktualisierungen, falls diese Entscheidung dafür ausfällt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
I have been using CommandLineParser for a while now (and it's changed how I build tools -- thank you!) including in a program with ~50 Verbs (and growing), and since many of the Verbs take common options, I was hoping to extend Options to provide common handling of them.
Simple example: if 15 Verbs take a LogFile option, each of which has a long name ("log-file") and a help description, I can do this now by constant strings to keep them consistent, but if I were able to do:
[AttributeUsage(AttributeTargets.Property)]
public class LogFileOptionAttribute : OptionAttribute
{
public LogFileOptionAttribute(bool required = false)
: base("log-file") // I don't use short option names for anything
{
HelpText = "Name of the logfile to use for blah blah blah";
Required = required;
}
}
and then adorn the actual option with:
public class BlahOptions {
...
[LogFileOption]
public string LogFileName {get ; set; }
...
}
I have easily a dozen of these common options. It's not a huge deal to create constant strings:
[Option(OPTION_LOGFILE_NAME, HelpText = OPTION_LOGFILE_HELPTEXT)]
but adding this level of abstraction would be more convenient.
If there's a good reason for this class to be sealed, then so be it, but mine doesn't feel like a ridiculous use case. I may well get to 100 verbs for this tool by the time I'm done.
- Vorherrschende Sprache
- C#
- Sterne
- 4.8k
- Forks
- 478
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus commandlineparser/commandline
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
commandlineparser/commandline#951 · 1 Kommentar ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 70/100
commandlineparser/commandline#880 · 2 Reaktionen ·
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 45/100
commandlineparser/commandline#952 ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
commandlineparser/commandline#948 ·
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
commandlineparser/commandline#947 ·
Alle Issues in commandlineparser/commandline
Ähnliche Issues
-
bug
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
-
Type: enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
apache/arrow-adbc#4809 ·
-
type/automation type/tech-debt
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
microsoft/vscode-azurefunctions#5197 · 1 Kommentar ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
microsoft/microsoft-ui-reactor#1274 ·