Skip to content

Commit 8e32734

Browse files
committed
Fixed bug where a return type which implements IEnumerable<T> but is not itself generic (or perhaps not [generic]<T>) would fail when UseSingleLineHeaderInCsv was true.
1 parent c5ef816 commit 8e32734

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/WebApiContrib.Core.Formatter.Csv/CsvOutputFormatter.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ public async override Task WriteResponseBodyAsync(OutputFormatterWriteContext co
6969
var response = context.HttpContext.Response;
7070

7171
Type type = context.Object.GetType();
72+
if (!type.IsGenericType || type.GetGenericTypeDefinition() != typeof(IEnumerable<>))
73+
{
74+
type = type.GetInterfaces().First(z => z.GetGenericTypeDefinition() == typeof(IEnumerable<>));
75+
}
7276
Type itemType;
7377

7478
if (type.GetGenericArguments().Length > 0)

0 commit comments

Comments
 (0)