Skip to content

Conversation

@TheBrambleShark
Copy link

Fixes serdedotnet/serde#276
Closes serdedotnet/serde#281

Sorry for the delay on this. I've mostly only had time to work on this while at work and things got busy. I changed my approach a bit for this version to match some of the other libraries. Please let me know what you think.

@TheBrambleShark
Copy link
Author

Changed up how I did things a bit by adding a new FixedWidthBuffer type. This type is intended only for serialization and allows for situations like this, where field order does not match the offset order:

[GenerateSerde]
public partial record class Person
(
    [property: FixedFieldInfo(0, 10)] string FirstName,
    [property: FixedFieldInfo(10, 10)] string LastName,
    [property: FixedFieldInfo(20, 5)] int EmployeeId,
    [property: FixedFieldInfo(28, 8, format: "MMddyyyy")] DateTime Birthday
)
{
    [FixedFieldInfo(25, 3, "D3")]
    [SerdeMemberOptions(SkipDeserialize = true)]
    public int Age => DateOnly.FromDateTime(DateTime.Today).Year - Birthday.Year;
}

See also: serdedotnet/serde#287

…e simple code for non-generated serde objects
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.

Fixed-Width Text File Support

1 participant