Please do not reply to this email- if you want to comment on the bug, go to the URL shown below and enter your comments there.
Changed by [EMAIL PROTECTED] http://bugzilla.ximian.com/show_bug.cgi?id=79249 --- shadow/79249 2006-09-01 15:13:58.000000000 -0400 +++ shadow/79249.tmp.26683 2006-09-01 15:13:58.000000000 -0400 @@ -0,0 +1,73 @@ +Bug#: 79249 +Product: Mono: Class Libraries +Version: 1.1 +OS: +OS Details: +Status: NEW +Resolution: +Severity: +Priority: Wishlist +Component: CORLIB +AssignedTo: [EMAIL PROTECTED] +ReportedBy: [EMAIL PROTECTED] +QAContact: [EMAIL PROTECTED] +TargetMilestone: --- +URL: +Cc: +Summary: Unable to generate static interface methods using Reflection.Emit + +Please fill in this template when reporting a bug, unless you know what you +are doing. +Description of Problem: + +If MethodAttributes.Static is passed to TypeBuilder.DefineMethod, it throws +exception "Interface method must be abstract and virtual." There's nothing +wrong about static methods in interfaces and there are compilers (e.g. +Phalanger) that actually use this for certain helpers. Not to mention that +it works in CLR :) + +Steps to reproduce the problem: + +using System; +using System.Reflection; +using System.Reflection.Emit; + +namespace ConsoleApplication1 +{ + class Program + { + static void Main(string[] args) + { + AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly( + new AssemblyName("ass"), + AssemblyBuilderAccess.Run); + + ModuleBuilder mb = ab.DefineDynamicModule("mod"); + + TypeBuilder tb = mb.DefineType( + "ILikeDotNet", + TypeAttributes.Public | TypeAttributes.Abstract | +TypeAttributes.Interface); + + MethodBuilder fb = tb.DefineMethod( + "Foo", + MethodAttributes.Public | MethodAttributes.Static, + typeof(void), + Type.EmptyTypes); + + fb.GetILGenerator().Emit(OpCodes.Ret); + + tb.CreateType(); + } + } +} + +Actual Results: +Unhandled Exception: System.ArgumentException: attributes +Parameter name: Interface method must be abstract and virtual. + +Expected Results: +- + +How often does this happen? +Always. _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
