Skip to content

BeXmlSerializable does not respect XmlIgnoreAttribute #2626

@sa-he

Description

@sa-he

Description

BeXmlSerializable creates a clone using XmlSerializer. XmlSerializer ignores members marked by XmlIgnoreAttribute.

The resulting clone is compared with the original. But this comparison does NOT ignore members marked by XmlIgnoreAttibute.

Reproduction Steps

public class DemoData
{
    public string Id { get; set; }

    [XmlIgnore]
    public Guid IdWrapper
    {
        get => Guid.Parse(this.Id);
        set => this.Id = value.ToString();
    }

    [XmlIgnore]
    public string IgnoreMe { get; set; }

    public string Name { get; set; }
}

// Arrange
var sut = new DemoData { Id = "m2", Name = "test 2", IgnoreMe = "ignore me" };

// Act
sut.Should().BeXmlSerializable();

Expected behavior

Test should succeed.

Actual behavior

Test fails.

Regression?

No response

Known Workarounds

No response

Configuration

FluentAssertions Version="6.12.0"
MSTest.TestAdapter/Framework Version="2.2.8"
net472 and net6.0-windows

Other information

No response

Are you willing to help with a pull-request?

No

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions