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

Inspired Mars inspiredmars at gmail.com
Wed Sep 8 14:36:56 EDT 2010


I think I haven't explained the issue well enough.

Namespace aliases will not fix this, as mentioned before.



Here is a picture:



MyApp

+ MonoMac.dll (reference)

   + System.Drawing.dll (reference)

     - System.Drawing.PointF

     - MonoMac.CoreGraphics.CGContext

       {

           AddLines(System.Drawing.PointF[]);

       }

     - System.Drawing.Graphics

      {

          void AddLines(System.Drawing.PointF[] points)

          {

             // This implementation is broken on MonoMac, since winforms is
not supported.

          }

      }

+ Types exposed by MyApp

  - System.Drawing.PointF

  - System.Drawing.Graphics

   {

      private CGContext CGContext {get; set;}

      void AddLines(System.Drawing.PointF[] points)

      {

          This.CGContext.AddLines(points);

      }

   }



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 not have these useless types included by reference
into MonoMac,

and to follow what MonoTouch does and 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.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-osx/attachments/20100908/0025c765/attachment.html 


More information about the Mono-osx mailing list