commandlineparser / commandlineparser/commandline
unable to set default value using Uri
- Linguagem predominante
- C#
- Estrelas
- 4.8k
- Forks
- 478
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
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.
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Direção de pesquisa
Reproduce the issue with the shown Options class, Uri property, Value attribute, and Parser.Default.ParseArguments call. Trace how the parser applies the default string and handles the Uri input; done means the default URI is assigned successfully and invalid URI input produces a parser error instead of requiring manual construction in Run.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- csharp
- Domínio
- cli
- Tipo de issue
- Bug
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 45/100