giuspen / cherrytree

cherrytree
https://www.giuspen.net/cherrytree/
Other
3.43k stars 466 forks source link

Executing C# dotnet #2234

Closed Adam-wil closed 1 year ago

Adam-wil commented 1 year ago

Hi Giuspen,

Firstly, great work on CherryTree, its my new NoteBook!

I would like to know how to execute C# from the codeblocks.

Can you help me with some more instructions setting up the preferences / tmp path please. As I understand it please see images below:

To Run the C#

image

Do I need to set the C:\Program Files\CherryTree\mingw64\bin> to the Environment Variable Path ?

image

image

Any help would be appreciated. Cheers Adam

giuspen commented 1 year ago

Hi @Adam-wil The command that you need to write is: csc /out:<tmp_bin_path> <tmp_src_path> && <tmp_bin_path> And a valid Hello World would be:

namespace HelloWorld {
class Hello {
    static void Main(string[] args) {
        System.Console.WriteLine("Hello World!");
    }
}
} // namespace HelloWorld

And if the codebox type is c-sharp and the folder containing csc.exe is in the system Path ( C:\Windows\Microsoft.NET\Framework64\v4.0.30319 ), you will get:

Microsoft (R) Visual C# Compiler version 4.8.4084.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.

This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest version. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240

Hello World!

C:\Program Files\CherryTree\mingw64\bin>
Adam-wil commented 1 year ago

Thanks Guispen,

I managed to get the c-sharp compiling. Saving the snippet as a testc.cs by right clicking the snippet and saving as cs. Then adding it to the file path worked.

WhatsApp Image 2023-03-04 at 14 39 58

Thanks from your help on this! I would love to see the c# be written in .Net 6 or 7 to strip out the namespaces etc.

giuspen commented 1 year ago

No problem I added support command in the default list in upcoming 0.99.55 and a dedicated icon for c-sharp