Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Parsing gives incorrect/unexpected/inconsistent error results

オープン
#2,664 コメント 8 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
csharp
領域
cli

調査の方向性

issue に示されているコマンドと引数を使用して、RawApi_Version_Error_tests と RawApi_Help_Error_tests の動作を再現します。報告されたエラー数とメッセージを、想定されるパースおよびバリデーションの動作と比較します。完了時には、--help と --version の処理を含め、パースエラーとアプリケーション依存のバリデーションを明確かつ制御可能に分離できている状態にします。

索引モデルが issue の本文から書いたものです。

説明

Area-Parser and Binder

Version: 2.0.0-beta7.25380.108 (Latest NuGet as of this writing)

[TestMethod]
public void RawApi_Version_Error_tests( )
{
    var rootCommand = new RootCommand("Test Root")
    {
        new Option<string>("--option1")
        {
            Description = "Test option `",
            Required = true,
        },
    };

    var result = rootCommand.Parse(["--FooBar", "--version"]);
    Assert.HasCount( 3, result.Errors, "Errors should account for, bogus arg (`--FooBar`), missing required arg (`--option1`), AND that `--version` should be solo" );
}

This test won't pass, the error count is only 2, the error regarding the --version is completely missing.
Errors are:
[0] = "Unrecognized command or argument '--FooBar'."
[1] = "Option '--option1' is required."

For help it's even worse...

[TestMethod]
public void RawApi_Help_Error_tests( )
{
    var rootCommand = new RootCommand("Test Root")
    {
        new Option<string>("--option1")
        {
            Description = "Test option `",
            Required = true,
        },
    };

    var result = rootCommand.Parse(["--FooBar", "--help"]);
    Assert.HasCount( 3, result.Errors, "Errors should account for, bogus arg (`--FooBar`), missing required arg (`--option1`), AND that `--version` should be solo" );
}

This results in NO errors. But the expectation is that an error for the bogus param AND the missing required argument is present. Basically, the problem is one of co-mingling parsing (which is really lex+parse) with validation which is semantic analysis and is VERY application dependent. Ideally, there is a way to disable all validations and move that to a distinct operation the application is in control of.

主要言語
C#
スター
3.7k
フォーク
434
平均マージ
4時間 46分
マージ済み PR(30日)
1

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

dotnet/command-line-api のほかの issue

dotnet/command-line-api の issue をすべて見る

似ている issue

C# の issue をもっと見る

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

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