[Mono-bugs] [Bug 81350][Wis] New - non-public extension method problems

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Tue Apr 10 20:36:31 EDT 2007

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 ijbema at fmf.nl.


--- shadow/81350	2007-04-10 20:36:31.000000000 -0400
+++ shadow/81350.tmp.15037	2007-04-10 20:36:31.000000000 -0400
@@ -0,0 +1,53 @@
+Bug#: 81350
+Product: Mono: Compilers
+Version: 1.2
+OS Details: 
+Status: NEW   
+Priority: Wishlist
+Component: C#
+AssignedTo: rharinath at novell.com                            
+ReportedBy: ijbema at fmf.nl               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+Summary: non-public extension method problems
+A non-public extension method gives several problems:
+1) when it's called in the ``oldfashioned'' way, it gives very
+strange/wrong error messages (compared to the non-extension method
+2) when it's called in the extension method way it generates invalid IL code
+sample file:
+using System;
+static class Program{
+	static void Main(string[] args)
+    {
+        string s = "Hello, world";
+        //compiles to nonworking il code:
+        s.Print();
+        //gives an incomprehensible error and an incorrect error:
+       	//error CS0119: Expression denotes a `type', where a `variable',
+`value' or `method group' was expected <-- wtf?
+			//Ext.cs(14,13): error CS1501: No overload for method `Print' takes `2'
+arguments <-- it takes one argument from a linq point of few, also can a
+class be a ``this'' parameter?
+        Foo.Print(s);
+    }
+//the problem is that Print is not public
+//this class gives either an incomprehensible error or generates wrong il code
+static class Foo{static void Print(this string s){Console.WriteLine(s);}}
+// the following implemtation gives a normal error:
+// static class Foo{static void Print(string s){Console.WriteLine(s);}}

More information about the mono-bugs mailing list