From de88c3c4b5d89aa608639dd123fd63bb5384b0f8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 15 Aug 2026 04:08:38 +0000 Subject: [PATCH 1/6] Guard newer APIs for netstandard2.0 Co-authored-by: wforney <79032+wforney@users.noreply.github.com> --- SharedCode.Core/Data/DataReaderExtensions.cs | 10 ++++++++-- SharedCode.Core/IO/BufferedWriter.cs | 15 +++++++++++++++ SharedCode.Core/Linq/EnumerableExtensions.cs | 15 +++++++++++++-- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/SharedCode.Core/Data/DataReaderExtensions.cs b/SharedCode.Core/Data/DataReaderExtensions.cs index f850917..6e931ac 100644 --- a/SharedCode.Core/Data/DataReaderExtensions.cs +++ b/SharedCode.Core/Data/DataReaderExtensions.cs @@ -80,7 +80,13 @@ public static IList ToDelimited(this IDataReader @this, string separator if (@this.GetFieldType(index) == typeof(string)) { // If double quotes are used in value, ensure each are replaced but 2. - if (value?.Contains('"', StringComparison.Ordinal) == true) + if ( +#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER + value?.IndexOf('"', StringComparison.Ordinal) >= 0 +#else + value?.IndexOf('"') >= 0 +#endif + ) { #if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER value = value.Replace("\"", "\"\"", StringComparison.Ordinal); @@ -90,7 +96,7 @@ public static IList ToDelimited(this IDataReader @this, string separator } // If separtor are is in value, ensure it is put in double quotes. - if (value?.Contains(separator, StringComparison.Ordinal) == true) + if (value?.IndexOf(separator, StringComparison.Ordinal) >= 0) { value = $"\"{value}\""; } diff --git a/SharedCode.Core/IO/BufferedWriter.cs b/SharedCode.Core/IO/BufferedWriter.cs index c461356..dbf9e91 100644 --- a/SharedCode.Core/IO/BufferedWriter.cs +++ b/SharedCode.Core/IO/BufferedWriter.cs @@ -67,7 +67,12 @@ public async Task FullFlushAsync(CancellationToken token) if (this.StringBuilder.Length > 0) { +#if NET8_0_OR_GREATER await this.writer.WriteAsync(this.StringBuilder, token).ConfigureAwait(false); +#else + token.ThrowIfCancellationRequested(); + await this.writer.WriteAsync(this.StringBuilder.ToString()).ConfigureAwait(false); +#endif _ = this.StringBuilder.Clear(); } @@ -102,7 +107,12 @@ public async Task StrongFlushAsync(CancellationToken token) if (this.StringBuilder.Length > 0) { +#if NET8_0_OR_GREATER await this.writer.WriteAsync(this.StringBuilder, token).ConfigureAwait(true); +#else + token.ThrowIfCancellationRequested(); + await this.writer.WriteAsync(this.StringBuilder.ToString()).ConfigureAwait(true); +#endif _ = this.StringBuilder.Clear(); } } @@ -128,7 +138,12 @@ public async Task WeakFlushAsync(CancellationToken token = default) { if (this.StringBuilder.Length > BufferLength) { +#if NET8_0_OR_GREATER await this.writer.WriteAsync(this.StringBuilder, token).ConfigureAwait(true); +#else + token.ThrowIfCancellationRequested(); + await this.writer.WriteAsync(this.StringBuilder.ToString()).ConfigureAwait(true); +#endif _ = this.StringBuilder.Clear(); } } diff --git a/SharedCode.Core/Linq/EnumerableExtensions.cs b/SharedCode.Core/Linq/EnumerableExtensions.cs index 9819bad..91218c1 100644 --- a/SharedCode.Core/Linq/EnumerableExtensions.cs +++ b/SharedCode.Core/Linq/EnumerableExtensions.cs @@ -271,8 +271,19 @@ public static int IndexOf(this IEnumerable @this, TSource valu /// /// true if the source enumerable is not null and contains items; otherwise, false. /// - public static bool IsNotNullOrEmpty(this IEnumerable @this) => - @this is not null && (@this.TryGetNonEnumeratedCount(out var count) ? count > 0 : @this.Any()); + public static bool IsNotNullOrEmpty(this IEnumerable @this) + { + if (@this is null) + { + return false; + } + +#if NET6_0_OR_GREATER + return @this.TryGetNonEnumeratedCount(out var count) ? count > 0 : @this.Any(); +#else + return @this.Any(); +#endif + } /// /// Determines whether the source enumerable is null or contains no items. From c4297da10ac99d57d0952092623374fa3ebc82cc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 15 Aug 2026 04:09:57 +0000 Subject: [PATCH 2/6] Refine netstandard2.0 compatibility guards Co-authored-by: wforney <79032+wforney@users.noreply.github.com> --- SharedCode.Core/Data/DataReaderExtensions.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/SharedCode.Core/Data/DataReaderExtensions.cs b/SharedCode.Core/Data/DataReaderExtensions.cs index 6e931ac..3c45a33 100644 --- a/SharedCode.Core/Data/DataReaderExtensions.cs +++ b/SharedCode.Core/Data/DataReaderExtensions.cs @@ -1,4 +1,5 @@ using System.Data; +using System.Globalization; namespace SharedCode.Data; @@ -96,7 +97,14 @@ public static IList ToDelimited(this IDataReader @this, string separator } // If separtor are is in value, ensure it is put in double quotes. - if (value?.IndexOf(separator, StringComparison.Ordinal) >= 0) + if ( +#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER + value?.IndexOf(separator, StringComparison.Ordinal) >= 0 +#else + value is not null && + CultureInfo.InvariantCulture.CompareInfo.IndexOf(value, separator, CompareOptions.Ordinal) >= 0 +#endif + ) { value = $"\"{value}\""; } From 95810fb3d5d4f18f300acd9b5099ff96682f4492 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 15 Aug 2026 04:10:52 +0000 Subject: [PATCH 3/6] Document netstandard fallback behavior Co-authored-by: wforney <79032+wforney@users.noreply.github.com> --- SharedCode.Core/Data/DataReaderExtensions.cs | 2 +- SharedCode.Core/IO/BufferedWriter.cs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/SharedCode.Core/Data/DataReaderExtensions.cs b/SharedCode.Core/Data/DataReaderExtensions.cs index 3c45a33..c139cc8 100644 --- a/SharedCode.Core/Data/DataReaderExtensions.cs +++ b/SharedCode.Core/Data/DataReaderExtensions.cs @@ -96,7 +96,7 @@ public static IList ToDelimited(this IDataReader @this, string separator #endif } - // If separtor are is in value, ensure it is put in double quotes. + // If separator is in value, ensure it is put in double quotes. if ( #if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER value?.IndexOf(separator, StringComparison.Ordinal) >= 0 diff --git a/SharedCode.Core/IO/BufferedWriter.cs b/SharedCode.Core/IO/BufferedWriter.cs index dbf9e91..6624278 100644 --- a/SharedCode.Core/IO/BufferedWriter.cs +++ b/SharedCode.Core/IO/BufferedWriter.cs @@ -71,6 +71,7 @@ public async Task FullFlushAsync(CancellationToken token) await this.writer.WriteAsync(this.StringBuilder, token).ConfigureAwait(false); #else token.ThrowIfCancellationRequested(); + // Older targets do not expose a cancellable TextWriter string overload. await this.writer.WriteAsync(this.StringBuilder.ToString()).ConfigureAwait(false); #endif _ = this.StringBuilder.Clear(); @@ -111,6 +112,7 @@ public async Task StrongFlushAsync(CancellationToken token) await this.writer.WriteAsync(this.StringBuilder, token).ConfigureAwait(true); #else token.ThrowIfCancellationRequested(); + // Older targets do not expose a cancellable TextWriter string overload. await this.writer.WriteAsync(this.StringBuilder.ToString()).ConfigureAwait(true); #endif _ = this.StringBuilder.Clear(); @@ -142,6 +144,7 @@ public async Task WeakFlushAsync(CancellationToken token = default) await this.writer.WriteAsync(this.StringBuilder, token).ConfigureAwait(true); #else token.ThrowIfCancellationRequested(); + // Older targets do not expose a cancellable TextWriter string overload. await this.writer.WriteAsync(this.StringBuilder.ToString()).ConfigureAwait(true); #endif _ = this.StringBuilder.Clear(); From fd93a7fa4232679a0e6792ca1c140a95419e2889 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 15 Aug 2026 04:37:49 +0000 Subject: [PATCH 4/6] Fix DataReaderExtensions review comments for target framework compatibility Co-authored-by: wforney <79032+wforney@users.noreply.github.com> --- SharedCode.Core/Data/DataReaderExtensions.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/SharedCode.Core/Data/DataReaderExtensions.cs b/SharedCode.Core/Data/DataReaderExtensions.cs index c139cc8..21703ff 100644 --- a/SharedCode.Core/Data/DataReaderExtensions.cs +++ b/SharedCode.Core/Data/DataReaderExtensions.cs @@ -1,5 +1,7 @@ using System.Data; +#if !(NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER) using System.Globalization; +#endif namespace SharedCode.Data; @@ -81,13 +83,7 @@ public static IList ToDelimited(this IDataReader @this, string separator if (@this.GetFieldType(index) == typeof(string)) { // If double quotes are used in value, ensure each are replaced but 2. - if ( -#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER - value?.IndexOf('"', StringComparison.Ordinal) >= 0 -#else - value?.IndexOf('"') >= 0 -#endif - ) + if (value?.Contains('"', StringComparison.Ordinal) == true) { #if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER value = value.Replace("\"", "\"\"", StringComparison.Ordinal); From baf8d4bef6678dfb2e2ce17dc8e97502cd29ab49 Mon Sep 17 00:00:00 2001 From: Bill Forney Date: Fri, 14 Aug 2026 23:06:09 -0700 Subject: [PATCH 5/6] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- SharedCode.Core/Data/DataReaderExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SharedCode.Core/Data/DataReaderExtensions.cs b/SharedCode.Core/Data/DataReaderExtensions.cs index 21703ff..b378ecf 100644 --- a/SharedCode.Core/Data/DataReaderExtensions.cs +++ b/SharedCode.Core/Data/DataReaderExtensions.cs @@ -95,7 +95,7 @@ public static IList ToDelimited(this IDataReader @this, string separator // If separator is in value, ensure it is put in double quotes. if ( #if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER - value?.IndexOf(separator, StringComparison.Ordinal) >= 0 + value?.IndexOf(separator, StringComparison.Ordinal) is >= 0 #else value is not null && CultureInfo.InvariantCulture.CompareInfo.IndexOf(value, separator, CompareOptions.Ordinal) >= 0 From 607bfb7a6c82ebec6118f78434e9c1c4235be052 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 15 Aug 2026 06:26:59 +0000 Subject: [PATCH 6/6] Fix DataReaderExtensions cross-TFM compatibility issues Co-authored-by: wforney <79032+wforney@users.noreply.github.com> --- SharedCode.Core/Data/DataReaderExtensions.cs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/SharedCode.Core/Data/DataReaderExtensions.cs b/SharedCode.Core/Data/DataReaderExtensions.cs index b378ecf..e63d9cc 100644 --- a/SharedCode.Core/Data/DataReaderExtensions.cs +++ b/SharedCode.Core/Data/DataReaderExtensions.cs @@ -1,7 +1,4 @@ using System.Data; -#if !(NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER) -using System.Globalization; -#endif namespace SharedCode.Data; @@ -83,7 +80,11 @@ public static IList ToDelimited(this IDataReader @this, string separator if (@this.GetFieldType(index) == typeof(string)) { // If double quotes are used in value, ensure each are replaced but 2. - if (value?.Contains('"', StringComparison.Ordinal) == true) +#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER + if (value?.IndexOf('"', StringComparison.Ordinal) >= 0) +#else + if (value?.IndexOf('"') >= 0) +#endif { #if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER value = value.Replace("\"", "\"\"", StringComparison.Ordinal); @@ -93,14 +94,7 @@ public static IList ToDelimited(this IDataReader @this, string separator } // If separator is in value, ensure it is put in double quotes. - if ( -#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER - value?.IndexOf(separator, StringComparison.Ordinal) is >= 0 -#else - value is not null && - CultureInfo.InvariantCulture.CompareInfo.IndexOf(value, separator, CompareOptions.Ordinal) >= 0 -#endif - ) + if (value?.IndexOf(separator, StringComparison.Ordinal) >= 0) { value = $"\"{value}\""; }