Csvhelper: Breaking change when migrating to CsvHelper 7.1.1

Created on 23 Jul 2018  路  3Comments  路  Source: JoshClose/CsvHelper

I am trying to upgrade from 2.16.3 to 7.1.1. After fixing a few easy compilation problems, I am stuck with the following csv reader configuration properties that do not exist anymore:

  • SkipEmptyRecords
  • IsHeaderCaseSensitive
  • TrimFields
  • TrimHeaders
  • WillThrowOnMissingField

Can you please provide guidance on how to migrate these configuration to the new version of CsvHelper?

Thanks.

Most helpful comment

The configs have changed to more generic callbacks so it's configurable for the user, instead of me writing every feature. All the changes are listed in the change log and the configs are documented, but I'll post them here too.

https://joshclose.github.io/CsvHelper/configuration

SkipEmptyRecords -> ShouldSkipRecord

ShouldSkipRecord = record => record.All(string.IsNullOrEmpty);

IsHeaderCaseSensitive -> PrepareHeaderForMatch

PrepareHeaderForMatch = header => header.ToLower();

TrimFields -> TrimOptions

TrimOptions = TrimOptions.Trim;

TrimHeaders -> PrepareHeaderForMatch or TrimOptions

PrepareHeaderForMatch = header => header.Trim();
// or
TrimOptions = TrimOptions.Trim;

WillThrowOnMissingField -> MissingFieldExcpetion
The default throws a MissingFieldException.

// turn off
MissingFieldFound = null;

All 3 comments

The configs have changed to more generic callbacks so it's configurable for the user, instead of me writing every feature. All the changes are listed in the change log and the configs are documented, but I'll post them here too.

https://joshclose.github.io/CsvHelper/configuration

SkipEmptyRecords -> ShouldSkipRecord

ShouldSkipRecord = record => record.All(string.IsNullOrEmpty);

IsHeaderCaseSensitive -> PrepareHeaderForMatch

PrepareHeaderForMatch = header => header.ToLower();

TrimFields -> TrimOptions

TrimOptions = TrimOptions.Trim;

TrimHeaders -> PrepareHeaderForMatch or TrimOptions

PrepareHeaderForMatch = header => header.Trim();
// or
TrimOptions = TrimOptions.Trim;

WillThrowOnMissingField -> MissingFieldExcpetion
The default throws a MissingFieldException.

// turn off
MissingFieldFound = null;

TrimFields -> TrimOptions

TrimOptions = TrimOptions.Trim;

I just wanted to mention that we had to use TrimOptions = TrimOptions.Trim | TrimOptions.InsideQuotes; to regain full compatibility with 2.16.3.

Hi @JoshClose -
The link - CsvHelper-Configuration throws an error - 404 - Oh no's! We couldn't find that page :(

Is it supposed to be https://joshclose.github.io/CsvHelper/api/CsvHelper.Configuration/ ?

Thanks

Was this page helpful?
0 / 5 - 0 ratings