[Mono-bugs] [Bug 389116] New: TypeBuilder: TypeLoadException is not reported when interface implementation is missing

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sat May 10 15:40:58 EDT 2008


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


           Summary: TypeBuilder: TypeLoadException is not reported when
                    interface implementation is missing
           Product: Mono: Class Libraries
           Version: SVN
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: CORLIB
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: gert.driesen at pandora.be
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


Currently, TypeBuilder.CreateType does not throw a TypeLoadException when one
of its methods - which implements an interface method - does not have a body.

To reproduce, compile and run the following code:

using System;
using System.Reflection;
using System.Reflection.Emit;

class Program
{
        static void Main ()
        {
                AssemblyName assemblyName = new AssemblyName ();
                assemblyName.Name = "lib";

                AssemblyBuilder ab =
AppDomain.CurrentDomain.DefineDynamicAssembly (
                        assemblyName, AssemblyBuilderAccess.RunAndSave,
                        AppDomain.CurrentDomain.BaseDirectory);
                ModuleBuilder mb = ab.DefineDynamicModule ("lib.dll");

                TypeBuilder tb = mb.DefineType ("TheType",
TypeAttributes.Public,
                        typeof (object), new Type [] { typeof (IRunner) });
                tb.CreateType ();
        }
}

public interface IRunner
{
        void Create (int interval);
}

Expected result:

Unhandled Exception: System.TypeLoadException: Method 'Create' in type
'TheType'
 from assembly 'lib, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
does
 not have an implementation.
   at System.Reflection.Emit.TypeBuilder._TermCreateClass(Int32 handle, Module
m
odule)
   at System.Reflection.Emit.TypeBuilder.CreateTypeNoLock()
   at System.Reflection.Emit.TypeBuilder.CreateType()
   at Program.Main()

Actual result:

Successful completion.


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