ovska / FlameCsv

High performance RFC 4180 compliant CSV parsing library for .NET 6+
MIT License
6 stars 1 forks source link

Support for records #8

Closed ovska closed 3 months ago

ovska commented 3 months ago

Currently a record generates an invalid initializer:

public record User(int Id, string Name, DateTime LastLogin, int? Age = null);

Generated:

Examples.User obj = new Examples.User()
{
    Id = state.Id!,
    Name = state.Name!,
    LastLogin = state.LastLogin!,
    Age = state.Age!,
};
ovska commented 3 months ago

Resolving to the single valid constructor also generates funky code like this:

Examples.User obj = new Examples.User(
    Id: state.@p_Id!,
    Name: state.@p_Name!,
    LastLogin: state.@p_LastLogin!,
    Age: state.@p_Age!)
{
    Id = state.Id!,
    Name = state.Name!,
    LastLogin = state.LastLogin!,
    Age = state.Age!,
};
return obj;

This is due to init properties being always required, needs to be fixed for records

ovska commented 3 months ago

Still missing for reflection path