[Mono-bugs] [Bug 679599] New: Linker shouldn't remove constructors for types which are used by generic types/methods 'new' constraint

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Mar 14 22:52:49 EDT 2011


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

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


           Summary: Linker shouldn't remove constructors for types which
                    are used by generic types/methods 'new' constraint
    Classification: Mono
           Product: MonoDroid
           Version: SVN
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Tools
        AssignedTo: jbevain at novell.com
        ReportedBy: jpryor at novell.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


Context:
http://lists.ximian.com/mailman/private/monodroid/2011-March/003644.html

To recreate this bug:

1. Create a monodroid project linked to a monodroid class library
2. The class library should include the following code:

   public interface IA
    {
        void Do();
    }

    public class A : IA
    {
        public A()
        { }

        public void Do()
        {          
        }
    }

    public interface IB
    {
        void Do();
    }

    public class B<TA> : IB
        where TA : IA, new()
    {
        public B()
        {
        }

        public void Do()
        {
        }
    }


3. The main assembly has a member of interface IB called: IB b;

4. Instantiate the member on a method called in OnCreate and you get an
exception:  b = new B<A>();

W/mono    ( 7780): Missing method .ctor in assembly Hello.dll, type Typespec
0x1b000003
E/mono    ( 7780): [0xafd4d440:] EXCEPTION handling: System.TypeLoadException:
Could not load type 'Mono.Samples.Hello.A' from assembly 'HelloLibrary,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
I/MonoDroid( 7780): UNHANDLED EXCEPTION: System.TypeLoadException: Could not
load type 'Mono.Samples.Hello.A' from assembly 'HelloLibrary, Version=0.0.0.0,
Culture=neutral, PublicKeyToken=null'.
I/MonoDroid( 7780): at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_
(intptr,intptr,intptr) <0x00057>
I/MonoDroid( 7780): at (wrapper dynamic-method)
object.6c700434-795f-44df-b515-4282376d8971 (intptr,intptr,intptr) <0x00033>
E/mono    ( 7780): [0xafd4d440:] EXCEPTION handling: System.TypeLoadException:
Could not load type 'Mono.Samples.Hello.A' from assembly 'HelloLibrary,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
E/mono    ( 7780): 
E/mono    ( 7780): Unhandled Exception: System.TypeLoadException: Could not
load type 'Mono.Samples.Hello.A' from assembly 'HelloLibrary, Version=0.0.0.0,
Culture=neutral, PublicKeyToken=null'.
E/mono    ( 7780):   at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_
(IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState)
[0x00000] in <filename unknown>:0 
E/mono    ( 7780):   at (wrapper dynamic-method)
object:6c700434-795f-44df-b515-4282376d8971 (intptr,intptr,intptr)

Disabling the linker and/or adding [Preserve(AllMembers=true)] to the A type
allows the program to run without error.

Thus: is it possible for the linker to detect that B`1 has a constructor
constraint, and since A is used as a type parameter to B`1 preserve the A
default constructor?

-- 
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