Mono / .net related stuff - Monodevelop.sfs

Under development: PCMCIA, wireless, etc.
Message
Author
User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#16 Post by MU »

today we discussed, what kind of final project we might do in the end of the C# course (last week of mai).
One idea I have, is the following. But I am not certain, how far it is doable.

A program, that reads in C# files, and converts them to vala.
So you afterwards could compile native binaries, and would not need .net or mono, to run them.

Limitations:
As I have just 1 week, it is impossible, to convert additional libs.
So WindowsForms or such would be ignored.
It just would convert simple things. Example:

Code: Select all

Console.WriteLine("test");
This would become:

Code: Select all

stdout.printf ("test\n")
So the task would be, to replace several calls to "System" with calls to "GLib".
Usually, such a program will not work immedeatly, you had to convert other things by hand.
But it could simplify the process of porting from C# to vala.

If someone knows, if comparable utilities exist, please let me know.

In the next weeks, I will investigate, if it makes sense for only 1 week or not.
Mark
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

wow
Posts: 1052
Joined: Fri 30 Jun 2006, 00:18
Location: Peru

#17 Post by wow »

Download gnome-2.20.3-test02_400.sfs from:
http://puppyisos.org/wow/puppy4sfs/
user: puppy
passw: linux


I need more time to relink all my stuff to puppyisos.org

(Thanks MU)
[url=http://www.puppylinux.com][img]http://i.imgur.com/M4OyHe1.gif[/img][/url]

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#18 Post by MU »

Thanks for the Link, wow :)

------------------------------------------------------------
I tried to install .NET 3.5 SP in Wine again.
This takes really long in virtalbox.
It crashes, if the Wine version is set to XP.
Set to 2003, it works, but after one hour or so, after all the content was extracted by the installer, it stopped with the message, that I had to install .NET 3.0 SP1 first.
As that is a 2.4 MB zip only, I think it will download files.
Due to security and proxy settings, I cannot access the web from Virtualbox, so my experiments in this diretion will stop now.

------------------------------------------------------------
I also looked again at my project idea csharp2vala.
One bad issue might discourage me, from doing it.
In C#, you can overload methods, in Vala not. This could make it impossible, to wrap functions.

Example:
C#:
you can use:

Code: Select all

Console.WriteLine(string_value);
or

Code: Select all

Console.WriteLine(int_value);
This is called "overloading",
The Console class has 2 methods (18 to be exact) of the same name, but they are different, because they take different types of parameters.
If you try that in Vala, you will get an error, that the method was already defined.

Vala just has:

Code: Select all

print(formatstring , value);
So a converter would need a "scanner", that tries to find out, what type the value has.
Then it had to generate code like

Code: Select all

print("%s" , string_value);
or

Code: Select all

print("%d" , int_value);
So it explicitly must define, what type is printed, so this type had to be found out by the scanner.

As this is not only used by the inbuilt classes, but also by the selfwritten ones, it would be pretty difficult.

I must look a bit deeper into this, before I can make a decision.
Maybe I could use "placeholders", so that the converted code has to be corrected by hand afterwards by the programmer.
Then I would not need the scanner.

Mark
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#19 Post by MU »

I attach a prototype of csharp2vala.
Screenshot see at bottom.

This is far from creating usable code, but my small included example testproject works.

Extract csharp2vala somewhere, then open it in Visual Studio or Monodevelop.

Extract the "testprojects.tgz" in /root/ (or C:\).

In Windows, you must uncomment the path setting in convertprojects.cs at line 28, and comment the Linux path there.

Then run the project.
It creates /root/testprojects/WindowsFormsApplication1/valaout/.
This is a project, that can be loaded in the ValaIDE.

When you compile it, you get 1 error:
"cannot convert from int to string".
So set line 23 in main.vala to:

Code: Select all

            print( "%d\n", i);
This error demontrates well the "overload" problem I described in my last message.

