Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions CsvHelper.FastDynamic/CsvReaderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ public static IEnumerable<dynamic> EnumerateDynamicRecords(this CsvReader csvRea

for (var i = 0; i < csvHeader.FieldNames.Length; i++)
{
values[i] = csvReader.Parser[i];
if (i >= csvReader.Parser.Count)
{
values[i] = default;
}
else
{
values[i] = csvReader.Parser[i];
}
Comment on lines +43 to +50
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Behavior change adds support for rows with fewer fields than the header, but there are no tests asserting that missing fields yield null/default (and that no exception is thrown). Please add/extend unit tests to cover: (1) header has more columns than row values, and (2) the missing header columns map to null in the produced dynamic record.

Copilot uses AI. Check for mistakes.
}

record = new CsvRecord(csvHeader, values);
Expand Down Expand Up @@ -105,7 +112,14 @@ public static async IAsyncEnumerable<dynamic> EnumerateDynamicRecordsAsync(this

for (var i = 0; i < csvHeader.FieldNames.Length; i++)
{
values[i] = csvReader.Parser[i];
if (i >= csvReader.Parser.Count)
{
values[i] = default;
}
else
{
values[i] = csvReader.Parser[i];
}
Comment on lines +115 to +122
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Async path mirrors the sync fix for short rows, but current test suite doesn’t cover missing-field rows for EnumerateDynamicRecordsAsync. Add a test that reads a CSV where the header has more columns than a data row and asserts missing fields are null/default and no ReaderException is thrown.

Copilot uses AI. Check for mistakes.
}

record = new CsvRecord(csvHeader, values);
Expand Down