CS-Script 3.20.0


The way how a script file processed at the execution time is controlled by the scripting engine runtime settings, command line parameters and Script Engine Directives.
Directives are special instructions for the script engine, which can be specified in the script code.

The set of CS-Script directives is the foundation for achieving the advanced level of functionality with scripting. They are the technical base for the implementation of the multi-file scripts, seamless access to COM, WebService, Remoting and initial support for .NET3.0.

It is important to remember that CS-Script is a system based on the ECMA-compliant C#. This means that CS-Script engine does not allow any code in the script which does not comply with C# official syntax. That is why all directives are implemented as code comments. This way script code is not polluted with text, which can prevent compilation with the C# compiler.

The convention is that all directives start with //css.  And currently there are only 4 directives supported (subject of changes for the future versions):
The full description of a particular directive can be found in the corresponding article (follow the directive links).

All directives are duplicated with corresponding shorter aliases (etc. //css_reference and //css_ref).

Any directive is interpreted by C# compiler as a comment.  In order to shield it from the C# compiler a given single directive has to be written as a single line. It also must be placed before any namespace or class declaration.

If you need to use directives in non-C# language specify it as a language specific comment in order to have no impact on compilation by this language compiler. For example for VB preface the directive with VB comment token:

' //css_reference "System.dll";
' //css_reference "System.Windows.Forms.dll";
Imports System
Imports System.Windows.Forms

Module Module1

    Sub Main()
    
    MessageBox.Show("Hello World!")
    End Sub

End Module

Delimiters Escaping

All //css_* directives should escape any internal CS-Script delimiters by doubling the delimiter character. For example //css_include for 'script(today).cs' should escape brackets as they are the directive delimiters. Thus the correct syntax would be as follows '//css_include script((today)).cs;'
The delimiters characters are ';,(){}'. However you should always check CSharpParser.DirectiveDelimiters for the accurate list of the all delimiters.

See Also


Importing scripts | Using .NET assemblies | Pre- and Postscripts | Using Resources