[Mono-bugs] [Bug 79249][Wis] New - Unable to generate static interface methods using Reflection.Emit
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Fri Sep 1 15:13:58 EDT 2006
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 ladislav.prosek at matfyz.cz.
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: mono-bugs at ximian.com
+ReportedBy: ladislav.prosek at matfyz.cz
+QAContact: mono-bugs at ximian.com
+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.
More information about the mono-bugs
mailing list