bilal-fazlani / commanddotnet

A modern framework for building modern CLI apps
https://commanddotnet.bilal-fazlani.com
MIT License
560 stars 32 forks source link

Pipe Example Excute Error with Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object #440

Closed legenself closed 2 years ago

legenself commented 2 years ago

this is my code

 class Program
    { 
        static int Main(string[] args)
        {
            return new AppRunner<Program>().Run(args); 
        }
        public void Range( int start, int count, int sleep = 0)
        {
            foreach (var i in Enumerable.Range(start, count))
            {
                Console.WriteLine(i);
                if (sleep > 0)
                {
                    Thread.Sleep(sleep);
                }
            }
        }

        public void Sum(IEnumerable<int> values)
        {
            int total = 0;
            foreach (var value in values)
            {
                Console.WriteLine(total += value);
            }
        }
    }

and my command

./BufferInspacter.exe Range  10 100 1  | ./BufferInspacter.exe Sum

and error output

Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at BufferInspacter.Program.Sum(IEnumerable`1 values) in C:\Users\admin\source\repos\jpgls\BufferInspacter\Program.cs:line 41
--- End of stack trace from previous location ---
   at CommandDotNet.AppRunner.HandleException(Exception ex, IConsole console, CommandContext commandContext) in CommandDotNet/AppRunner.cs:line 158
   at CommandDotNet.AppRunner.Run(String[] args) in CommandDotNet/AppRunner.cs:line 83
   at BufferInspacter.Program.Main(String[] args) in C:\Users\admin\source\repos\jpgls\BufferInspacter\Program.cs:line 25
legenself commented 2 years ago

because i use low version of commanddotnet