Graduate to C# from Small Basic - Featured Article

LitDev wrote this fantastic article about graduating to C# from Small Basic:

Small Basic: Graduate to C#

 

 

Here is an except from that article:

 

 

Conversion

First we create a Small Basic exe and then convert it to a Visual Studio project.

Create a Small Basic exe

The first thing we need is a compiled Small Basic exe.  For this example I use quite a complex one using the LitDev extension; the sample creating a 3D maze game.  You can do this with any Small Basic exe, but I chose a large complex one for demonstration and test purposes.

To create the Small Basic exe, simply save and run the program in the Small Basic IDE.  Once compiled, there will be an exe created in the same directory as your Small Basic *.sb source code.  For this example the exe file is LD3DMazeGame.exe.

Convert to VS project

Next start ILSpy and open the generated Small Basic exe using File->Open and navigate to the exe (LD3DMazeGame.exe).  You can also just drag the exe into the left pane of ILSpy from Windows Explorer.

The code for the opened .Net file will be available for viewing in ILSpy, but we just want to export the whole thing as a Visual Studio project.

Ensure that the code visualisation is set to C# (the default), select the exe project on the list of .Net assemblies (left pane).

Then click File->Save Code... to save it somewhere.  I suggest a new folder somewhere.

Once saved, ILSpy then gives you the option to open this folder, which you can do, or navigate to it in Explorer.  There should be 2 files here:

  • _SmallBasicProgram.cs
  • LD3DMazeGame.csproj

It is convenient at this stage to also copy all required extension dlls and SmallBasicLibrary.dll to this folder.  These dlls can be found in the same folder as your compiled Small Basic exe.  In my case this is just 2:

  • SmallBasicLibrary.dll
  • LitDev.dll

 

 

==================================

 

 

Thanks again to LitDev for this great contribution. Go check out the full article:

 

Small Basic: Graduate to C#

 

 

Enjoy!

 

   - Ninja Ed