Skip to content

System.Xml.Serialization.XmlSerializer serializes 0x00 but crashes on deserialization #1411

Closed
Woodpile37/runtime
#47
@Bonuspunkt

Description

@Bonuspunkt

sample

public class StringContainer
{
    public string String { get; set; }
}

[Fact]
public void Test()
{
    var serializer = new XmlSerializer(typeof(StringContainer));

    var expected = new StringContainer
    {
        String = "Sample\0Text"
    };

    var stream = new MemoryStream();
    serializer.Serialize(stream, expected);

    stream.Position = 0;
    var actual = (StringContainer)serializer.Deserialize(stream); // <-- exception
}

it would be nice, if the exception would occur at serialization, because its a pita when it happens at deserialization with huge streams (ex There is an error in XML document (54563, 98).)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-SerializationbugwishlistIssue we would like to prioritize, but we can't commit we will get to it yet

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions