Bug 24589 - Atom10ItemFormatter fails to deserialize ATOM XML with Source element
Summary: Atom10ItemFormatter fails to deserialize ATOM XML with Source element
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: WCF assemblies (show other bugs)
Version: 3.2.x
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-11-17 15:14 UTC by josh.gehman
Modified: 2017-09-06 16:55 UTC (History)
1 user (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Code exposing issue (8.04 KB, text/plain)
2014-11-17 15:14 UTC, josh.gehman
Details

Description josh.gehman 2014-11-17 15:14:38 UTC
Created attachment 8772 [details]
Code exposing issue

Atom10ItemFormatter fails to deserialize ATOM XML when it contains a Source element.  When I attempt to use the formatter to read the XML into a SyndicationItem, I encounter an XmlException with the message "Only element node is expected under 'entry' element".  I have identified a number of issues with the Source element in the XML.  I have included code to expose the issues that I have uncovered.

1) No White Space in XML
  - When the ATOM XML contains no white space formatting, I encounter the exception
2) White Space in XML
  - When the ATOM XML contains white space formatting, the exception is not encountered
  - However in this scenario, the Source element is not deserialized correctly, the Source ID element is deserialized into the SyndicationItem.SourceFeed.Generator property
3) Empty Source element in XML
  - In .NET this example encounters an XmlException
  - In Mono this example works
4) No Source element in XML
  - This example works in both .NET and Mono
5) Link elements present after Source element in XML
  - The first link element encountered after the Source element is skipped
6) Summary element after Source element in XML
  - XmlException is thrown when running in Mono
7) Author element after Source element in XML
  - SyndicationItem.Authors is not populated as expected
  - Author information is found in SyndicationItem.ElementExtensions


Program output when ran in .NET

No Whitespace in XML is valid

Whitespace in XML is valid

System.Xml.XmlException: 'None' is an invalid XmlNodeType.
   at System.Xml.XmlReader.ReadEndElement()
   at System.ServiceModel.Syndication.Atom10FeedFormatter.ReadItemFrom(XmlReader
 reader, SyndicationItem result, Uri feedBaseUri)
   at System.ServiceModel.Syndication.Atom10ItemFormatter.ReadFrom(XmlReader rea
der)
   at ConsoleApplication1.Program.RunTest(String testRunName, SourceElementOptio
n sourceElementOption, Boolean isSummaryAfterSource, Boolean isAuthorAfterSource
, Boolean areLinksAfterSource, Boolean includeWhiteSpaceInXml) in c:\Users\fooba
r\Desktop\ConsoleApplication1\ConsoleApplication1\Program.cs:line 73
Empty Source element failed to deserialize

No Source element is valid

Links after Source element is valid

Summary after Source element is valid

Author after Source element is valid


Program output when ran in Mono

System.Xml.XmlException: Only element node is expected under 'entry' element
  at System.ServiceModel.Syndication.Atom10ItemFormatter.ReadXml (System.Xml.Xml
Reader reader, Boolean fromSerializable) [0x00000] in <filename unknown>:0
  at System.ServiceModel.Syndication.Atom10ItemFormatter.ReadFrom (System.Xml.Xm
lReader reader) [0x00000] in <filename unknown>:0
  at ConsoleApplication1.Program.RunTest (System.String testRunName, SourceEleme
ntOption sourceElementOption, Boolean isSummaryAfterSource, Boolean isAuthorAfte
rSource, Boolean areLinksAfterSource, Boolean includeWhiteSpaceInXml) [0x00000]
in <filename unknown>:0
No Whitespace in XML failed to deserialize

item.SourceFeed.Id is not correct
        Expected: urn:uuid:b0dc5cfb-275c-4f71-9fd9-60f1bb06589e
        Actual:   null
item.SourceFeed.Generator is not correct
        Expected: null
        Actual:   urn:uuid:b0dc5cfb-275c-4f71-9fd9-60f1bb06589e
Whitespace in XML is not valid

Empty Source element is valid

No Source element is valid

item.Links.Count is not correct
        Expected: 2
        Actual:   1
item.Links did not contain the self link
item.SourceFeed.Id is not correct
        Expected: urn:uuid:b0dc5cfb-275c-4f71-9fd9-60f1bb06589e
        Actual:   null
item.SourceFeed.Generator is not correct
        Expected: null
        Actual:   urn:uuid:b0dc5cfb-275c-4f71-9fd9-60f1bb06589e
Links after Source element is not valid

System.Xml.XmlException: Only element node is expected under 'entry' element
  at System.ServiceModel.Syndication.Atom10ItemFormatter.ReadXml (System.Xml.Xml
Reader reader, Boolean fromSerializable) [0x00000] in <filename unknown>:0
  at System.ServiceModel.Syndication.Atom10ItemFormatter.ReadFrom (System.Xml.Xm
lReader reader) [0x00000] in <filename unknown>:0
  at ConsoleApplication1.Program.RunTest (System.String testRunName, SourceEleme
ntOption sourceElementOption, Boolean isSummaryAfterSource, Boolean isAuthorAfte
rSource, Boolean areLinksAfterSource, Boolean includeWhiteSpaceInXml) [0x00000]
in <filename unknown>:0
Summary after Source element failed to deserialize

item.Authors.Count is not correct
        Expected: 1
        Actual:   0
item.SourceFeed.Id is not correct
        Expected: urn:uuid:b0dc5cfb-275c-4f71-9fd9-60f1bb06589e
        Actual:   null
item.SourceFeed.Generator is not correct
        Expected: null
        Actual:   urn:uuid:b0dc5cfb-275c-4f71-9fd9-60f1bb06589e
item.ElementExtensions.Count is not correct
        Expected: 0
        Actual:   2
Author after Source element is not valid

Note You need to log in before you can comment on or make changes to this bug.