Skip to content

Deserializing record structs doesn't respect default arguments. #6556

@whatston3

Description

@whatston3

Produced on 275.2.0.

Reproduction

In DataRecordTest.cs, add the following definitions:

    [DataRecord]
    public partial record struct OneByteOneDefaultIntRecordStruct(byte A, int B = 5);
    [Test]
    public void OneByteOneDefaultIntRecordStructTest()
    {
        var mapping = new MappingDataNode {{"a", "1"}};
        var val = Serialization.Read<OneByteOneDefaultIntRecordStruct>(mapping);

        Assert.Multiple(() =>
        {
            Assert.That(val.A, Is.EqualTo(1));
            Assert.That(val.B, Is.EqualTo(5));
        });
    }

Run the tests. OneByteOneDefaultIntRecordStructTest will fail, as val.B has a value of 0.

Metadata

Metadata

Assignees

No one assigned

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions