commandlineparser / commandlineparser/commandline

unable to set default value using Uri

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

説明

trying to be able to run an app like this:
consoleApp.exe
or
consoleApp.exe http://someOtherUri.invalid:1234

i can get the default value to work using a string:
class Options{
[Value(0,
Default = "http://someUri.invalid:1234"
)]
public string OptionalUri { get;set;}
}

but not using a Uri as its type.
class Options{
[Value(0,
Default = "http://someUri.invalid:1234"
)]
public Uri OptionalUri { get;set;}
}

static void Main(string[] args)
{
CommandLine.Parser.Default.ParseArguments(args)
.WithParsed(Run)
.WithNotParsed(HandleParseError);
}
static void Run(Options options)
{
//Uri u = options.OptionalUri;
Uri u = new Uri(options.OptionalUri); // possible parseerrors, should've been handled in commandlineparser
}

then i get
Error setting value to option '': Check if Option or Value attribute values
are set properly for the given type.

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

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

評価

この issue はまだ評価されていません。

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

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