commandlineparser / commandlineparser/commandline

Option Default type conversion

未關閉
#740 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
C#
星號
4.8k
分支
478
PR 合併指標
30 天內沒有已合併 PR

描述

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

貢獻指南

這個儲存庫沒有索引到貢獻指南

研究方向

定位 OptionAttribute 與現有的命令列引數轉換路徑。比較提議的 string Default 與 DefaultProperty 方案,包括它們對 CultureInfo 等參考型別預設值的影響。完成要求確定 API 方向,並涵蓋屬性指定預設值的轉換。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
csharp
領域
cli
Issue 類型
功能
難度
5/5
預估耗時
一週以上
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。