BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News CSI C# Interpreter Supports .NET 4.0

CSI C# Interpreter Supports .NET 4.0

This item in japanese

Bookmarks

CSI is a simple C# interpreter that allows command-line compilation of standalone C# files. A new version has been released that supports .NET 4.0.

CSI accepts an input file and compiles the source code on the fly, finally executing the resulting assembly. This allows with a simple, self-documenting batch file with no project files and no concern for the resulting binary and keeping code changes synchronized.

Sample batch file Hello.cs :

public class Hello
{
	public static void Main()
	{
		System.Console.WriteLine("Hello World");
	}
}

Sample usage:

C:\>CSI Hello.cs
Hello World

There are many options for writing scripts and batch files in the Windows environment, including PowerShell which can also leverage the .NET framework. However, because it is open source, CSI offers more customization of behavior and can support new .NET and C# features more quickly.

CSI 4.0, the version targeting .NET 4.0 relies upon .NET 4 Beta 2 Framework. This version allows scripters to take advantage of the new dynamic type, the push-based IObservable interface, the Tuple class, among the many new features in C# 4.0.

CSI also includes a command script to register the .CSI file type with Windows to execute C# batch files without dropping into a command-line interface. CSI makes executing batch files straightforward with features including executing multiple files in one command and specifying custom references. But CSI is not an interactive shell, not a REPL.

For a true interactive C# shell, like Ruby's IRB, there are other projects providing a REPL compiler service, including the Mono project CsharpRepl

Rate this Article

Adoption
Style

BT