Open jeoffm opened 1 year ago
There was a breaking change with CsvHelper 20.0.0
20.0.0 Features Changed CsvConfiguration to a read only record to eliminate threading issues.
You need to pass a CsvConfiguration
to CsvWriter
void Main()
{
var records = new List<Foo>
{
new Foo { Id = 1, Name = "one" },
};
var config = new CsvConfiguration(CultureInfo.InvariantCulture)
{
HasHeaderRecord = false
};
//using (var writer = new StreamWriter("path\\to\\file.csv"))
using (var csv = new CsvWriter(Console.Out, config))
{
csv.WriteRecords(records);
}
}
public class Foo
{
public int Id { get; set; }
public string Name { get; set; }
}
Describe the bug the class model allows this
_csvWriter.Context.Configuration.HasHeaderRecord = false;
but it is not honored as the code always refers to the private memberprivate readonly bool hasHeaderRecord;
which can only be set at instantiation timeExpected behavior the Context's value should be honored, otherwise why have a context??