From f0721024ce4ab4944b5165240b19a5759cf32b7f Mon Sep 17 00:00:00 2001 From: Drew Kriger Date: Thu, 28 Aug 2025 11:05:10 -0400 Subject: [PATCH] Refactor SerializeEntry to handle collections in CsvFeedExporter --- .../CsvFeedExporter.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Geta.Optimizely.ProductFeed.Csv/CsvFeedExporter.cs b/src/Geta.Optimizely.ProductFeed.Csv/CsvFeedExporter.cs index 4df0a6c..0390015 100644 --- a/src/Geta.Optimizely.ProductFeed.Csv/CsvFeedExporter.cs +++ b/src/Geta.Optimizely.ProductFeed.Csv/CsvFeedExporter.cs @@ -1,6 +1,7 @@ // Copyright (c) Geta Digital. All rights reserved. // Licensed under Apache-2.0. See the LICENSE file in the project root for more information +using System.Collections; using System.Collections.Generic; using System.Globalization; using System.IO; @@ -30,8 +31,17 @@ public override object ConvertEntry(TEntity entity, HostDefinition host, Cancell public override byte[] SerializeEntry(object value, CancellationToken cancellationToken) { - _writer.WriteRecord(value); - _writer.NextRecord(); + // Handle collections (e.g., IEnumerable) by writing all records. + // Use non-generic IEnumerable to avoid generic invariance issues. + if (value is IEnumerable enumerable && value is not string) + { + _writer.WriteRecords(enumerable); + } + else + { + _writer.WriteRecord(value); + _writer.NextRecord(); + } return []; }