`WithUnknownContent` Does Not Support List Members
See original GitHub issueHello and thank you very much for the EXS library. I would like to ask about the way how unknown elements are deserialized into array/list items. Please consider following example. Currently extended serializer creates an instance of animal per each inner element of Animals
node even for cases that element name is not Animal
. Is there a way to configure EXS not do so and skip these unknown elements? This behavior differs from standard XmlSerializer
which does not deserialize unknown child elements. Any help would be very appreciated.
[Test]
public void ShouldIgnoreUnknownXmlArrayItems()
{
var input = "<Zoo><Animals><Animal/><Animal/><Human/></Animals></Zoo>";
var serializer = new ConfigurationContainer()
.Type<Zoo>()
.Name("Zoo")
.EnableImplicitTyping(typeof(Zoo))
.Create();
var contentStream = new MemoryStream(Encoding.UTF8.GetBytes(input));
var reader = XmlReader.Create(contentStream));
var deserialized = (Zoo) serializer.Deserialize(reader);
Assert.That(deserialized.Animals.Count, Is.EqualTo(2));
}
public class Zoo
{
public List<Animal> Animals { get; set; }
}
public class Animal
{
}
I was trying to play around with WithUnknownContent
method and put breakpoint into Call
lambda as described in #256 . However the breakpoint was never hit by debugger.
.EnableReaderContext()
.WithUnknownContent().Call(reader =>
{
// debugger never reach this code
var content = reader.Content();
})
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
Collective HUs and HUs with Unknown Content in Inbound ...
Process Steps: · An inbound delivery with several physical HUs, but there is no information about which product items are packed into which...
Read more >Unknown file type MIME?
Do I have to specify a MIME type if the uploaded file has no extension? In other words is there a default general...
Read more >Add application/json support on IIS 7
I have several WCF services that i want to host on an IIS 7 machine. My clients will POST data to these services...
Read more >Properly configuring server MIME types - MDN Web Docs
If a web server or application reports an incorrect MIME type for content (including a "default type" for unknown content), a web browser...
Read more >ASAM MDF - Wiki
The introduction of distributed data blocks in ASAM MDF 4.0 was essential to support a practicable implementation of sorted writing: Instead of writing...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This has been deployed to NuGet and deployed here: https://www.nuget.org/packages/ExtendedXmlSerializer/
Thanks again for your patience and collaboration with this issue. It is very much appreciated! I am glad we were able to track this down and it wouldn’t have been possible without your sleuthing.
If you find any additional issues with this please do let me know and I will see if they can be addressed. Closing for now.
Thank you Mike. I am glad to see that I was almost there. Yesterday I was just playing with that
UnknownContentHandlingExtension.Services
class but I did not know about theIClassification
that does the magic. And regarding the design of code - to be honest, show me a good developer who never wanted to delete whole solution and start all over.