Cysharp / ConsoleAppFramework

Zero Dependency, Zero Overhead, Zero Reflection, Zero Allocation, AOT Safe CLI Framework powered by C# Source Generator.
MIT License
1.54k stars 88 forks source link

Validation causes build error CS0103 if using a class-based approach #116

Closed fog-bank closed 1 month ago

fog-bank commented 1 month ago

ver.5.1.0 にて、クラスベースの方法でコマンドを追加する際に、System.ComponentModel.DataAnnotations.RangeAttribute を使用していると、ビルドに失敗します。 [Range(0, 1)] の部分を削除すれば、ビルドに成功します。

using System.ComponentModel.DataAnnotations;
using ConsoleAppFramework;

var app = ConsoleApp.Create();
app.Add<Test>();
app.Run(args);

public class Test
{
    public void Show([Range(0, 1)] double value) => ConsoleApp.Log($"{value}");
}

ビルド結果:

Error (active)  CS0103  The name 'command' does not exist in the current context    ConsoleApp1 F:\src\ConsoleApp1\obj\Debug\net8.0\ConsoleAppFramework\ConsoleAppFramework.ConsoleAppGenerator\ConsoleApp.Builder.g.cs 98
neuecc commented 1 month ago

ありがとうございます! v5.1.1で修正しました!

fog-bank commented 1 month ago

こちらこそありがとうございました!