commandlineparser / commandlineparser/commandline
dotnet fsi fails on dotnet-sdk 6.0.3 - No parameterless constructor found
- Ngôn ngữ chính
- C#
- Star
- 4.8k
- Fork
- 478
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
* 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 "?"
```
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Bắt đầu bằng cách chạy script F# được cung cấp với CommandLineParser.FSharp 2.9.1 trên dotnet 6.0.300, sau đó so sánh với dotnet 6.0.203, nơi nó hoạt động. Truy vết lệnh gọi parser được hiển thị trong stack trace và xác minh kết quả bằng cùng script đó; được xem là hoàn tất khi các đối số không hợp lệ hoặc bị thiếu tạo ra thông báo CLI usage như mong đợi thay vì MissingMethodException.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- csharp, fsharp
- Lĩnh vực
- cli
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100