Currently, the WindowsForms are not converted to Gtk, just an empty Gladefile is created.
This is also not included yet in the code.
I also am not certain yet, if it will be possible, to import some elements like buttons. The layout certainly will break completely, but that could be "rearranged" by hand in Glade.
The eventhandlers in Form1.vala are converted already though.

It currently just prints "Hello World!".

So you see: still a lot to be done... well after some free easter days :D

Mark
Attachments
csharp2vala.jpg
(189.9 KiB) Downloaded 642 times
csharp2vala.tar.gz
(53.26 KiB) Downloaded 603 times
testprojects.tar.gz
(66.32 KiB) Downloaded 617 times
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

MUguest
Posts: 73
Joined: Sat 09 Dec 2006, 16:40

#20 Post by MUguest »

Uploaded a bugfix to the download folder of Monodevelpup.

The "Mac" Gtk theme has some entries, that can cause error dialogs.
This effects the filechooser in Valaide.
Monodevelop even crashes because of this.
The bugfix corrects this.

I also fixed the Glade icon, and the gedit starters.
And included a fix, when the desktop options did not save settings.

Mark

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#21 Post by MU »

I added some basic "Winforms to Glade" support to csharp2vala.

It supports buttons and textboxes.
The generated vala project contains the code to load the generated gladefile, and the eventhandlers work.

This has just started, so it will not be usable yet in practice, but the concept works now.
The rest is "just" adding more elements and eventhandlers.

This seems better doable than converting code itself (overloaded classes, polymorphism and other nasty stuff), so for my project in the end of the course, I might focus on the Winforms converter classes.

