Description
When parsing the following XML:
<Document>
<Test unknown="attribute">
...
</Test>
</Document>
Into the following classes:
public class Test
{
...
}
public class Document
{
public Test Test;
}
XMLSerializer's Deserialize function correctly fires an UnknownAttribute event. However, for the following XML:
<Document>
<TestList unknown="attribute not triggered">
...
</TestList>
<StringField unknown="attribute not triggered">random</StringField>
</Document>
And classes:
public class Document
{
[XmlArrayItem("Test")]
public List<string> TestList;
public string StringField;
}
No event is fired for the unknown attribute on either the list or the string field.
Reproduction Steps
Using the XML and classes above, run the following code to verify that HandleUnknownAttribute is not called when erroneous attributes are present on string or list fields (or any built-in type it seems, including ints, bools, etc.):
var serializer = new XmlSerializer(typeof(Document));
serializer.UnknownAttribute += HandleUnknownAttribute
using (var reader = new FileStream("filename.xml", FileMode.Open))
{
serializer.Deserialize(reader);
}
...
public void HandleUnknownAttribute(object sender, XmlAttributeEventArgs e)
{
// not triggered for TestList or StringField
}
Expected behavior
An UnknownAttribute event should be fired and the event handler called
Actual behavior
No event is fired
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
Description
When parsing the following XML:
Into the following classes:
XMLSerializer's Deserialize function correctly fires an UnknownAttribute event. However, for the following XML:
And classes:
No event is fired for the unknown attribute on either the list or the string field.
Reproduction Steps
Using the XML and classes above, run the following code to verify that
HandleUnknownAttributeis not called when erroneous attributes are present on string or list fields (or any built-in type it seems, including ints, bools, etc.):Expected behavior
An UnknownAttribute event should be fired and the event handler called
Actual behavior
No event is fired
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response