|
Download the latest release
What
is CS-Script?
CS-Script is a CLR (Common Language Runtime)
based scripting system which uses ECMA-compliant C# as a programming
language. CS-Script currently targets Microsoft implementation of CLR
(.NET 2.0/3.0/3.5) with limited support on Mono.
CS-Script is an open-source initiative that is
distributed under the license agreement, which can be found here.
However commercial support is also available.
CS-Script combines
the power and richness of C# and FCL with the flexibility of a
scripting system. CS-Script can be useful for system and network
administrators, developers and testers. For any one who needs an
automation for solving variety of programming tasks.
- CS-Script has started as an article at CodeProject but
quickly it has grown past the scale of a single publication. Currently
it is used world wide for extending the applications
functionality
with scripting and as a general purpose scripting environment. It is
used by both enthusiasts and by professional programmers. It
found its way to non-profit organizations
(e.g. educational
institutes) as well as to commercial organizations. These are
just
a few examples: K2
API, SF.net
("WinTin"), BonSAI.
The
main idea of CS-Script is to allow "plain vanilla" C# code execution
from both command-prompt and form any CLR application hosting the
script engine.
Command-prompt
execution:
Explorer view:

hello.cs:
- using System;
- using System.Windows.Forms;
- class Script
- {
- static void Main()
- {
- MessageBox.Show( "Hello World!");
- }
- }
Script hosting execution:
- a. Execution of the script contatining class
definition:
- Assembly assembly = CSScript.LoadCode(
@"using System;
public class Script
{
public static void SayHello(string gritting)
{
Console.WriteLine(gritting);
}
}");
AsmHelper script = new AsmHelper(assembly);
script.Invoke("Script.SayHello", "Hello World!");
- b. Execution of the script contatining method
definition only:
- var
PrintSum = CSScript.LoadMethod(
@"public static void PrintSum(int a, int b)
{
Console.WriteLine((a+b));
}")
.GetStaticMethod();
PrintSum(1, 2);
- or
- Assembly assembly = CSScript.LoadMethod(
@"public static void PrintSum(int a, int b)
{
Console.WriteLine((a+b));
}");
AsmHelper script = new AsmHelper(assembly);
script.Invoke("*.PrintSum", 1, 2);
CS-Script
comes with the full integration with MS Visual Studio including
(intellisense, toolbar buttons/commands, code snippets etc.). Because
of the clever
loading model CLR Debuggers do not differentiate between static and
dynamic code (script).
You can debug your script with the same debugger
as your host application.
CS-Script also brings you Dynamic Code Generation. The
concept, which allows you to define C++ style macros in C#.
CS-Script comes with the full set of comprehensive
documentation (tutorials,
help in both CHM and PDF format, API reference guide).
|
Why
CS-Script? - read about the
difference between CS-Script and other CLR based scripting solutions.
This is what you need to know before making a decision on using the
CS-Script.
|
Benefits of C# Scripting System:
-
Simple deployment approach:
just bring both script and engine file (about 70 K size) on the system
that has .NET runtime installed and script can be run.
-
Portability: Scripts can be
run on any system, which has CLR installed (including Mono).
-
Base language is a truly OO
language: CS-Script
uses full
featured C# and also supports VB.NET,
C++/CLI and J#.
-
All .NET functionality is
available (FCL, COM Interop, Remoting, WPF, WCF etc.).
-
Easily available Debugger and
rich IDE (MS .NET Visual Studio or third-party IDEs).
-
Execution model within the
script is the same as for any .NET application: static void Main().
-
Any script can be
easily
converted into application and vice versa.
-
Optimised interpretation:
interpretation of any statement in the script is done only once even if
the statement is frequently used throughout the code.
-
Script language is type safe
(strongly typed): strong typing is a luxury not available for the most
of the scripting languages.
-
Dynamic typing is also
available: just go with Object as a default type and do boxing/unboxing
all the time.
-
All SW development tasks can
be done in the same language.
-
GUI development for script
application becomes easy.
-
Extensibility: scripting
system can be extended by using new assemblies written in any
.NET languages or COM components.
-
Script hosting: functionality
of any CLR application can be extended with scripting.
See
Features
for more details.
|