[Mono-osx] MonoMac.dll depends on System.Drawing.dll?

Lee V. Andrus landrus2 at by-rite.net
Wed Sep 8 18:00:57 EDT 2010

1st, I also would like to see any dependence on System.Drawing  
eliminated from MonoMac.  This is only 1 of the inconsistencies with  
such a dependency.  Most Mono-Cocoa bridges define structures based on  
Cocoa's NSPoint, NSSize, and NSRect.  But don't hold your breath while  
waiting for these guys to make a simple logical fix that would likely  
break other user's code to accommodate your very special use.  They  
are very focused on serving the most common scenario.

2nd, my suggestion is not a namespace alias, but type aliases that  
give you access to specific types without exposing the whole  
namespace.  The attached file illustrates this.  It uses PointF and  
RectangleF from System.Drawing with a custom class named Graphics.

3rd, If your wrapper assembly MUST define code in namespace  
System.Drawing, I have 2 suggestions:
  A) Rename it System.Drawing.dll in hopes that Monomac.dll will use  
its Point, etc.
  B) The compiler's -reference option can define an alias to  
disambiguate assemblies that define the same namespace.  Check out the  
man page for mcs.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hello graphics.cs.zip
Type: application/zip
Size: 1886 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-osx/attachments/20100908/e264b502/attachment.zip 
-------------- next part --------------

On Sep 8, 2010, at 1:36 PM, Inspired Mars wrote:

> Namespace aliases will not fix this, as mentioned before.
> ...
> Thus, our wrapper for Graphics.AddLines cannot use our definition of  
> PointF because
> CGContext expects the definition inside System.Drawing.dll.
> But our wrapper also cannot use the definition inside  
> System.Drawing.dll because
> referencing that dll means we cannot have a wrapper by that name to  
> begin with,
> since the dll defines exactly the same wrapper.
> The solution here is to ... directly define Point, Size, Rectangle,  
> PointF, SizeF, RectangleF
> in MonoMac.dll. Then, our app would use these definitions and the  
> rest of the System.Drawing wrappers
> our app defines would work.
> Net: This is a very simple fix to implement in MonoMac, and  
> MonoTouch already works this way.
> Thanks
> On Wed, Sep 8, 2010 at 11:22 AM, Lee V. Andrus <landrus2 at by- 
> rite.net> wrote:
>> Using directives can also be used to create aliases for specific  
>> types
>> without exposing the whole namespace.  Like this:
>>  using PointF = System.Drawing.PointF;
>> I'm sure it's a pain to put so much at the top of every file because
>> C# doesn't have #include or typedef.  But this can reduce the  
>> solution
>> to boilerplate.  You may even be able to incorporate it into your
>> standard header.

More information about the Mono-osx mailing list