Breaking changes in CSVHelper v23 includes "All delegates now take in a single struct argument." PrepareHeaderForMatch is one of those delegates. I get a compile error "Delegate 'PrepareHeaderForMatch' does not take 2 arguments".
I'm sorry about the basic question, but I am not sure how to fix PrepareHeaderForMatch in my code. I'm sure it's simple, but I cannot find any examples or help yet on the web. Maybe this post will help someone else in the future.
var csvConfig = new CsvConfiguration(CultureInfo.CurrentCulture)
{
HeaderValidated = null,
MissingFieldFound = null,
PrepareHeaderForMatch = (string header, int index) => header.ToLower() // Match header and property names after converting to lower case
};
I've been scratching my head on this one as well. The release notes as you say give no indication how to fix the problem, and the documentation has not been updated. I finally had to view the source code to solve it.
This works:
var csvConfig = new CsvConfiguration(CultureInfo.CurrentCulture)
{
PrepareHeaderForMatch = args => args.Header.ToLowerInvariant()
};
I prefer the new class for the args, but a simple example on a breaking change would have been nice.