commandlineparser / commandlineparser/commandline

dotnet fsi fails on dotnet-sdk 6.0.3 - No parameterless constructor found

Aberta
#828 3 comentários 5 reações 0 responsáveis Ver no GitHub
Linguagem predominante
C#
Estrelas
4.8k
Forks
478
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

* install dotnet 6.0.300
* save fsx script below to a file
* run `dotnet fsi ./test.fsx`

Expected: Get cli usage message
Actual: Get error message:
```shell
System.MissingMethodException: Cannot dynamically create an instance of type 'FSI_0002+options'. Reason: No parameterless constructor defined.
at System.RuntimeType.ActivatorCache..ctor(RuntimeType rt)
at System.RuntimeType.CreateInstanceOfT()
at System.Activator.CreateInstance[T]()
at CommandLine.Core.InstanceBuilder.<>c__1`1.b__1_0(Func`1 f)
at CSharpx.MaybeExtensions.MapValueOrDefault[T1,T2](Maybe`1 maybe, Func`2 func, T2 noneValue)
at CommandLine.Core.InstanceBuilder.Build[T](Maybe`1 factory, Func`3 tokenizer, IEnumerable`1 arguments, StringComparer nameComparer, Boolean ignoreValueCase, CultureInfo parsingCulture, Boolean autoHelp, Boolean autoVersion, Boolean allowMultiInstance, IEnumerable`1 nonFatalErrors)
at CommandLine.Parser.ParseArguments[T](IEnumerable`1 args)
at .$FSI_0002.main@() in C:\Users\edeus\dev\github\smashcut\stream-poc\scripts\Opts.fsx:line 26
Stopped due to error
```

> Note: works in dotnet 6.0.203

# fsx script:
```fsharp
#r "nuget: CommandLineParser.FSharp, 2.9.1"
// #r "nuget: CommandLineParser.FSharp, 2.9.2-ci-210"

open CommandLine
open System

type options =
{ []
files: seq
[]
verbose: bool
[]
language: string
[]
offset: int64 option }

let result =
CommandLine.Parser.Default.ParseArguments(Environment.GetCommandLineArgs())

match result with
| :? Parsed as parsed -> printfn $"{parsed.Value}"
| :? NotParsed as notParsed -> printfn $"{notParsed.Errors}"
| _ -> printfn "?"

```

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Direção de pesquisa

Start by running the provided F# script with CommandLineParser.FSharp 2.9.1 under dotnet 6.0.300, then compare it with dotnet 6.0.203 where it works. Trace the parser call shown in the stack trace and verify the result with the same script; done means invalid or missing arguments produce the expected CLI usage message instead of MissingMethodException.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
csharp, fsharp
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
35/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.