[MonoDevelop] Stetic code generator

"Andrés G. Aragoneses [ knocte ] "Andrés G. Aragoneses [ knocte ]
Fri Jun 30 04:05:04 EDT 2006


Juan Cristóbal Olivares escribió:
> 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 
> <http://VS.NET> 2002/2003)
> 
> But there's other way, taking an approach similar to the VS.NET 
> <http://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?

Hello! These thoughts are very interesting.

I suppose that, if we implement it using partial classes, we would be 
following a similar way to the one of the Visual Studio SWF designer: 
the InitializeComponent method sleeps in a different file. For me this 
seems much greater.

BTW, which languages don't support partial classes? C# and VB.NET 
support it AFAIK. Isn't this part of the ECMA standard? Shouldn't all 
languages implement this possibility (in any syntax manner)?

Regards.

	Andrés G. Aragoneses	[ knocte ]


P.S.: Could be also possible to implement an option for stetic to load 
the XML at runtime instead of generating the graphic interface code at 
compile time (like Glade)?

-- 



More information about the Monodevelop-list mailing list