Property with init-only setter results in MissingMethodException
まだ誰も着手していません。
評価
調査の方向性
CommandLine.Core.InstanceBuilder.Build のスタックトレースから始め、リンク先の .NET Fiddle にある init-only property のケースを再現します。Parser.ParseArguments が options インスタンスをどのように作成するかを追跡し、その後、init-only setter を持つ Options 型の解析が MissingMethodException なしで完了することを確認します。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
In case of read-only properties in the command line options class, where a property is defined as
public string Foo
{
get;
init;
}
you will get a MissingMethodException when parsing the command line.
To Reproduce
See this fiddle https://dotnetfiddle.net/J05g0c
Expected behavior
The exception is not thrown
Additional context
The resulting stack trace is as follows:
Unhandled exception. System.MissingMethodException: Cannot dynamically create an instance of type '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.<Build>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 Program.Main(String[] args)
- 主要言語
- C#
- スター
- 4.8k
- フォーク
- 478
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
commandlineparser/commandline のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
commandlineparser/commandline#951 · コメント 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 70/100
commandlineparser/commandline#880 · リアクション 2 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 45/100
commandlineparser/commandline#952 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
commandlineparser/commandline#948 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
commandlineparser/commandline#947 ·
commandlineparser/commandline の issue をすべて見る
似ている issue
-
bug frontend good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
NavigationViewItemAutomationPeer implements IInvokeProvider but never advertises the Invoke pattern オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
unoplatform/uno#24629 ·
-
agentic-workflows Needs: Triage :mag: State: In-PR
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
-
Type: enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
apache/arrow-adbc#4809 ·