[MonoDevelop] Stetic code generator

Juan Cristóbal Olivares juancri at gmail.com
Fri Jun 30 03:52:37 EDT 2006


I have been thinking about a better way to generate code from the stetic
XML.

The actual schema is something like this:

Visual Designer
 ||
<==>
 ||
XML
 ||
 =>
 ||
Code Generation
 ||
 =>
 ||
Source Code

But there are some issues with the generated code:

1.- The widgets are not intances of our class (Gtk.Window) and we need to
cast (from and to) the widgets, not checking types with the compiller
2.- The signal handlers are connected on execution time (not compiller
check)
3.- No code completion for the widgets (same reason)

So, the opposite option is to generate all the widgets as instances, but
then the problem is to parse the source file (model of VS.NET 2002/2003)

But there's other way, taking an approach similar to the VS.NET 2005. It's
to create a partial class. So, for example, if we create a visual interface
(stetic) for this class:

public class MyWindow : Gtk.Window

we can change it to a partial class (currently supported my both mcs and
gmcs):

public partial class MyWindow : GtkWindow

and create other file (like MyWindow.Generated.cs) with the same partial
class, implementing all the widgets of the visual design.

With this, all the issues are solved and there's no need to parse the source
file because the visual designer is always based on the xml file (just like
the actual behavior).

But, oops.. ok the problem is that this is only supported for C# (because of
the 'partial' keyword)... uhm... so it should be better to have the code in
a hidden #region? (I like partial)...

Ideas?

Juan Cristóbal Olivares
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/monodevelop-list/attachments/20060630/db07a28b/attachment.html 


More information about the Monodevelop-list mailing list