Skip to content

v3.0.0

Latest

Choose a tag to compare

@stevehansen stevehansen released this 02 Nov 21:31
· 2 commits to master since this release
392b9b1

Install: Csv 3.0.0 on nuget.org.

Changed

  • Breaking: target frameworks are now netstandard2.0 and net10.0 (dropped net8.0 and net9.0)
    • .NET 8/9 apps now resolve the netstandard2.0 build, which lacks the Span/Memory APIs (ReadAsSpan, ReadFromMemoryOptimized, CsvBufferWriter, ...)
  • Removed the stale NetStandardImplicitPackageVersion 1.6.0 pin; it broke the netstandard2.0 build once NuGet package pruning kicked in for net10.0

Fixed

  • ReadFromStreamAsync and ReadFromTextAsync dropping cancellation tokens when consumed with .WithCancellation(ct)
    • Async enumerator implementations now carry [EnumeratorCancellation] and forward tokens to the underlying reader engine
  • CsvWriter not quoting fields that contain a bare carriage return (\r)
    • Per RFC 4180 a field containing CR, LF, the separator, or a quote must be quoted; CsvWriter only triggered on \n, the separator, ', and ", so a value like a\rb was written unquoted — mis-parsed by strict readers and split into two records when re-read
    • CsvBufferWriter already included \r; all CsvWriter paths (sync, async, and the ReadOnlyMemory<char> paths) now match it

Performance

  • Removed a per-row char[] allocation in CsvWriter.WriteLine/WriteLineAsync by caching the fixed quote-trigger characters in a static array and checking the variable separator separately
  • Reader: 40–55% fewer bytes allocated and 10–35% faster on net10.0
    • Line splitting jumps between separators/quotes with vectorized IndexOfAny and returns an exact-size array instead of a List
    • Field trimming/unquoting reuses the split array instead of copying it
    • Escaped quotes are unescaped in one pass with a single allocation (was one allocation per escape)
    • ReadFromText/ReadFromTextAsSpan slice the input string instead of allocating a string per line; Raw is materialized on first access and cached
  • Writer: quoted fields containing " are written in segments instead of via string.Replace / per-char writes on net10.0

Full changes: 7b3f998...v3.0.0 (since 2.0.245)

🤖 Generated with Claude Code