The screenshot shows the original (C#) on the left, and Vala on the right.
On the right, you see two small application windows.
The left is, what you see right after conversion. The right one was quickly "re-layouted" by hand in Glade afterwards, as layout containers are not converted.

The program now automatically detects, if it runs in Windows or Linux.

Mark
Attachments
testprojects.tar.gz
extract in /root/ or c:\
(66.32 KiB) Downloaded 594 times
csharp2vala05.tar.gz
Open and run in Monodevelop or Visual Studio.
(66.67 KiB) Downloaded 619 times
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

MUguest
Posts: 73
Joined: Sat 09 Dec 2006, 16:40

#22 Post by MUguest »

New csharp2vala06c:

- cleaned up interface for the converter.

- choice, if original code is added as comments or not.

- inlayed vala code.


You can include converterdirectives like
//PCB start
...
//PCB end


means: Preferred Code Block
If this is found, this code is used.

Like this you also can "ignore code":
//ICB start
...
//ICB end


Code surrounded by this directive, will not be converted.

For one-liners, use:
//PC ... yourcode ...

If this directive is found, yourcode will be used instead of the following line.

The screenshot shows Visual Studio with such directives, and ValaIDE with the resulting Vala program.

Mark
Attachments
testprojects.zip
(76.11 KiB) Downloaded 569 times
csharp2vala06c.zip
(72.72 KiB) Downloaded 585 times

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#23 Post by MU »

today only a minor update.
You now have a fileselection dialog, to select another project than the one in /root/testprojects.

This is not well tested yet, but seems to work in Visual Studio (Win) and Monodevelop (Linux).
I had to rewrite several variables, they now are public in the class Form1, not in Convertproject. There was a design error before, that made it not possible to modify them afterwards.

The location of the last project is not "remembered" yet, although it already creates a configfile in ~/.csharp2vala.

Mark
Attachments
csharp2vala07.tar.gz
(79.74 KiB) Downloaded 589 times
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

MUguest
Posts: 73
Joined: Sat 09 Dec 2006, 16:40

#24 Post by MUguest »

09, restructured, each glade element now has an own class.
Added some more elements, and a selected projectfolder now is stored.

Mark
Attachments
csharp2vala09.jpg
(53.79 KiB) Downloaded 1980 times
WindowsFormsTest.zip
(58.47 KiB) Downloaded 666 times
csharp2vala09.zip
(95.49 KiB) Downloaded 678 times

MUguest
Posts: 73
Joined: Sat 09 Dec 2006, 16:40

#25 Post by MUguest »

v10
notes:
notebook pages (Win: tabcontrol) are invisible, if they contain nothing.
So you must put elements in the pages using Glade.

Text boxes need a textbuffer so that you can "do" something with the text.
Same with treeviews, they need a listmodel.
I'd like to add such requirements later automatically generated.

Next week I first will add some more elements, and try to layout them (place the tabcontrol contents inside the notebook pages, and maybe use a "fixed" panel to arrange elements).

Mark
Attachments
WindowsFormsTest.zip
(68.35 KiB) Downloaded 671 times
csharp2vala10b.zip
(105.5 KiB) Downloaded 707 times
csharp2vala10.jpg
(89.33 KiB) Downloaded 767 times

MUguest
Posts: 73
Joined: Sat 09 Dec 2006, 16:40

#26 Post by MUguest »

added more elements:
-menubar (currently empty)
-statusbar
-progressbar
-hbox (flowlayout)
-vbox (flowlayout)
-picturebox
- calendar
-spinbutton
- notebook tabs now use assigned text

Mark
Attachments
csharp2vala11.zip
(126.18 KiB) Downloaded 672 times
WindowsFormsTest.zip
(93.41 KiB) Downloaded 647 times

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#27 Post by MU »

here is version 12.
It has no "visible" advantages, so no need to download it.
I just upload it in order to document, how the project evolves.

I started to add a logic to layout the elements of a winform (but it does not save anything yet!).
The code now gets somewhat complex :roll:

The XML representation of each widget is added to an own arraylist.
These arraylists are managed by two other arraylists.
So they can be "resorted" lateron.


Then a "layout()" method begins to sort out (using the xml lists and the original winforms file), what widget is a child of another widget.
In this step, also positioning informations are added.
This part is not finished yet, as visible on the screenshot.

Once the whole "chains" of inheritance are created, the previously generated xml lists can be re-combined on base of this structure.

A special case are elements, that are placed directly on the "rootwindow".
They may be placed absolutely (like on a GtkFixed), or using a table layout like in the Java Swing BorderLayout.
Each tablecell itself can be separated again, so you can put a menubar and a toolbar on top of the window, and they scale to the wiindowsize.
I included a "rootwindow.glade", that simulates this with hboxes/vboxes.
I later must integrate such a layout for the rootwindow.

Another issue:
a SplitContainer has 2 panels in Winforms.
In Gtk, it has none, these must e defined in addition.
So I had to hack in somewhere the generation of these panels.
It is solved a bit ugly, but well...
I will continue on monday.

Mark
Attachments
csharp2vala12.jpg
(92.96 KiB) Downloaded 1713 times
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

mymas
Posts: 3
Joined: Sun 29 Mar 2009, 14:07
Location: japan

#28 Post by mymas »

hi, I try to use csharp2vala.

http://live.gnome.org/Vala/GladeSample

I look at this glade sample code. and then add --pkg option
but, receive fellowing error...

C:\testprojects\WindowsFormsTest\valaout>valac main.vala Form1.vala Class1.vala
--pkg gtk+-2.0 --pkg libglade-2.0 --pkg gmodule-2.0
main.vala:14.17-14.36: warning: local variable `form1' declared but never used
var form1 = new Form1 ();
^^^^^^^^^^^^^^^^^^^^
Form1.c: In function `windows_forms_test_form1_construct':
Form1.c:31: error: `GladeXML' undeclared (first use in this function)
Form1.c:31: error: (Each undeclared identifier is reported only once
Form1.c:31: error: for each function it appears in.)
Form1.c:31: error: `xml' undeclared (first use in this function)
error: cc exited with status 1
Compilation failed: 1 error(s), 1 warning(s)

my develop environment:

Windows XP Home sp3
vala 0.61 http://code.google.com/p/valide/downloads/list

download glade source
glade sourve http://ftp.gnome.org/pub/GNOME/sources/ ... 2.2.tar.gz

copy to
C:\vala-0.6.1\include\glade

My --pkg option is wrong? I don't know correct --pkg option.
thanks. regard.

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#29 Post by MU »

download glade source
glade sourve http://ftp.gnome.org/pub/GNOME/sources/ ... 2.2.tar.gz

copy to
C:\vala-0.6.1\include\glade
No, this is not sufficient.
You need the libglade dlls.

http://dotpups.de/puppy4/dotpups/Progra ... alog32.zip

Extract it to C:\vala-0.6.1\
It includes libglade compiled for Windows.

I uploaded the vala packages I use in Windows here:
http://dotpups.de/puppy4/dotpups/Progra ... r-Windows/
The readme.txt explains how I use them.

If it does not work, I can test it again in a fresh setup.
Mark
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

mymas
Posts: 3
Joined: Sun 29 Mar 2009, 14:07
Location: japan

#30 Post by mymas »

Mu, Thanks very much. It's works.
No problem =)

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#31 Post by MU »

