To synthesize C# code for the HelloWorld example, execute the following command:
scc -lcsharp HelloWorld.des
HelloWorld.cs is generated and the following message is printed out to the console:
----- Time spent on compilation: 0.007 (sec) File(s) generated: HelloWorld.cs ----- Command to compile the source: mcs -main:HelloWorld HelloWorld.cs (with Mono) csc /main:HelloWorld HelloWorld.cs (with .Net Framework SDK) Command to run the compiled code: mono HelloWorld.exe (with Mono) HelloWorld.exe (with .Net Framework) -----
This tells the user how to compile the source and execute the program in Linux and Windows.
Mono (a C# compiler and run-time environment) must be installed. It is downloadable from:
To compile the C# source generated by SCC, execute the following command:
mcs -main:HelloWorld HelloWorld.csHere, the -main parameter is specified on the command-line, which tells Mono the entrance of the program is in class HelloWorld. (The entrance is the Main method of the class.) This is necessary because, if the model imports other components, C# classes are also generated for those components by SCC in the same source file. In that case, there will be multiple Main methods, and the user must explicitly specify only one class on the Mono command-line with the -main parameter.
After compilation, HelloWorld.exe is produced. It is a valid Windows executable, but in Linux, it must be executed with the support of Mono:
mono HelloWorld.exe(Note: this executable may be executed in Windows with Microsoft .Net Framework installed.)
Microsoft .Net SDK (Software Development Kit) is required to compile HelloWorld.cs in Windows. The SDK is downloadable from:
To compile the C# source, execute the following command:
csc /main:HelloWorld HelloWorld.csSimilar to Mono, .Net SDK generates HelloWorld.exe. The executable can be directly executed in Windows, but it requires .Net Framework, which is included in the SDK. The end users who only want to run the executable model may download .Net Framework only from the download website of Microsoft.
The execution result of the C# program is as following:
Hello World Example ['A'] > e ['B'] > exit
Currently the -ext parameter is not supported for the C# target language. All the action code and guards in the model are ignored.