[Mono-bugs] [Bug 463041] New: XElement.Add, XElement.Attribute, XElement. ToString bugs block use of VB XML literals

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Dec 31 01:11:58 EST 2008


           Summary: XElement.Add, XElement.Attribute, XElement.ToString bugs
                    block use of VB XML literals
           Product: Mono: Class Libraries
           Version: 1.9
          Platform: x86
        OS/Version: openSUSE 11.1
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Sys.XML
        AssignedTo: atsushi at ximian.com
        ReportedBy: lu at wischik.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: Community User

Description of Problem:

* XElement.Add(List<XAttribute>) throws NotImplementedException
* XElement.Add(IEnumerable) throws NotImplementedException
* XElement.Attribute(...) throws ArgumentNullException on absent attribute, but
should just return NULL
* XElement.ToString() gives incorrect output in presence of namespace


VB has native syntax for "XML literals", which the compiler emits as calls to
functions in the System.Xml.Linq namespace. The user has no control over which
calls are emitted.

Mono has four bugs in its System.Xml.Linq implementation, where it differs from
the CLR behavior, and which make it basically impossible to use VB's XML

For ease in reproducing this bug, I've provided the C# equivalent of what VB
codegens. If the C# bugs are fixed, then VB's XML literals will now work
properly in Mono. Until then, VB's XML literals are basically unusable.

Steps to reproduce the problem:
Actual Results:
Expected Results:
See code snippet at bottom of this report

How often does this happen? 
Always. It is reproducible.

using System.Xml.Linq;

class Program

    static void Main(string[] args)
        // This syntax in VB:
        //    Dim x1 = <xml><%= New Uri("http://news.bbc.co.uk") %></xml>
        // Emits this kind of code in C#:
        var x1 = new XElement(XNamespace.Get("").GetName("xml"));
        var x1a = new System.Collections.Generic.List<XAttribute>();
        try { x1.Add(x1a); } catch (System.NotImplementedException) {
System.Console.WriteLine("ex1"); }
        // MONO: prints "ex1"
        // CLR: doesn't throw an exception, doesn't print anything

        // This syntax in VB:
        //    Dim x2 = <xml><%= New XElement() {<item1></item1>} %></xml>
        // Emits this kind of code in C#:
        var x2 = new XElement(XNamespace.Get("").GetName("xml"));
        var x2a = (System.Collections.IEnumerable)new XElement[] { };
        try { x2.Add(x2a); } catch (System.NotImplementedException) {
System.Console.WriteLine("ex2"); }
        // MONO: prints "ex2"
        // CLR: doesn't throw an exception, doesn't print anything

        // This syntax in VB:
        //    Dim x3 = <xml attr="hello"></xml>. at world
        // Emits this kind of code in C#:
        var x3 = new XElement(XNamespace.Get("").GetName("xml"));
        var x3n = XNamespace.Get("").GetName("attr");
        try { string s = (string)x3.Attribute(x3n); } catch
(System.ArgumentNullException) { System.Console.WriteLine("ex3"); }
        // MONO: prints "ex3"
        // CLR: doesn't throw an exception, doesn't print anything, returns
"null" for s

        // This syntax in VB:
        //    Dim x4 = <xml><itunes:item></itunes:item></xml>
        // Emits this kind of code in C#:
        XElement x4 = new XElement(XNamespace.Get("").GetName("xml"));
        XName x4ns =
        XAttribute x4a = new XAttribute(x4ns,
        XElement x4i = new
        // MONO: prints
        // CLR:  prints <xml


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