minhhungit / ConsoleTableExt

A fluent library to print out a nicely formatted table in a console application C#
MIT License
331 stars 37 forks source link

List crashed when using with string type #25

Closed zhenyuan0502 closed 3 years ago

zhenyuan0502 commented 3 years ago

There was a bug when int is replaced by string

//Worked
ConsoleTableBuilder.From(new List<int> { 1, 2, 3, 4, 5, 6 })
.WithFormat(ConsoleTableBuilderFormat.Alternative).WithColumn("I'm a custom name").ExportAndWrite();

//Crashed
ConsoleTableBuilder.From(new List<string> { "1", "2", "3", "4", "5", "6" }).WithFormat(ConsoleTableBuilderFormat.Alternative).WithColumn("I'm a custom name").ExportAndWrite();

Unhandled exception. System.Reflection.TargetParameterCountException: Parameter count mismatch. at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture) at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index) at ConsoleTableExt.ConsoleTableBuilder.From[T](List`1 list)

minhhungit commented 3 years ago

I will check it, thank you

minhhungit commented 3 years ago

@zhenyuan0502 fixed, please update to version 3.16

zhenyuan0502 commented 3 years ago

@minhhungit it's solved, thank you for your time.

palenshus commented 2 months ago

Still reproing for me on 3.2:

var tableData = new List<List<string>>
{
    new List<string>{ "Sakura Yamamoto", "Support Engineer", "London", 46.ToString(), ""},
    new List<string>{ "Serge Baldwin", "Data Coordinator", "San Francisco", 28.ToString(), "something else" },
    new List<string>{ "Shad Decker", "Regional Director", "Edinburgh", "", ""},
};

ConsoleTableBuilder
    .From(tableData)
    .Export().Dump();