[Mono-bugs] [Bug 675620] New: ArgumentNullException thrown when calling SyndicationContent.WriteTo

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Feb 28 12:54:47 EST 2011


https://bugzilla.novell.com/show_bug.cgi?id=675620

https://bugzilla.novell.com/show_bug.cgi?id=675620#c0


           Summary: ArgumentNullException thrown when calling
                    SyndicationContent.WriteTo
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.8.x
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Sys.XML
        AssignedTo: atsushi at ximian.com
        ReportedBy: dmitchell at logos.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-US)
AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.102 Safari/534.13

When calling SyndicationContent.WriteTo with an XmlWriter created from
XDocument.CreateWriter, an ArgumentNullException is thrown. In Microsoft's
implementation, no exception is thrown. Code that reproduces this behavior is
included below.

using System;
using System.IO;
using System.Linq;
using System.Net;
using System.ServiceModel.Syndication;
using System.Text;
using System.Xml;
using System.Xml.Linq;

namespace SyndicationWikiTest
{
    class MainClass
    {
        public static void Main (string[] args)
        {
            Uri uri = new
Uri("http://topics.logos.com/query.aspx?query=[[lcv_id::%creation]]&format=atom&content=wiki");
            HttpWebRequest request = (HttpWebRequest) WebRequest.Create(uri);

            SyndicationFeed feed = null;
            using (HttpWebResponse response = (HttpWebResponse)
request.GetResponse())
            using (Stream stream = response.GetResponseStream())
            using (XmlReader reader = XmlReader.Create(stream))
            {
                if (response.StatusCode == HttpStatusCode.OK)
                    feed = SyndicationFeed.Load(reader);
                else if (response.StatusCode != HttpStatusCode.NotModified)
                    Console.Out.WriteLine("Unexpected HTTP response when
accessing '{0}': {1} {2}", uri, (int) response.StatusCode,
response.StatusDescription);
            }

            if (feed == null)
            {
                Console.Out.WriteLine("No feed!");
                return;
            }

            foreach (SyndicationItem item in feed.Items)
            {
                Console.WriteLine("contentType = {0}", item.Content == null ?
"null" : item.Content.Type);

                // this should work...
                XDocument docWiki = new XDocument();
                using (XmlWriter writer = docWiki.CreateWriter())
                    item.Content.WriteTo(writer, "content", "w");

                XElement content = docWiki.Root;

                // a workaround
//                StringBuilder builder = new StringBuilder();
//                using (XmlWriter writer = XmlWriter.Create(builder))
//                    item.Content.WriteTo(writer, "content", "w");
//                
//                XDocument docWiki = null;
//                using (StringReader reader = new
StringReader(builder.ToString()))
//                    docWiki = XDocument.Load(reader);
//                
//                XElement docWikiRoot = docWiki.Root;
//                XElement content = docWikiRoot != null ?
docWikiRoot.Elements().FirstOrDefault() : null;

                Console.WriteLine("content:{0}", content);
            }
        }
    }
}

Reproducible: Always

Steps to Reproduce:
1. Take the code above, put it in a file, and compile it with the flags
-r:System.Xml.Linq -r:System.ServiceModel -r:System.ServiceModel.Web
2. Run the resulting executable
3. Crash!
Actual Results:  
An ArgumentNullException is thrown.

Expected Results:  
No ArgumentNullException should be thrown.

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list