JoshClose / CsvHelper

Library to help reading and writing CSV files
http://joshclose.github.io/CsvHelper/
Other
4.66k stars 1.05k forks source link

LeaveOpen removed from CsvConfiguration #2082

Open crobibero opened 1 year ago

crobibero commented 1 year ago

Describe the bug The property LeaveOpen was removed from the CsvConfiguration class.

To Reproduce Attempt to update from 29.0.0 to 30.0.0.0 (or 30.0.1)

Expected behavior LeaveOpen should be available.

Additional context PR that removed the functionality: https://github.com/JoshClose/CsvHelper/pull/1267 Specific commit: https://github.com/JoshClose/CsvHelper/commit/283d68f97437f921b23606d71f08f3bcf4afd571

OldrichDlouhy commented 1 year ago

The changelog for version 30.0.0 incorrectly states in the breaking changes section that

Added bool LeaveOpen { get; } to IWriterConfiguration.
Added bool LeaveOpen { get; } to IParserConfiguration.

While the properties were in fact removed.

The LeaveOpen value is now passed directly via constructor for the parser and writer:

public CsvParser(TextReader reader, IParserConfiguration configuration, bool leaveOpen = false) { ... }

public CsvWriter(TextWriter writer, IWriterConfiguration configuration, bool leaveOpen = false) { ... }
andres-olivares-ncontracts commented 1 year ago

Does this update impact ExcelWriter? I updated from from CsvHelper 27.2.1 to 30.0.1, and when calling the following:

using var stream = new MemoryStream(); await using (var excelWriter = new ExcelWriter(stream, new CultureInfo("en-US"))) // Fails - Exception thrown: 'System.MissingMethodException' in CsvHelper.Excel.dll { await excelWriter.WriteRecordsAsync(collection); }

return stream.ToArray();

image

image

Don't know if this is the right place to post this, but it seemed related. Reverted back to CsvHelper 27.2.1 to keep it moving.

Thanks so much in advance,