Skip to content

Instantly share code, notes, and snippets.

@magicianzrh
Forked from adambyram/C# Template
Last active August 29, 2015 14:20
Show Gist options
  • Save magicianzrh/17a357500a3b1692aa9b to your computer and use it in GitHub Desktop.
Save magicianzrh/17a357500a3b1692aa9b to your computer and use it in GitHub Desktop.
using System;
namespace CodeRunner
{
class MainClass
{
public static void Main (string[] args)
{
Console.WriteLine ("Hello World!");
}
}
}
To support C# in CodeRunner:
1) Install the Mono runtime
2) CodeRunner -> Preferences
3) Switch to the Language tab
4) Use the "+" to add a "C#" entry
5) Check "Language uses compilation script"
6) Set the Run Command to "mono $compiler"
7) Set the code template to the "C# Template" below
8) Set syntax mode to Generic
9) Set file extension to "cs"
10) Click "Edit Script"
11) Paste in the compile.sh file contents below
12) Save the updated compile.sh
That's it. This is a *very* basic setup. It doesn't handle failure if your code doesn't compile, it doesn't handle adding assembly references, or anything else. If you need any of that, you'll need to update the compile.sh file,
#!/bin/bash
# This is a CodeRunner compilation script. Compilation scripts are used to
# compile code before being run using the run command specified in CodeRunner
# preferences. This script should have the following properties:
#
# Launch directory ($PWD): Will be the same as the file being run
#
# Exit status: Should be 0 on success (will cause CodeRunner
# to continue and execute the run command)
#
# Output (stdout): On success, one line of text which can be accessed
# using the $compiler variable in the run command
#
# Output (stderr): Anything outputted here will be displayed in
# the CodeRunner console
#
# Arguments: $1 Filename of the source file
# $2 Encoding of the source file
# $3 Compilation flags set in CodeRunner preferences
# $4 Path of a temporary directory (without / suffix)
#
# The encoding argument may be used to specify to the compiler which encoding
# the source file uses. It will be one of the integers in the following array:
enc[4]="UTF8" # UTF-8
enc[10]="UTF16" # UTF-16
enc[5]="ISO8859-1" # ISO Latin 1
enc[9]="ISO8859-2" # ISO Latin 2
enc[30]="MacRoman" # Mac OS Roman
enc[12]="CP1252" # Windows Latin 1
enc[3]="EUCJIS" # Japanese (EUC)
enc[8]="SJIS" # Japanese (Shift JIS)
enc[1]="ASCII" # ASCII
file=$1
file=${file/\.cs/\.exe}
mcs "$1"
echo "$file"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment