From 8e32734453a1ece5b38abc8b590f133d8c262325 Mon Sep 17 00:00:00 2001 From: Paul Reeder Date: Tue, 7 Apr 2020 06:54:51 -0500 Subject: [PATCH 1/2] Fixed bug where a return type which implements IEnumerable but is not itself generic (or perhaps not [generic]) would fail when UseSingleLineHeaderInCsv was true. --- src/WebApiContrib.Core.Formatter.Csv/CsvOutputFormatter.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/WebApiContrib.Core.Formatter.Csv/CsvOutputFormatter.cs b/src/WebApiContrib.Core.Formatter.Csv/CsvOutputFormatter.cs index 0e419ad..01081f1 100644 --- a/src/WebApiContrib.Core.Formatter.Csv/CsvOutputFormatter.cs +++ b/src/WebApiContrib.Core.Formatter.Csv/CsvOutputFormatter.cs @@ -69,6 +69,10 @@ public async override Task WriteResponseBodyAsync(OutputFormatterWriteContext co var response = context.HttpContext.Response; Type type = context.Object.GetType(); + if (!type.IsGenericType || type.GetGenericTypeDefinition() != typeof(IEnumerable<>)) + { + type = type.GetInterfaces().First(z => z.GetGenericTypeDefinition() == typeof(IEnumerable<>)); + } Type itemType; if (type.GetGenericArguments().Length > 0) From f71f8f0edfcc57e8aae31fe74939a0dd641b1758 Mon Sep 17 00:00:00 2001 From: Paul Reeder Date: Fri, 16 Dec 2022 08:01:45 -0600 Subject: [PATCH 2/2] version update --- .../WebApiContrib.Core.Formatter.Csv.csproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/WebApiContrib.Core.Formatter.Csv/WebApiContrib.Core.Formatter.Csv.csproj b/src/WebApiContrib.Core.Formatter.Csv/WebApiContrib.Core.Formatter.Csv.csproj index dfec2b6..9d745f9 100644 --- a/src/WebApiContrib.Core.Formatter.Csv/WebApiContrib.Core.Formatter.Csv.csproj +++ b/src/WebApiContrib.Core.Formatter.Csv/WebApiContrib.Core.Formatter.Csv.csproj @@ -10,9 +10,9 @@ ASP.NET Core;InputFormatter;OutputFormatter;MediaFormatter;CSV;Content-Type;aspnetcore Replace smart quotes when encoding is Windows-1252 https://github.com/damienbod/WebAPIContrib.Core/tree/master/src/WebApiContrib.Core.Formatter.Csv - 3.0.1 - 3.0.1 - 3.0.1 + 3.0.2 + 3.0.2 + 3.0.2 true