aloneguid / parquet-dotnet

Fully managed Apache Parquet implementation
https://aloneguid.github.io/parquet-dotnet/
MIT License
542 stars 140 forks source link

[BUG]: Serialisation error for class with nullable struct with child property #495

Open paulengineer opened 3 months ago

paulengineer commented 3 months ago

Library Version

4.23.4

OS

Windows

OS Architecture

64 bit

How to reproduce?

  1. Add test below (possibly to ParquetSerializerTest.cs ?) and run

Failing test

private struct StructWithIntProp {
    public int id { get; set; }
}
private class ClassWithNullableCustomStruct {
    public StructWithIntProp? nullableStruct { get; set; }
}

[Fact]
public async Task Class_With_Nullable_Struct() {
    var data = new List<ClassWithNullableCustomStruct> {
        new ClassWithNullableCustomStruct() {
            nullableStruct = null
        }
    };

    using var ms = new MemoryStream();
    await ParquetSerializer.SerializeAsync(data, ms);

    ms.Position = 0;
    IList<ClassWithNullableCustomStruct> data2 = await ParquetSerializer.DeserializeAsync<ClassWithNullableCustomStruct>(ms);

    Assert.Equivalent(data2, data);
}