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: [email protected]
        ReportedBy: [EMAIL PROTECTED]
         QAContact: [email protected]
          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.
_______________________________________________
mono-bugs maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs

Reply via email to