CS-Script 3.2.0


What's New in CS-Script 

This is the combined list of changes in v.3.0.0-3.2.0

Full support for Mono/Linux

CS-Script now has full support on Linux. While even before this release it was possible to execute the C# scripts on Mono only from this version the script engine implementation has been reworked to to bring the same level of support as on Windows. 

Implemented script Precompilers

Precompilation is the feature that allows pre-processing the script code on-fly just before it is passed to the C# compiler. This very simple and yet powerful feature allows very precise control over the script execution. It also allows implementation even such exotic features as DSL or C++ style Macros.

Some fixes for CS-Script Tools for Visual Studio 2010 Extension (CS-Script VS Tools)

Fixed occasional lose of Recent Scripts history content.


Implemented AppDomain extensions

Added AppDomain extension methods for the conveient generic way of executing any arbitrary routine in the temporary AppDoman wollowed by its unloading.

AppDomain remote = AppDomain.CurrentDomain.Clone();
        
remote.Execute(() =>
{
    var Sum = CSScript.BuildEval(@"func(float a, float b) {
                                            return a + b;
                                   }");
                                                
    var Average = CSScript.BuildEval(@"func(float a, float b) {
                                            return (a + b)/2;
                                       }");
                                               
    Console.WriteLine("Sum = {0}\nAverage={1}", Sum(1f, 2f), Average(1f, 2f));
});
       
remote.Unload();


Action job = () =>
        {
            var PrintDiv = CSScript.BuildEval(@"func(float a, float b) {
                                         Console.WriteLine(a/b);
                                     }");
            PrintDiv(999f, 3f);
        };
...
 
AppDomain.CurrentDomain
         .Clone()
         .Execute(job)
         .Unload();


Implemented Eval

Now you can use Eval when implementing hosting scenarios. While it is nothing else but a syntactic sugar it is a convenient option and it can improve code readability as long as you are aware about the limitations.

CSScript.Eval(@"func() {
                    Console.WriteLine(DateTime.Now);
                }"
);

var SayHello = CSScript.BuildEval(@"func(string greeting) {
                                        Console.WriteLine(greeting);
                                    }"
);

SayHello("Hello World!");


Usability improvements

Added unconditional injection of the AssemblyDescriptionAttribute into every script being executed. The attribute value is set to the full file name of the script that it is possible now to query the executing assembly attribute at runtime to find out the script file path.
The file extension of the compiled scripts (in the script cache) are changed from <script>.css to <script>.cs.compiled.
Increased amount of information reported by the script engine when executing the scripts with /verbose switch.
Added ChangeIcon button to the configuration console. It can be used to change the icon associated with the script files (.cs file extension).



Command interface changes

In-code directives
//css_precompiler - Specifies custom precompiler file(s). This can be either script or assembly file (see Precompilers for details).

Command-line switches

/v - Prints CS-Script version information
/precompiler - Specifies custom precompiler file(s). This can be either script or assembly file (see Precompilers for details).

Added new scripts to the Script/Samples Library

- ReflectScript.cs
  Example of how in the script to obtain the information about the script itself (e.g. script file name).