1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

How to add C# to CodeRunner?

Discussion in 'Mac Programming' started by xEKx, Feb 22, 2012.

  1. macrumors newbie

    #1
    Hi,
    I want to add C# Language to CodeRunner

    How to add it could you guys tell me in detail please

    Thanks in advance :)
     
  2. macrumors G4

    #2
    CodeRunner supports AppleScript, C, C++, Java, Objective-C, Perl, PHP, Ruby, and Shell Script. It does not support C#. If you want C# support in CodeRunner, then you should express your desires to CodeRunner's developer, Nikolai Krill.

    As you are no doubt know, C# is a part of Microsoft's .NET frameworks. I am not aware of the value of C# outside the .NET frameworks. .NET does not exist on MacOS X. However, there is a clone of the .NET frameworks that should be fairly mature now. It is Mono 2.10.8.

    In the best case--the one in which you can actually integrate C# with CodeRunner--you will need to download and install Mono.
     
  3. macrumors newbie

    #3
    Configure C# on CodeRunner using mono

    Configuring CodeRunner to compile and run C# is actually reasonably simple if you have Mono installed (if not, see http://www.go-mono.com/mono-downloads/download.html). Mono includes command line utilities to compile and run C# programs which by default are:

    Compiler: /usr/bin/mcs
    Runtime execution: /usr/bin/mono

    To configure CodeRunner for C#, open the CodeRunner Preferences dialog, go to the "Languages" tab, click the "+" icon and and specify "C#" as the Language name. On the right you have fields where you can populate the language settings. Check the "Language uses compilation script" check box, enter "/usr/bin/mono $compiler" (no quotes) for the Run Command, set the File Extension to "cs" (again, no quotes). Click the "Edit Script..." button and append the following to the compile.sh script (this will open in the CodeRunner editor):

    Code:
    file=$1
    /usr/bin/mcs "$file"
    status=$?
    if [ $status -ne 0 ]
    then
    exit $status
    fi
    echo $file | sed -e "s/\.cs/.exe/"
    exit 0
    
    You can specify a code template like the following if desired:

    Code:
    using System;
    public class MyProgram {
      public static void Main( string[] args ) {
        Console.WriteLine( "Hello, World!" );
      }
    }
    
    CodeRunner doesn't have native syntax highlighting support for C#, but you can select Java as the syntax mode and the syntax highlighting works reasonably well since.
     

Share This Page