commandlineparser / commandlineparser/commandline

Does the Options attribute class really need to be sealed?

オープン
#859 コメント 3 件 リアクション 1 件 担当者 0 名 GitHub で見る
awaiting response
主要言語
C#
スター
4.8k
フォーク
478
PR マージ指標
30日以内にマージされた PR はありません

説明

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.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

ファイルもテストも指定されていません。まず C# Options/OptionAttribute 宣言とその sealed 修飾子を見つけ、次に属性がどのように使用され、テストでカバーされているかを調べます。完了条件は、派生オプション属性をサポートするかどうかについてプロジェクトが明示的でレビュー済みの判断を下し、その判断が yes である場合に対応する API とテストの更新が行われていることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
csharp
領域
cli
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。