[Mono-bugs] [Bug 640402] New: XmlSerialization and GetConstructor not working on generic types

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sun Sep 19 12:21:54 EDT 2010



           Summary: XmlSerialization and GetConstructor not working on
                    generic types
    Classification: Mono
           Product: MonoTouch
           Version: unspecified
          Platform: Macintosh
        OS/Version: Mac OS X 10.6
            Status: NEW
          Severity: Major
          Priority: P5 - None
         Component: Runtime
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: johan.otto at justenough.com
         QAContact: mono-bugs at lists.ximian.com
                CC: johan.otto at justenough.com
          Found By: Customer
           Blocker: Yes

Description of Problem:

Steps to reproduce the problem:
1. Create a class that inherits from a generic class that has a
[Preserve(AllMembers=true)]. In my case I have the following (simplified):

public class BusinessObject

public partial class Customer : BusinessObject
  public string Name {get; set;}

public class BusinessObjects<T> : Collection<T> where T: BusinessObject
  public BusinessObjects()
  public BusinessObjects(BusinessObject owner):this()

    public partial class Customers : BusinessObjects<Customer>
            public Customers(Organization owner):base(owner) // Can remove for
testing pruposes
          public Customers():base()


2. Now try and use the the XmlSerializer to serialize the class. 
3. Also try and call this extension method I wrote... always returns false.

public static bool HasDefaultConstructor(this Type type)

            if (type.IsPrimitive)
                return true;

            if (type.GetConstructor(
                | BindingFlags.Instance
                | BindingFlags.CreateInstance, null, new Type[0], null) !=
                return true;

            return false;

----- Test Xml
  <Customer Name="Zim" />
  <Customer Name="Zum" />

Actual Results:
  The constructor does not get preserved when using reflection even though
[Preserve(AllMembers=true)] on the base class.

The XmlSerializer failes with a SIGNEV

Expected Results:

How often does this happen? 
if the class is not used directly in the code path from Main()... everytime

Additional Information:

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

More information about the mono-bugs mailing list