Skip to content

Add support for array and List<T> properties in CSV parsing#10

Closed
Copilot wants to merge 5 commits intomainfrom
copilot/add-list-type-support
Closed

Add support for array and List<T> properties in CSV parsing#10
Copilot wants to merge 5 commits intomainfrom
copilot/add-list-type-support

Conversation

Copy link
Copy Markdown

Copilot AI commented Dec 14, 2025

Enables parsing comma-delimited values within a CSV column into arrays or List<T> properties.

Changes

Property parsing

  • Added CsvPropertyKind.List to distinguish collection properties
  • Extended CsvPropertyDefinition with element type metadata (type name, kind, date format, delimiter)
  • Modified Parser.cs to detect and validate array types and List<T> generics

Code generation

  • Added ParseListToArray<T> and ParseListToList<T> helper methods to generated code
  • Split column values by delimiter and parse each element according to its type
  • Support all existing element types: primitives, enums, dates, ISpanParsable<T>

Element types
List elements support the same types as scalar properties:

  • Strings, enums, primitives implementing ISpanParsable<T>
  • Date/time types with [CsvDateFormat] attribute

Example

public partial class Product
{
    [CsvHeaderName("Tags")]
    public string[]? Tags { get; set; }

    [CsvHeaderName("Prices")]
    public List<decimal>? Prices { get; set; }

    [GenerateCsvParser(IncludeProperties = true)]
    public static partial IEnumerable<Product> Parse(SepReader reader);
}

CSV input:

Tags,Prices
gadget,tool,hardware,9.99,19.99,29.99
electronics,14.99,24.99

Result: Tags parsed as string[], Prices as List<decimal>.

Original prompt

This section details on the original issue you should resolve

<issue_title>Consider adding support for list-like types for properties</issue_title>
<issue_description>Like arrays or List<T>.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits December 14, 2025 22:56
Co-authored-by: AustinWise <7751+AustinWise@users.noreply.github.com>
Co-authored-by: AustinWise <7751+AustinWise@users.noreply.github.com>
Co-authored-by: AustinWise <7751+AustinWise@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for list-like types for properties Add support for array and List<T> properties in CSV parsing Dec 14, 2025
Copilot AI requested a review from AustinWise December 14, 2025 23:02
@AustinWise
Copy link
Copy Markdown
Owner

Ideally I'd like the generated code to put the helpers into a file-scoped class instead of duplicating them into each instance. Or add a assembly to the Nuget that contains the attributes and the helpers.

But I don't actually need this feature right now, so I'm not going to work on this more.

@AustinWise AustinWise closed this Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider adding support for list-like types for properties

2 participants