From 2efe3a4f200c91a43a2c5d6fe53064898994e5a8 Mon Sep 17 00:00:00 2001 From: Josh Close Date: Thu, 29 Feb 2024 14:52:21 -0600 Subject: [PATCH] Removed dependency on System.Linq.Async. Updated package reference versions. --- src/CsvHelper/CsvHelper.csproj | 31 ++++++++----------- src/CsvHelper/CsvWriter.cs | 7 +++-- .../Compatibility/IsExternalInit.cs | 6 ++++ tests/CsvHelper.Tests/CsvHelper.Tests.csproj | 6 ++-- 4 files changed, 27 insertions(+), 23 deletions(-) create mode 100644 tests/CsvHelper.Tests/Compatibility/IsExternalInit.cs diff --git a/src/CsvHelper/CsvHelper.csproj b/src/CsvHelper/CsvHelper.csproj index f080bc528..3d821abd2 100644 --- a/src/CsvHelper/CsvHelper.csproj +++ b/src/CsvHelper/CsvHelper.csproj @@ -48,46 +48,41 @@ - - - - - - - + + + - - - + + + - - - + + + - - - + + + - - + diff --git a/src/CsvHelper/CsvWriter.cs b/src/CsvHelper/CsvWriter.cs index e3db3db8b..b5d3f1dd3 100644 --- a/src/CsvHelper/CsvWriter.cs +++ b/src/CsvHelper/CsvWriter.cs @@ -6,7 +6,6 @@ using CsvHelper.Expressions; using CsvHelper.TypeConversion; using System; -using System.Buffers; using System.Collections; using System.Collections.Generic; using System.Dynamic; @@ -773,7 +772,11 @@ private async Task WriteHeaderAsync(IAsyncEnumerable records) return hasHeaderBeenWritten; } - return WriteHeader(await records.FirstOrDefaultAsync()); + var enumerator = records.GetAsyncEnumerator(); + await enumerator.MoveNextAsync().ConfigureAwait(false); + var header = enumerator.Current; + + return WriteHeader(header); } private bool WriteHeader(IEnumerable records) diff --git a/tests/CsvHelper.Tests/Compatibility/IsExternalInit.cs b/tests/CsvHelper.Tests/Compatibility/IsExternalInit.cs new file mode 100644 index 000000000..b2942b517 --- /dev/null +++ b/tests/CsvHelper.Tests/Compatibility/IsExternalInit.cs @@ -0,0 +1,6 @@ +#if NETFRAMEWORK +namespace System.Runtime.CompilerServices +{ + internal static class IsExternalInit { } +} +#endif diff --git a/tests/CsvHelper.Tests/CsvHelper.Tests.csproj b/tests/CsvHelper.Tests/CsvHelper.Tests.csproj index ce060e13c..720f7cfb6 100644 --- a/tests/CsvHelper.Tests/CsvHelper.Tests.csproj +++ b/tests/CsvHelper.Tests/CsvHelper.Tests.csproj @@ -1,8 +1,8 @@  - - net8.0 + net8.0;net7.0;net6.0;net48;net47;net462 + preview True CsvHelper.snk @@ -16,7 +16,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive