Josh Close

Results 279 comments of Josh Close

What do you mean by empty? `Optional` ignores the member if the field doesn't exist in the CSV. `Validate` isn't called if the field doesn't exist. If you mean the...

Write the header manually, then write all the records. ```cs void Main() { var records = new List { new Foo { Id = 1, Name = "one" }, };...

When reading? Are you reading using `var records = csv.GetRecords();` or looping manually like `while (csv.Read())`?

You can get that info from the parser. `csv.Parser`. ```cs void Main() { var s = new StringBuilder(); s.Append("Id,Name\r\n"); s.Append("1,\"one\r\ntwo\""); var config = new CsvConfiguration(CultureInfo.InvariantCulture) { }; using (var reader...

If you want to start back on a specific row, you can do something like: ```cs void Main() { var s = new StringBuilder(); s.Append("Id,Name\r\n"); s.Append("1,\"one\r\nfoo\"\r\n"); s.Append("2,\twowo\r\n"); var config =...

There would be way too many people that wouldn't use it right if it was done this way. I believe the factory stuff was created for exactly your usage.

Ha, I thought you were referring to the factory stuff in CsvHelper, but that's your own thing. There is `CsvHelper.IFactory` and `CsvHelper.Factory`.

@firewater You would just inject an instance of `IFactory` and that is used to create a reader/writer. ```cs IFactory csvFactory = new Factory(); // This is injected. using var csvReader...

The context is per instance of CsvReader/CsvWriter and shouldn't be shared. The configuration is essentially immutable as it's values are copied local in the constructor. Any mutable state got moved...