8)

Next week I have 3 days left to fix the bugs I added by rewriting code to get the automatic layouting to work.

E.g. splitpanels mess up project.glade, so that glade refuses to load it.

The screenshot shows a small testprogram running in Visual Studio (C#, Winforms, Windows XP) and right after conversion in Vala-IDE (Vala/Gtk2, Newyearspup).
I did not edit the converted project in Glade - it started out of the box like this after compilation in the Vala-IDE.

A download follows friday in 1 week after the presentation.
Mark
Attachments
csharp2vala15.jpg
(169.85 KiB) Downloaded 753 times
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

MUguest
Posts: 73
Joined: Sat 09 Dec 2006, 16:40

#32 Post by MUguest »

:D

I did NOT alter the resulting Window in Glade :!:
It is directly compiled and run after conversion :P

You just had to resize some elements for a "perfect" result, that takes 1 minute.

Tomorrow I will have a look, if I can convert menus.

Mark
Attachments
csharp2vala16e.zip
(161 KiB) Downloaded 705 times
csharp2vala16d-mini.jpg
(29.03 KiB) Downloaded 2173 times
csharp2vala16d.jpg
(100.98 KiB) Downloaded 805 times

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#33 Post by MU »

This is almost the "final" state, as I have just 1 day left to finish the project.

I added support for menus, even nested submenus work.
The menu and the statusbar will be not placed in the "fixed" widget, but in a vbox, so they expand with the window.

All other elements now are sized.
In most cases this gives better results than before.
Just flowlayouts look strange then, and must be adjusted by hand in Glade (see the bottom left corner, where the button is expanded).

Tomorrow I plan:
- add a scrolled-window to surround textboxes,
- remove unneeded properties (they throw warnings when the program runs - not critical, but it would look more professional to avoid them).
- if a menubar is available, move all elements on the "fixed" sligtly up.
I cannot gurantee, that I'll have success with every point.

I plan to announce the program in a Mono Mailinglist or so, so that it can be continued by other people.
Even if they are not interested in Vla - the Winforms to Glade feature is great for C#, too (Monodelop, Glade#).

Myself I will concentrate on Genie programming, and do not plan to extend it further on my own.
You still could add "thousands" of enhancements (more widgets, convert more than one form, ...), and it would take several weeks or even months, to implement all of this.

Mark
Attachments
csharp2vala17-mini.jpg
(42.06 KiB) Downloaded 1923 times
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#34 Post by MU »

Here is the final release.

I improved the import of multiline text, added scrolledwindows to textboxes, shadows to the treeviews.

If a menu is used, the elements are moved up to get the original aspect ratios.

Mark
Attachments
csharp2vala18mini.jpg
(36.98 KiB) Downloaded 1936 times
csharp2vala18.jpg
(134.87 KiB) Downloaded 720 times
WindowsFormsTest.zip
(105.52 KiB) Downloaded 573 times
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#35 Post by MU »

here are the final files I used for the presentation.
Still need to set up a webpage and translate fies to english...

http://dotpups.de/csharp2vala/

Mark
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

Post Reply