diff --git a/bin/choco/cs-script.4.0.0.0.nupkg b/bin/choco/cs-script.4.0.0.0.nupkg deleted file mode 100644 index 6901a253..00000000 Binary files a/bin/choco/cs-script.4.0.0.0.nupkg and /dev/null differ diff --git a/bin/choco/cs-script.4.0.1.0.nupkg b/bin/choco/cs-script.4.0.1.0.nupkg deleted file mode 100644 index cf586e8e..00000000 Binary files a/bin/choco/cs-script.4.0.1.0.nupkg and /dev/null differ diff --git a/bin/linux/ubuntu/OBSOLETE.MONO-BUILD b/bin/linux/ubuntu/OBSOLETE.MONO-BUILD deleted file mode 100644 index e69de29b..00000000 diff --git a/bin/linux/ubuntu/build/cs-script_3.27.5.0/-update.cs b/bin/linux/ubuntu/build/cs-script_3.27.5.0/-update.cs deleted file mode 100644 index 6d611e1f..00000000 --- a/bin/linux/ubuntu/build/cs-script_3.27.5.0/-update.cs +++ /dev/null @@ -1,102 +0,0 @@ -//css_args -ac, -inmem -using System; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Net; -using System.Text; - -static string rootUrl = "http://oleg-shilo.github.io/cs-script/linux/ubuntu/"; -static string versionUrl = rootUrl + "/version.txt"; -static string help = @"Install/Update CS-Script with the latest Ubuntu package available from product GitHub repository. - -i (or no args) - installs the latest version of cs-script package - -u - uninstalls the cs-script package from the system - -? - show command's help - -ver - print latest available version - -check - check if any updates are available"; - -void main(string[] args) -{ - if (args.LastOrDefault() == "-?") - { - Console.WriteLine(help); - } - else if (args.LastOrDefault() == "-ver") - { - Console.WriteLine("Checking the latest available version..."); - Console.WriteLine("Latest available version: " + versionUrl.DownloadString()); - } - else if (args.LastOrDefault() == "-check") - { - Console.WriteLine("Checking the latest available version..."); - Console.WriteLine("Latest available version: " + versionUrl.DownloadString()); - Console.WriteLine("You have version: " + Environment.GetEnvironmentVariable("CSScriptRuntime")); - } - else if (args.LastOrDefault() == "-u") - { - Console.WriteLine("Uninstalling package: 'sudo dpkg --purge cs-script'"); - Process.Start("dpkg", "--purge cs-script") - .WaitForExit(); - } - else if (args.FirstOrDefault() == "-i" || args.Count() == 0) - { - if (Environment.UserName != "root") - { - Console.WriteLine("error: requested operation requires superuser privilege"); - } - else - { - Console.WriteLine("Checking the latest available version..."); - - var version = versionUrl.DownloadString(); - - if (version == Environment.GetEnvironmentVariable("CSScriptRuntime")) - { - Console.WriteLine("You already have the latest version. Do you want to reinstall it?\n [Y]es/[N]o"); - - var response = Console.ReadLine(); - - if (response != "Y" && response != "y") - return; - } - - var packageUrl = rootUrl + "/cs-script_" + version + "_all.deb"; - Console.WriteLine("Downloading " + packageUrl + " ..."); - - // install: sodo dpkg -i cs-script_3.27.2.1.deb - // uninstall: sudo dpkg --purge cs-script - - string package = packageUrl.DownloadFile(); - var cmd = "-i " + Path.GetFileName(package); - - Console.WriteLine("Installing package: 'dpkg" + cmd + "'"); - Process.Start("dpkg", cmd) - .WaitForExit(); - } - } - else - Console.WriteLine("Unknown command"); -} - -//css_ac_end -static class Web -{ - public static string DownloadString(this string url) - { - var temp = Path.GetTempFileName(); - - try - { - new WebClient().DownloadFile(url, temp); - return File.ReadAllText(temp); - } - finally { File.Delete(temp); } - } - - public static string DownloadFile(this string url, string outFile = null) - { - outFile = outFile ?? (Path.GetFileName(url)); - new WebClient().DownloadFile(url, outFile); - return Path.GetFullPath(outFile); - } -} \ No newline at end of file diff --git a/bin/linux/ubuntu/build/cs-script_3.27.5.0/CSSRoslynProvider.dll b/bin/linux/ubuntu/build/cs-script_3.27.5.0/CSSRoslynProvider.dll deleted file mode 100644 index 90b27cc7..00000000 Binary files a/bin/linux/ubuntu/build/cs-script_3.27.5.0/CSSRoslynProvider.dll and /dev/null differ diff --git a/bin/linux/ubuntu/build/cs-script_3.27.5.0/cscs.exe b/bin/linux/ubuntu/build/cs-script_3.27.5.0/cscs.exe deleted file mode 100644 index c8538b83..00000000 Binary files a/bin/linux/ubuntu/build/cs-script_3.27.5.0/cscs.exe and /dev/null differ diff --git a/bin/linux/ubuntu/build/debian/README b/bin/linux/ubuntu/build/debian/README deleted file mode 100644 index c0f85720..00000000 --- a/bin/linux/ubuntu/build/debian/README +++ /dev/null @@ -1,6 +0,0 @@ -The Debian Package cs-script ----------------------------- - -Comments regarding the Package - - -- Oleg Shilo Mon, 14 Aug 2017 16:16:27 +1000 diff --git a/bin/linux/ubuntu/build/debian/changelog b/bin/linux/ubuntu/build/debian/changelog deleted file mode 100644 index f7d8cc71..00000000 --- a/bin/linux/ubuntu/build/debian/changelog +++ /dev/null @@ -1,6 +0,0 @@ -cs-script (3.28.9.0) stable; urgency=medium - - * Initial Release. - * Second Release. - - -- Oleg Shilo (Oleg Shilo) Sun, 16 Jun 2019 10:19:09 +1000 \ No newline at end of file diff --git a/bin/linux/ubuntu/build/debian/changelog.template b/bin/linux/ubuntu/build/debian/changelog.template deleted file mode 100644 index 6d6cd714..00000000 --- a/bin/linux/ubuntu/build/debian/changelog.template +++ /dev/null @@ -1,6 +0,0 @@ -cs-script (${version}) stable; urgency=medium - - * Initial Release. - * Second Release. - - -- Oleg Shilo (Oleg Shilo) ${date} \ No newline at end of file diff --git a/bin/linux/ubuntu/build/debian/compat b/bin/linux/ubuntu/build/debian/compat deleted file mode 100644 index ec635144..00000000 --- a/bin/linux/ubuntu/build/debian/compat +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/bin/linux/ubuntu/build/debian/control b/bin/linux/ubuntu/build/debian/control deleted file mode 100644 index 446bf5ff..00000000 --- a/bin/linux/ubuntu/build/debian/control +++ /dev/null @@ -1,16 +0,0 @@ -Source: cs-script -Section: devel -Priority: optional -Maintainer: Oleg Shilo -Build-Depends: debhelper (>=9) -Standards-Version: 3.9.6 -Homepage: https://github.com/oleg-shilo/cs-script -#Vcs-Git: https://github.com/oleg-shilo/cs-script -#Vcs-Browser: https://github.com/oleg-shilo/cs-script - -Package: cs-script -Architecture: all -Depends: ${misc:Depends} -Description: C# scripting runtime environment - CS-Script is a CLR (Common Language Runtime) based scripting system, - which uses ECMA-compliant C# as a programming language. diff --git a/bin/linux/ubuntu/build/debian/copyright b/bin/linux/ubuntu/build/debian/copyright deleted file mode 100644 index f30e3be4..00000000 --- a/bin/linux/ubuntu/build/debian/copyright +++ /dev/null @@ -1,25 +0,0 @@ -Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: cs-script -Source: https://github.com/oleg-shilo/cs-script - -Files: * -The MIT License (MIT) - -Copyright (c) 2017 oleg-shilo - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE diff --git a/bin/linux/ubuntu/build/debian/cs-script-docs.docs b/bin/linux/ubuntu/build/debian/cs-script-docs.docs deleted file mode 100644 index a25c234d..00000000 --- a/bin/linux/ubuntu/build/debian/cs-script-docs.docs +++ /dev/null @@ -1,3 +0,0 @@ -README -README.source -README.Debian diff --git a/bin/linux/ubuntu/build/debian/cs-script.links b/bin/linux/ubuntu/build/debian/cs-script.links deleted file mode 100644 index 4769941b..00000000 --- a/bin/linux/ubuntu/build/debian/cs-script.links +++ /dev/null @@ -1 +0,0 @@ -/usr/local/bin/cs-script/cscs.exe /usr/local/bin/cscs diff --git a/bin/linux/ubuntu/build/debian/cs-script.substvars b/bin/linux/ubuntu/build/debian/cs-script.substvars deleted file mode 100644 index 978fc8b5..00000000 --- a/bin/linux/ubuntu/build/debian/cs-script.substvars +++ /dev/null @@ -1,2 +0,0 @@ -misc:Depends= -misc:Pre-Depends= diff --git a/bin/linux/ubuntu/build/debian/debhelper-build-stamp b/bin/linux/ubuntu/build/debian/debhelper-build-stamp deleted file mode 100644 index 70046b33..00000000 --- a/bin/linux/ubuntu/build/debian/debhelper-build-stamp +++ /dev/null @@ -1 +0,0 @@ -cs-script diff --git a/bin/linux/ubuntu/build/debian/files b/bin/linux/ubuntu/build/debian/files deleted file mode 100644 index ffa49048..00000000 --- a/bin/linux/ubuntu/build/debian/files +++ /dev/null @@ -1 +0,0 @@ -cs-script_3.27.5.0_all.deb devel optional diff --git a/bin/linux/ubuntu/build/debian/install b/bin/linux/ubuntu/build/debian/install deleted file mode 100644 index bd4fc5fa..00000000 --- a/bin/linux/ubuntu/build/debian/install +++ /dev/null @@ -1 +0,0 @@ -cs-script_3.28.9.0/* /usr/local/bin/cs-script diff --git a/bin/linux/ubuntu/build/debian/install.template b/bin/linux/ubuntu/build/debian/install.template deleted file mode 100644 index 42c088ea..00000000 --- a/bin/linux/ubuntu/build/debian/install.template +++ /dev/null @@ -1 +0,0 @@ -cs-script_${version}/* /usr/local/bin/cs-script diff --git a/bin/linux/ubuntu/build/debian/postinst b/bin/linux/ubuntu/build/debian/postinst deleted file mode 100644 index cc3f6a8d..00000000 --- a/bin/linux/ubuntu/build/debian/postinst +++ /dev/null @@ -1 +0,0 @@ -alias css='dotnet /usr/local/bin/cs-script/cscs.dll' diff --git a/bin/linux/ubuntu/build/debian/rules b/bin/linux/ubuntu/build/debian/rules deleted file mode 100644 index cc8760c2..00000000 --- a/bin/linux/ubuntu/build/debian/rules +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/make -f -# See debhelper(7) (uncomment to enable) -# output every command that modifies files on the build system. -#export DH_VERBOSE = 1 - - -# see FEATURE AREAS in dpkg-buildflags(1) -#export DEB_BUILD_MAINT_OPTIONS = hardening=+all - -# see ENVIRONMENT in dpkg-buildflags(1) -# package maintainers to append CFLAGS -#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic -# package maintainers to append LDFLAGS -#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed - -# to let to install into /usr/local/* ; for some reason debuild does not like user to install in /usr/local -# good discussion: https://stackoverflow.com/questions/7459644/why-is-dh-usrlocal-throwing-a-build-error - -override_dh_usrlocal: - -%: - dh $@ - - -# dh_make generated override targets -# This is example for Cmake (See https://bugs.debian.org/641051 ) -#override_dh_auto_configure: -# dh_auto_configure -- # -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) - diff --git a/bin/linux/ubuntu/build/debian/source/format b/bin/linux/ubuntu/build/debian/source/format deleted file mode 100644 index 89ae9db8..00000000 --- a/bin/linux/ubuntu/build/debian/source/format +++ /dev/null @@ -1 +0,0 @@ -3.0 (native) diff --git a/bin/linux/ubuntu/build/prepare_package_sources.cs b/bin/linux/ubuntu/build/prepare_package_sources.cs deleted file mode 100644 index 6ef6d199..00000000 --- a/bin/linux/ubuntu/build/prepare_package_sources.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System.Diagnostics; -using System.IO; -using System.Linq; -using System; - -class Script -{ - static public void Main() - { - var version = "3.28.9.0"; - - var src_dir = Path.GetFullPath(@"..\..\..\..\..\..\Releases\v" + version + @"\bin\lib\Bin\Linux"); - var dest_dir = $"cs-script_{version}"; - - void copy(string file, string new_file_name = null) - { - var s = Path.Combine(src_dir, file); - var d = Path.Combine(dest_dir, new_file_name ?? file); - Console.WriteLine("Copying:\n\t" + s + "\n\t" + d); - File.Copy(s, d, true); - } - - void generate_from_template(string file, Func generator) - { - File.WriteAllText(file, generator(File.ReadAllText(file + ".template"))); - Process.Start(editor, file); - } - - Directory.CreateDirectory(dest_dir); - copy("CSSRoslynProvider.dll"); - copy("cscs.exe"); - copy("-update.deb.cs", "-update.cs"); - - File.WriteAllText(@"..\version.txt", version); - - // Mon, 14 Aug 2017 16:16:27 +1000 - var timestamp = $"{DateTime.Now:ddd, d MMM yyyy hh:mm:ss} " + $"{DateTime.Now:zzz} ".Replace(":", ""); - - generate_from_template(@"debian\changelog", - text => text.Replace("${version}", version) - .Replace("${date}", timestamp)); - - generate_from_template(@"debian\install", - text => text.Replace("${version}", version)); - - Process.Start(editor, "readme.md"); - Process.Start("7z.exe", @"a -r -tzip .\..\build.zip .\*"); - - Console.WriteLine("====================="); - Console.WriteLine("Prepared for building package cs-script_" + version); - Console.WriteLine("The build folder '.\\..\\build.zip' is ready."); - } - - static string editor = @"E:\Program Files\Sublime Text 3\sublime_text.exe"; -} \ No newline at end of file diff --git a/bin/linux/ubuntu/build/readme.md b/bin/linux/ubuntu/build/readme.md deleted file mode 100644 index a1870c13..00000000 --- a/bin/linux/ubuntu/build/readme.md +++ /dev/null @@ -1,24 +0,0 @@ -For any new build: - -1. Build and pack the release - -2. Prepare package sources by executing `prepare_package_sources.cs`. It will in turn: - - update `install` with the location of the path to the files to be included in the package - - update `changelog` with the new version and release notes - -3. Copy entire `build` folder on Ubuntu.
- IMPORTANT: do not copy files via VMware tools (drag-n-drop) as it screws the files. Instead: - - - zip the build directory (done by `prepare_package_sources.cs`) - - copy (drag-n-drop) build.zip file to the guest system - - unzip files on the guest system - -4. From the build folder in the terminal execute `debuild -b` - - - Test the package: - - sudo dpkg --purge cs-script - - sudo dpkg -i ../cs-script_*.deb (or specify the version instead of *) - -5. Copy cs-script*.deb package back to Win - -6. Commit to the GitHub diff --git a/bin/linux/ubuntu/cs-script_3.27.2.1.deb b/bin/linux/ubuntu/cs-script_3.27.2.1.deb deleted file mode 100644 index 7ffabb2f..00000000 Binary files a/bin/linux/ubuntu/cs-script_3.27.2.1.deb and /dev/null differ diff --git a/bin/linux/ubuntu/cs-script_3.27.5.0_all.deb b/bin/linux/ubuntu/cs-script_3.27.5.0_all.deb deleted file mode 100644 index a29e1cd9..00000000 Binary files a/bin/linux/ubuntu/cs-script_3.27.5.0_all.deb and /dev/null differ diff --git a/bin/linux/ubuntu/cs-script_3.28.8.0_all.deb b/bin/linux/ubuntu/cs-script_3.28.8.0_all.deb deleted file mode 100644 index c9400a77..00000000 Binary files a/bin/linux/ubuntu/cs-script_3.28.8.0_all.deb and /dev/null differ diff --git a/bin/linux/ubuntu/version.txt b/bin/linux/ubuntu/version.txt deleted file mode 100644 index 9922b48c..00000000 --- a/bin/linux/ubuntu/version.txt +++ /dev/null @@ -1 +0,0 @@ -3.28.9.0 \ No newline at end of file diff --git a/src/BuildServer/out/build.runtimeconfig.json b/src/BuildServer/out/build.runtimeconfig.json index d7845156..becfaeac 100644 --- a/src/BuildServer/out/build.runtimeconfig.json +++ b/src/BuildServer/out/build.runtimeconfig.json @@ -6,7 +6,6 @@ "version": "8.0.0" }, "configProperties": { - "System.Reflection.Metadata.MetadataUpdater.IsSupported": false, "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false } } diff --git a/src/CSScriptLib/src/CSScriptLib/CSScriptLib.csproj b/src/CSScriptLib/src/CSScriptLib/CSScriptLib.csproj index f909e4b8..096b2adf 100644 --- a/src/CSScriptLib/src/CSScriptLib/CSScriptLib.csproj +++ b/src/CSScriptLib/src/CSScriptLib/CSScriptLib.csproj @@ -14,7 +14,7 @@ true snupkg true - 4.8.13.0 + 2024.1.1.1 Oleg Shilo CS-Script engine Class Library for .NET 5 (and higher) (C) 2018-2023 Oleg Shilo @@ -36,8 +36,8 @@ - CSScriptLib is signed now true - 4.8.13.0 - 4.8.13.0 + 2024.1.1.1 + 2024.1.1.1 MIT css_logo.png True @@ -86,8 +86,8 @@ - - + + diff --git a/src/CSScriptLib/src/CSScriptLib/CSScriptLib.xml b/src/CSScriptLib/src/CSScriptLib/CSScriptLib.xml new file mode 100644 index 00000000..2d76a337 --- /dev/null +++ b/src/CSScriptLib/src/CSScriptLib/CSScriptLib.xml @@ -0,0 +1,3763 @@ + + + + CSScriptLib + + + + + Very light parser for C# code. The main purpose of it is to be very fast and reliable. + It only extracts code information relative to the CS-Script. + + + + + Class to hold the script information on what pre- or post-execution script needs to be executed. + pre- and post-script CS-Script command format: + //css_prescript file([arg0][, arg1]..[,arg2])[,ignore]; + //file - script file (extension is optional) + //arg0..N - script string arguments; + If $this is specified as arg0..N it will be replaced with the parent script full name at execution time. + + + + + Creates an instance of CmdScriptInfo. + + CS-Script pre- or post-script directive + If set to true the 'statement' is a pre-script otherwise it is a post-script. + The file name of the main script. + + + + Script file and it's arguments. + + + + + If set to 'true' the CmdScriptInfo describes the pre-script, otherwise it is for the post-script. + + + + + If set to 'true' parent script will be aborted on pre/post-script error, otherwise the error will be ignored. + + + + + Class to hold the script initialization information. + + + + + The boolean flag indicating if CoInitializeSecurity (with default parameters) should be called at the start of the script execution. + + + + + The RpcImpLevel of CoInitializeSecurity arguments + + + + + The EoAuthnCap of CoInitializeSecurity arguments + + + + + Initializes a new instance of the class. + + The original argument statement of the //css_init directive. + + + + Class to hold the script importing information, which actually controls how script is imported. + + + + + Creates an instance of ImportInfo. + + CS-Script import directive (//css_import...) string. + name of the parent (primary) script file. + + + + The file to be imported. + + + + + Renaming instructions (old_name vs. new_name) + + + + + If set to 'true' "static...Main" in the imported script is not renamed. + + + + + Initializes a new instance of the class. + + + + + Creates an instance of CSharpParser. + + C# code string + + + + Creates an instance of CSharpParser. + + C# script (code or file). + If set to 'true' the script is a file, otherwise it is a C# code. + + + + Creates an instance of CSharpParser. + + C# script (code or file). + If set to 'true' the script is a file, otherwise it is a C# code. + Additional C# script directives to search. The search result is stored in CSharpParser.CustomDirectives. + + + + Creates an instance of CSharpParser. + + C# script (code or file). + If set to 'true' the script is a file, otherwise it is a C# code. + Additional C# script directives to search. The search result is stored in CSharpParser.CustomDirectives. + Search directories for resolving wild card paths in //css_inc and //css_imp + + + + The result of search for additional C# script directives to search (directive vs. value). + + + + + Global flag to forcefuly supress any C# code analysys. This flag efectively disables + all CS-Script assembly and script probing and most likely some other functionality. + You may ever want to suppress code analysis only for profiling purposes or during performance tuning. + + + + + Parses the C# code. + + C# script (code or file). + If set to 'true' the script is a file, otherwise it is a C# code. + Additional C# script directives to search. The search result is stored in CSharpParser.CustomDirectives. + Search directories for resolving wild card paths in //css_inc and //css_imp + + + + Renames namespaces according renaming instructions. + + Renaming instructions (old_name vs. new_name). + /// If set to 'true' "static...Main" in the imported script is not renamed. + + + + Embedded script arguments. The both script and engine arguments are allowed except "/noconfig" engine command line switch. + + + + + Embedded compiler options. + + + + + Embedded compiler options. + + + + + Precompilers. + + + + + References to the external assemblies and namespaces. + + + + + References to the external assemblies. + + + + + Names of namespaces to be ignored by namespace-to-assembly resolver. + + + + + Additional search directories (for script and assembly probing). + + + + + References to the resource files. + + + + + References to the namespaces. + + + + + References to the NuGet packages. + + + + + C# scripts to be imported. + + + + + Pre- and post-execution scripts. + + + + + Script initialization directives. + + + + + Script C# raw code. + + + + + Script C# code after namespace renaming. + + + + + Enables omitting closing character (";") for CS-Script directives (e.g. "//css_ref System.Xml.dll" instead of "//css_ref System.Xml.dll;"). + + + + + Escapes the CS-Script directive (e.g. //css_*) delimiters. + 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. + The correct syntax would be as follows '//css_include script((today)).cs;' + The delimiters characters are ';,(){}'. + However you should check for the accurate list of all delimiters. + + + + The text to be processed. + The escaped string. + + + + Replaces the user escaped delimiters with internal escaping. +

"{char}{char}" -> "\u{((int)c).ToString("x4")}"

+

"((" -> "\u0028"

+ +
+ The text. + The escaped string. +
+ + + Unescapes the CS-Script directive (e.g. //css_*) delimiters. + 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. + The correct syntax would be as follows '//css_include script((today)).cs;' + The delimiters characters are ';,(){}'. + However you should check for the accurate list of all delimiters. + + + + The text to be processed. + The unescaped string. + + + + The //css_* directive delimiters. + 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. + The correct syntax would be as follows '//css_include script((today)).cs;' + + + + + + Contains the name of the temporary cache folder in the CSSCRIPT subfolder of Path.GetTempPath(). The cache folder is specific for every script file. + + + + + Generates the name of the cache directory for the specified script file. + + Script file name. + Cache directory name. + + + + Settings is an class that holds CS-Script application settings. + + + + + Loads and returns the settings instance. + + + + + Gets the default configuration file path. It is a "css_config.xml" file located in the same directory where the assembly + being executed is (e.g. cscs.exe). + + + The default configuration file location. Returns null if the file is not found. + + + + + List of directories to be used to search (probing) for referenced assemblies and script files. + This setting is similar to the system environment variable PATH. + + + + + Gets or sets the default reference assemblies. + + + The default reference assemblies. + + + + + Clears the search directories. + + The Settings instance. + + + + Adds the search directories aggregated from the unique locations of all assemblies referenced by the host application. + + The dir. + The Settings instance + + + + Adds the search dirs from host application. + The dirs are the list of locations the all currently loaded assemblies are loaded from. + + The Settings instance + + + + Class which is implements CS-Script class library interface. + + + + + Starts the build server. + + + + + Stops the build server. + + + + + Gets the CSScript., which controls the way code evaluation is conducted at runtime. + + The evaluator CSScript.. + + + + Global instance of the generic . This object is to be used for + dynamic loading of the C# code by "compiler as service" based on the + value. + Generic interface provides a convenient way of accessing + compilers without 'committing' to a specific compiler technology (e.g. Mono, Roslyn, CodeDOM). This may be + required during troubleshooting or performance tuning. + Switching between compilers can be done via global + CSScript.. + + By default CSScript. always returns a new instance of + . If this behavior is undesired change the evaluator access + policy by setting .Access value. + + + The instance. + + + if(testingWithMono) + CSScript.EvaluatorConfig.Engine = EvaluatorEngine.Mono; + else + CSScript.EvaluatorConfig.Engine = EvaluatorEngine.Roslyn; + + var sub = CSScript.Evaluator + .LoadDelegate<Func<int, int, int>>( + @"int Sub(int a, int b) { + return a - b; + }"); + + + + + + Returns the name of the temporary folder in the CSSCRIPT subfolder of Path.GetTempPath(). + Under certain circumstances it may be desirable to the use the alternative location for the CS-Script temporary files. + In such cases use SetScriptTempDir() to set the alternative location. + + + Temporary directory name. + + + + Returns the name of the temporary file in the CSSCRIPT subfolder of Path.GetTempPath(). + + Temporary file name. + + + + Settings object containing runtime settings, which controls script compilation/execution. + This is Settings class essentially is a deserialized content of the CS-Script configuration file (css_config.xml). + + + + + Global instance of . This object is to be used for + dynamic loading of the C# code by using Roslyn "compiler as service". + If you need to use multiple instances of th evaluator then you will need to call + .Clone(). + + + The instance. + + + + Global instance of . This object is to be used for + dynamic loading of the C# code by using CodeDom "compiler as service". + If you need to use multiple instances of th evaluator then you will need to call + .Clone(). + + + The instance. + + + + Controls if ScriptCache should be used when script file loading is requested (CSScript.Load(...)). If set to true and the script file was previously compiled and already loaded + the script engine will use that compiled script from the cache instead of compiling it again. + Note the script cache is always maintained by the script engine. The CacheEnabled property only indicates if the cached script should be used or not when CSScript.Load(...) method is called. + + + + + Notes the temporary file to be removed on application exit. + + The file. + + + + Starts the purging old temporary files. + + if set to true [ignore current process scripts]. + + + + Class implementing CodeDom favor of (csc.exe/csc.dll) + + + + + + The flag indicating if the compilation should happen on the build server or locally. + + + + + Timeout for the C# CLI compiler `csc.exe`. + + This compiler is a part of .NET SDK and it is the actual + tool that compiles C# code into assembly when CodeDomEvaluator is used. + This tool under certain circumstances has tendency to hang after even if it successfully + finished the compilation. Thus configurable timeout allows user to configure forcible termination + of the csc.exe process. + + + The default value is -1 (infinite). + + + + + The low level output of the last script compilation. This member is not designed to be a + part of script error handling. For this purpose a normal exception based mechanism the + is a more appropriate choice. + + on another hand is great for troubleshooting problems + associated with the low level completion. IE non script specific failures of csc.exe. + + + + + + Validates the specified information. + + The information. + + CompileInfo.RootClass property should only be used with Roslyn evaluator as " + "it + addresses the limitation associated with Roslyn. Specifically wrapping ALL scripts in + the illegally " + "named parent class. You are using CodeDomEvaluator so you should not + set CompileInfo.RootClass to any custom value + + + + + Compiles the specified script text. + + The script text. + The script file. + The information. + The method result. + + + + References the given assembly. + + It is safe to call this method multiple times for the same assembly. If the assembly + already referenced it will not be referenced again. + + + The assembly instance. + + The instance of the to allow fluent interface. + + + Current version of {EngineName} doesn't support referencing assemblies " + "which are + not loaded from the file location. + + + + + Gets the referenced assemblies files. + + The method result. + + + + Loads and returns set of referenced assemblies. + Notre: the set of assemblies is cleared on Reset. + + The method result. + + + + The information about the location of the compiler output - assembly and pdb file. + + + + + Gets or sets the compiler options for csc.exe. + + This property is only applicable for CodeDOM based script execution as Roslyn engine does + not accept string options for compilation. + + + The compiler options. + + + + The assembly file path. If not specified it will be composed as "<RootClass>.dll". + + + + + The PDB file path. + + Even if the this value is specified the file will not be generated unless .DebugBuild is set to true. + + + + + + Gets or sets the root class name. + + This setting is required as Roslyn cannot produce compiled scripts with the user script + class defined as a top level class. Thus all user defined classes are in fact nested + classes with the root class named by Roslyn as "Submission#0". This leads to the + complications when user wants to reference script class in another script. Specifically + because C# treats "Submission#0" as an illegal class name. + + + C# helps the situation by allowing user specified root name , which is by default is "css_root". + + + The root class name. + + + + Gets or sets the name of the assembly to be built from the script. + + + The name of the assembly. + + + + + Gets or sets the loaded script assembly. + This member is set to the script assembly loaded in the calling ppDomain. + It is particularly useful when you need access the script assembly (e.g. to unload it) + but it is unavailable to the caller because the evaluation expression does not return any result (`void`). + + + The loaded assembly. + + + + + Gets or sets a value indicating whether to prefer loading compiled script from the + assembly file when it is available. + + true if [prefer loading from file]; otherwise, false. + + + + Gets or sets the kind of the script code. This property is used to control the way Roslyn engine is compiling the script code. + + By default it is used for processing the scripts the same way as .cs/.vb files. + While used for processing the scripts as a canonical single file script with the + top-level code. + + + The is the code kind that is used by setting which is + the only API supported in the .NET applications published as single-file. Though this value can also be used in other Roslyn + evaluator scenarios too (e.g. ). + + + + + The kind of the code. + + + + + The exception that is thrown when a the script compiler error occurs. + + + + + Gets or sets the error count associated with the last script compilation. + + The error count. + + + + Initialises a new instance of the class. + + + + + Initialises a new instance of the class. + + The object that holds the serialized object data. + The contextual information about the source or destination. + + + + Initializes a new instance of the class. + + The message. + + + + Initializes a new instance of the class. + + The message. + The exception. + + + + Creates the CompilerException instance from the specified compiler errors. + + The compiler errors. + if set to true hide compiler warnings. + + if set to true all references to the path of the derived auto-generated files + (e.g. errors in the decorated classless scripts) will be replaced with the path of the + original files (e.g. classless script itself). + + The method result. + + + + + + + + + Loads and returns set of referenced assemblies. + Notre: the set of assemblies is cleared on Reset. + + The method result. + + + + Gets or sets the compiler settings. + + The compiler settings. + + + + Loads the assemblies implementing Roslyn compilers. + + Roslyn compilers are extremely heavy and loading the compiler assemblies for with the + first evaluation call can take a significant time to complete (in some cases up to 4 + seconds) while the consequent calls are very fast. + + + You may want to call this method to pre-load the compiler assembly your script + evaluation performance. + + + + + + Compiles the specified script text. + + The script text. + The script file. + The information. + The method result. + + + + + References the given assembly. + + It is safe to call this method multiple times for the same assembly. If the assembly + already referenced it will not be referenced again. + + + The assembly instance. + + The instance of the to allow fluent interface. + + + Current version of {EngineName} doesn't support referencing assemblies " + "which are + not loaded from the file location. + + + + + Evaluates (executes) the specified script text, which is a top-level C# code. + It is the most direct equivalent of "eval" available in dynamic languages. This method is only + available for Roslyn evaluator. + You can evaluate simple expressions: + + var result = CSScript.Evaluator.Eval("1 + 2"); + + Or it can be a complex script, which defines its own types: + + var calc = CSScript.Evaluator + .Eval(@"using System; + public class Script + { + public int Sum(int a, int b) + { + return a+b; + } + } + + return new Script();"); + int sum = calc.Sum(1, 2); + + + Note compiles and executes the script in the current AppDoman. + All AppDomain loaded assemblies of the AppDomain being referenced from the script regardless of + setting. + During the script compilation, this method uses: + + CompileInfo.CodeKind=Microsoft.CodeAnalysis.SourceCodeKind.Script. + + This is the only option that supports script execution for applications published with + PublishSingleFile option. + + This method is the only option that supports script execution for applications published with + PublishSingleFile option. + + The script text. + + The object returned by the script. + + This method is only available for Roslyn evaluator. + Script entry point method could be found. + + + + Evals the specified script text. + + + The script text. + The information. + + + This method is only available for Roslyn evaluator. + or + The parameter `{nameof(info)}.{nameof(info.CodeKind)}` must be set to `{nameof(SourceCodeKind.Script)}`. + + Script entry point method could be found. + + + + Resets Evaluator. + + Resetting means clearing all referenced assemblies, recreating evaluation infrastructure + (e.g. compiler setting) and reconnection to or recreation of the underlying compiling services. + + + Optionally the default current AppDomain assemblies can be referenced automatically with + . + + + + if set to true the default assemblies of the current AppDomain will be referenced + (see method). + + The freshly initialized instance of the . + + + + A wrapper class that encapsulates the functionality of the Roslyn evaluator ( ). + + + + + Clones itself as . + + This method returns a freshly initialized copy of the . The cloning 'depth' can be controlled by the . + + + This method is a convenient technique when multiple + instances are required (e.g. for concurrent script evaluation). + + + + if set to true all referenced assemblies from the parent will be referenced in the cloned copy. + + The freshly initialized instance of the . + + + + Gets or sets a value indicating whether to compile script with debug symbols. + + Note, setting DebugBuild will only affect the current instance of Evaluator. If + you want to emit debug symbols for all instances of Evaluator then use .DebugBuild. + + + true if 'debug build'; otherwise, false. + + + + Gets a value indicating whether this instance is debug. + + true if this instance is debug; otherwise, false. + + + + Initializes a new instance of the class. + + + + + Evaluates (compiles) C# code (script). The C# code is a typical C# code containing a single or multiple class definition(s). + + + + Assembly asm = CSScript.RoslynEvaluator + .CompileCode(@"using System; + public class Script + { + public int Sum(int a, int b) + { + return a+b; + } + }"); + + dynamic script = asm.CreateObject("*"); + var result = script.Sum(7, 3); + + + The C# script text. + The compiled assembly. + + + + Evaluates (compiles) C# code (script). The C# code is a typical C# code containing a + single or multiple class definition(s). + + The method is identical to + except that it allows specifying the destination assembly file with object. + + + + + var info = new CompileInfo + { + AssemblyFile = @"E:\temp\asm.dll" + }; + + Assembly asm = CSScript.Evaluator + .Cast<RoslynEvaluator>() + .CompileCode(@"using System; + public class Script + { + public int Sum(int a, int b) + { + return a+b; + } + }", + info); + + dynamic script = asm.CreateObject("*"); + var result = script.Sum(7, 3); + + + The C# script text. + + The compiled assembly. + + + + Validates the specified information. + + The information. + + + + CS-Script assembly unloading functionality is implemented as a combination of loading + assembly into that is marked as "IsCollectible" and + the ReflectionExtensions. extension method. Unloading is + only available on the runtimes that support it. Otherwise throws an exception on attempt to load the compiled script assembly. + + is designed to allow enabling/disabling of the + assembly unloading should you find that the limitations associated with this .NET Core + specific feature are not acceptable. E.g., collectible assemblies cannot be referenced + from other scripts or in fact any dynamically loaded assembly for that matter. + + + Due to the limitations (though minor) of the underlying .NET Core feature is set to false by default. + + + + + + This property controls script caching. + Caching mechanism allows avoiding multiple compilation of the scripts that have been already compiled and has not changes + since then for the duration of the host process. This feature can dramatically improve the performance in the cases when you are executing + the same script again and again. Even though in such cases caching is not the greatest optimization that can be achieved. + Note that caching has some limitations. Thus the algorithm for checking if the script is changed since the last execution + is limited to verifying the script code (text) only. Thus it needs to be used with caution. + Script caching is disabled by default. + + The following is an example of caching the compilation. + + dynamic printerScript = CSScript.Evaluator + .With(eval => eval.IsCachingEnabled = true) + .LoadFile(script_file); + printerScript.Print(); + + + + + + Returns set of referenced assemblies. + Notre: the set of assemblies is cleared on Reset. + + The method result. + + + + + Gets the referenced assemblies files. + + The method result. + + + + + Compiles C# file (script) into assembly file. The C# contains typical C# code containing + a single or multiple class definition(s). + + The C# script file. + The path to the assembly file to be compiled. + The compiled assembly file path. + + + string asmFile = CSScript.Evaluator + .CompileAssemblyFromFile("MyScript.cs", "MyScript.dll"); + + + + + + Compiles C# code (script) into assembly file. The C# code is a typical C# code containing a single or multiple class definition(s). + + + + string asmFile = CSScript.Evaluator + .CompileAssemblyFromCode( + @"using System; + public class Script + { + public int Sum(int a, int b) + { + return a+b; + } + }", + "MyScript.dll"); + + + The C# script text. + The path to the assembly file to be compiled. + The compiled assembly file path. + + + + Compiles the specified script text without loading it into the AppDomain or + writing to the file system. + + + + try + { + CSScript.Evaluator + .Check(@"using System; + public class Script + { + public int Sum(int a, int b) + { + error + return a+b; + } + }"); + } + catch (Exception e) + { + Console.WriteLine("Compile error: " + e.Message); + } + + + The script text. + + + + Compiles the specified script text. + + The script text. + The script file. + The information. + The method result. + + + + + Wraps C# code fragment into auto-generated class (type name DynamicClass) and evaluates it. + + This method is a logical equivalent of but is allows you to define + your script class by specifying class method instead of whole class declaration. + + + + dynamic script = CSScript.RoslynEvaluator + .CompileMethod(@"int Sum(int a, int b) + { + return a+b; + }") + .CreateObject("*"); + + var result = script.Sum(7, 3); + + + The C# code. + The compiled assembly. + + + + Wraps C# code fragment into auto-generated class (type name DynamicClass), + evaluates it and loads the class to the current AppDomain. + + Returns non-typed for class-less style of invoking. + + + + + var log = CSScript.Evaluator + .CreateDelegate(@"void Log(string message) + { + Console.WriteLine(message); + }"); + + log("Test message"); + + + The C# code. + The instance of a non-typed + + + + Wraps C# code fragment into auto-generated class (type name DynamicClass), + evaluates it and loads the class to the current AppDomain. + + Returns typed for class-less style of invoking. + + + The delegate return type. + + + var product = CSScript.RoslynEvaluator + .CreateDelegate<int>(@"int Product(int a, int b) + { + return a * b; + }"); + + int result = product(3, 2); + + + The C# code. + The instance of a typed + + + + Analyses the script code and returns set of locations for the assemblies referenced from + the code with CS-Script directives (//css_ref). + + The script code. + The assembly search/probing directories. + Array of the referenced assemblies + + + + Analyses the script file code and returns set of locations for the assemblies referenced from + the code with CS-Script directives (//css_ref). + + The script file. + The assembly search/probing directories. + + Array of the referenced assemblies + + + + + Evaluates and loads C# code to the current AppDomain. Returns instance of the first class defined in the code. + + The following is the simple example of the LoadCode usage: + + dynamic script = CSScript.RoslynEvaluator + .LoadCode(@"using System; + public class Script + { + public int Sum(int a, int b) + { + return a+b; + } + }"); + int result = script.Sum(1, 2); + + + The C# script text. + The non default constructor arguments. + Instance of the class defined in the script. + + + + Evaluates and loads C# code to the current AppDomain. Returns instance of the first + class defined in the code. + + + The type of the script class instance should be type casted to. + + The C# script text. + The non default type T constructor arguments. + Aligned to the T interface instance of the class defined in the script. + + The following is the simple example of the interface alignment: + + public interface ICalc + { + int Sum(int a, int b); + } + .... + ICalc calc = CSScript.Evaluator + .LoadCode<ICalc>(@"using System; + public class Script + { + public int Sum(int a, int b) + { + return a+b; + } + }"); + int result = calc.Sum(1, 2); + + + + + + Wraps C# code fragment into auto-generated class (type name DynamicClass), + evaluates it and loads the class to the current AppDomain. + + Returns instance of T delegate for the first method in the auto-generated class. + + + + + var Product = CSScript.Evaluator + .LoadDelegate<Func<int, int, int>>( + @"int Product(int a, int b) + { + return a * b; + }"); + + int result = Product(3, 2); + + + The C# code. + Instance of T delegate. + + + + Evaluates and loads C# code from the specified file to the current AppDomain. Returns instance of the first + class defined in the script file assembly. + + Note, the order of the classes in the script assembly is not may not be your script imports other scripts. + In such cases you may prefer using or + instead. + + + The C# script file. + Optional non-default constructor arguments. + + Instance of the class defined in the script file assembly. + + The following is the simple example of the interface alignment: + + dynamic script = CSScript.Evaluator.LoadFile("calc.cs"); + int result = script.Sum(1, 2); + + + + + Evaluates and loads C# code from the specified file to the current AppDomain. Returns instance of the first + class defined in the script file assembly. + + After initializing the class instance it is aligned to the interface specified by the parameter T. + Note: the script class does not have to inherit from the T parameter as the proxy type + will be generated anyway. + Note, the order of the classes in the script assembly is not may not be your script imports other scripts. + In such cases you may prefer using or + instead. + + + The type of the interface type the script class instance should be aligned to. + The C# script text. + Optional non-default constructor arguments. + + Aligned to the T interface instance of the class defined in the script file assembly. + + The following is the simple example of the interface alignment: + + public interface ICalc + { + int Sum(int a, int b); + } + .... + ICalc calc = CSScript.Evaluator + .LoadFile<ICalc>("calc.cs"); + int result = calc.Sum(1, 2); + + + + + Wraps C# code fragment into auto-generated class (type name DynamicClass), + evaluates it and loads the class to the current AppDomain. + + + The following is the simple example of the LoadMethod usage: + + dynamic script = CSScript.RoslynEvaluator + .LoadMethod(@"int Product(int a, int b) + { + return a * b; + }"); + + int result = script.Product(3, 2); + + + The C# script text. + Instance of the first class defined in the script. + + + + Wraps C# code fragment into auto-generated class (type name DynamicClass), + evaluates it and loads the class to the current AppDomain. + + After initializing the class instance it is aligned to the interface specified by the + parameter T. + + + + The following is the simple example of the interface alignment: + + public interface ICalc + { + int Sum(int a, int b); + int Div(int a, int b); + } + .... + ICalc script = CSScript.RoslynEvaluator + .LoadMethod<ICalc>(@"public int Sum(int a, int b) + { + return a + b; + } + public int Div(int a, int b) + { + return a/b; + }"); + int result = script.Div(15, 3); + + + + The type of the interface type the script class instance should be aligned to. + + The C# script text. + + Aligned to the T interface instance of the auto-generated class defined in the script. + + + + + Gets or sets the flag indicating if the script code should be analyzed and the + assemblies that the script depend on (via '//css_...' and 'using ...' directives) should + be referenced. + + + + + + References the assemblies from the script code. + + The method analyses and tries to resolve CS-Script directives (e.g. '//css_ref') and + 'used' namespaces based on the optional search directories. + + + The script code. + The assembly search/probing directories. + + The instance of the to allow fluent interface. + + + + + References the given assembly by the assembly path. + + It is safe to call this method multiple times for the same assembly. If the assembly + already referenced it will not be referenced again. + + + The path to the assembly file. + + The instance of the to allow fluent interface. + + + + + Gets the name of the engine (e.g. 'csc' or 'dotnet'). + + The name of the engine. + + + + References the given assembly. + + It is safe to call this method multiple times for the same assembly. If the assembly + already referenced it will not be referenced again. + + + The assembly instance. + + The instance of the to allow fluent interface. + + + + + References the name of the assembly by its partial name. + + Note that the referenced assembly will be loaded into the host AppDomain in order to + resolve assembly partial name. + + It is an equivalent of Evaluator.ReferenceAssembly(Assembly.Load(assemblyPartialName)) + + Name of the assembly. + + The instance of the to allow fluent interface. + + + + + References the assembly by the given namespace it implements. + + The namespace. + + Set to true if the namespace was successfully resolved (found) and the reference + was added; otherwise, false. + + + The instance of the to allow fluent interface. + + + + + References the assembly by the given namespace it implements. + + Adds assembly reference if the namespace was successfully resolved (found) and, + otherwise does nothing + + + The namespace. + + The instance of the to allow fluent interface. + + + + + The filter assemblies + + + + + Sets the filter for referenced assemblies. The filter is to be applied just before the + assemblies are to be referenced during the script execution. + + dynamic script = CSScript.Evaluator + .SetRefAssemblyFilter(asms => + asms.Where(a => !a.FullName.StartsWith("Microsoft.")) + .LoadCode(scriptCode); + + + The filter. + + + + + References the assembly by the object, which belongs to this assembly. + + It is safe to call this method multiple times for the same assembly. If the assembly + already referenced it will not be referenced again. + + + The object, which belongs to the assembly to be referenced. + + The instance of the to allow fluent interface. + + + + + References the assembly by the object, which belongs to this assembly. + + It is safe to call this method multiple times for the same assembly. If the assembly + already referenced it will not be referenced again. + + + The type which is implemented in the assembly to be referenced. + + The instance of the to allow fluent interface. + + + + + References the assemblies the are already loaded into the current AppDomain. + + The type of assemblies to be referenced. + + The instance of the to allow fluent interface. + + + + + Resets Evaluator. + + Resetting means clearing all referenced assemblies, recreating evaluation infrastructure + (e.g. compiler setting) and reconnection to or recreation of the underlying compiling services. + + + Optionally the default current AppDomain assemblies can be referenced automatically with + . + + + + if set to true the default assemblies of the current AppDomain will be referenced + (see method). + + The freshly initialized instance of the . + + + + Compiles C# file (script) into assembly file according the compiling context + specified in the argument. + Note, value will be ignored since the + script engine will only build the assembly without loading it. + + The C# script file. + The information about compilation context (e.g. location of the compiler output - + assembly and pdb file). + + The compiled assembly file path. + + + + + Evaluates (executes) the specified script text, which is a top-level C# code. + It is the most direct equivalent of "eval" available in dynamic languages. This method is only + available for Roslyn evaluator. + You can evaluate simple expressions: + + var result = CSScript.Evaluator.Eval("1 + 2"); + + Or it can be a complex script, which defines its own types: + + var calc = CSScript.Evaluator + .Eval(@"using System; + public class Script + { + public int Sum(int a, int b) + { + return a+b; + } + } + return new Script();"); + int sum = calc.Sum(1, 2); + + + Note compiles and executes the script in the current AppDoman. + All AppDomain loaded assemblies of the AppDomain being referenced from the script regardless of + setting. + During the script compilation, this method uses: + + CompileInfo.CodeKind=Microsoft.CodeAnalysis.SourceCodeKind.Script. + + This is the only option that supports script execution for applications published with + PublishSingleFile option. + + + The script text. + + The object returned by the script. + + + + + + Delegate which is used as a return type for AsmHelper.GetMethodInvoker(). + + AsmHelper.GetStaticMethod() and AsmHelper.GetMethod() allow obtaining dynamic method + delegate emitted on the base of the MethodInfo (from the compiled script type). + + Optional method parameters. + Returns MethodInfo return value + + + + Delegate which is used as a return type for AsmHelper.GetMethodInvoker(). + + AsmHelper.GetStaticMethod() and AsmHelper.GetMethod() allow obtaining dynamic method + delegate emitted on the base of the MethodInfo (from the compiled script type). + + The delegate return type. + Optional method parameters. + Returns MethodInfo return value + + + + Delegate implementing cs script statement expansion. + + The text to expand. + Returns a string with each statement variable replaced by its value. + + + + Type of the assemblies to be loaded/referenced. + + + + + No assemblies + + + + + All static current AppDomain assemblies + + + + + All static and non-GAC current AppDomain assemblies + + + + + All current AppDomain assemblies + + + + + Type of the evaluator engine. + + This enum is used to control type of compiler the generic CSScript. encapsulates. + + + + + + Roslyn compilation services + + + + + CodeDom compilation infrastructure + + + + + Runtime instantiation model for CS-Script evaluators (e.g CSScript. ). + + + + + Every time the member variable is accessed the same static object is returned. + + + + + Every time the member variable is accessed a new object is created. + + + + + Class that contains configuration options for controlling dynamic code evaluation with + CSScript. . + + + + + Gets or sets the default access type for CS-Script evaluators. + + This property controls the how the generic CS-Script evaluators are instantiated when + accessed (e.g. CSScript. or ). + + + The access. + + + + Default value of the . DebugBuild property + controlling the generation of the debug symbols. + In case of evaluator setting this property to true + will also set conditional compiling symbol `DEBUG`. + + CSScript.EvaluatorConfig.DebugBuild = true; + dynamic script = CSScript.Evaluator + .LoadMethod(... + + + + + + + Gets or sets the compiler options. Since out of two supported compilers (for hosting scenarios) only CodeDom engine (csc.exe) + supports options effectively this property is a user specified string of CLI arguments for `csc.exe`. + If you want to specify compiler options per script execution then you can use . + + + The compiler options. + + + + + Gets or sets the PDB format. This property is only used if is set to true. + + + The PDB format. + + + + + Flag that controls if the host AppDo,main referenced assemblies are automatically + referenced at creation of . + + + + + Flag that controls if the host AppDomain referenced assemblies are automatically + referenced at creation of . + Note, the assemblies are getting referenced with an automatic call + with the default argument. + This may not be consistent with your intend. If it is the case then it is recommended that you call + with the desired argument explicitly. + + + + + Gets or sets the default evaluator engine type. + + This property controls the type of compiler the generic CSScript. encapsulates. + + + The default evaluator engine. + + + + Defines a custom algorithm how to expand script code. The default implementation + calls but a host application + might define a more complex algorithm. + + + + + + + + + A generic interface of the CS-Script evaluator. It encapsulates the generic functionality of + the evaluator regardless of the nature of the underlying compiling services (e.g. Mono, + Roslyn, CodeDom). + + + + + Gets or sets a value indicating whether to compile script with debug symbols. + + Note, setting DebugBuild will only affect the current instance of Evaluator. If + you want to emit debug symbols for all instances of Evaluator then use .DebugBuild. + + + true if 'debug build'; otherwise, false. + + + + CS-Script assembly unloading functionality is implemented as a combination of loading + assembly into that is marked as + "IsCollectible" and the ReflectionExtensions. extension method. + Unloading is only available on the runtimes that support it. Otherwise throws an exception on attempt to + load the compiled script assembly. + + is designed to allow enabling/disabling of the + assembly unloading should you find that the limitations associated with this .NET Core + specific feature are not acceptable. E.g., collectible assemblies cannot be referenced + from other scripts or in fact any dynamically loaded assembly for that matter. + + + Note, using 'dynamic` completely breaks CLR unloading mechanism. Most likely it triggers + an accidental referencing of the assembly or . Meaning that if you are planing to + use assembly unloading you need to use interface based scripting. See `Test_Unloading` + (https://github.com/oleg-shilo/cs-script/blob/master/src/CSScriptLib/src/Client.NET-Core/Program.cs) + sample for details. + + + + + + This property controls script caching. + Caching mechanism allows avoiding multiple compilation of the scripts that have been already compiled and has not changes + since then for the duration of the host process. This feature can dramatically improve the performance in the cases when you are executing + the same script again and again. Even though in such cases caching is not the greatest optimization that can be achieved. + Note that caching has some limitations. Thus the algorithm for checking if the script is changed since the last execution + is limited to verifying the script code (text) only. Thus it needs to be used with caution. + Script caching is disabled by default. + + The following is an example of caching the compilation. + + dynamic printerScript = CSScript.Evaluator + .With(eval => eval.IsCachingEnabled = true) + .LoadFile(script_file); + printerScript.Print(); + + + + + + Gets or sets the flag indicating if the script code should be analyzed and the + assemblies that the script depend on (via '//css_...' and 'using ...' directives) should + be referenced. + + + + + + Evaluates (compiles) C# code (script). The C# code is a typical C# code containing a single or multiple class definition(s). + + + + Assembly asm = CSScript.Evaluator + .CompileCode(@"using System; + public class Script + { + public int Sum(int a, int b) + { + return a+b; + } + }"); + + dynamic script = asm.CreateObject("*"); + var result = script.Sum(7, 3); + + + The C# script text. + The information about compilation context (e.g. location of the compiler output - + assembly and pdb file). + The compiled assembly. + + + + Compiles the specified script text without loading it into the AppDomain or + writing to the file system. + + + + try + { + CSScript.Evaluator + .Check(@"using System; + public class Script + { + public int Sum(int a, int b) + { + error + return a+b; + } + }"); + } + catch (Exception e) + { + Console.WriteLine("Compile error: " + e.Message); + } + + + The script text. + + + + Compiles C# code (script) into assembly file. The C# code is a typical C# code containing a single or multiple class definition(s). + + + + string asmFile = CSScript.Evaluator + .CompileAssemblyFromCode( + @"using System; + public class Script + { + public int Sum(int a, int b) + { + return a+b; + } + }", + "MyScript.dll"); + + + The C# script text. + The path to the assembly file to be compiled. + The compiled assembly file path. + + + + Compiles C# file (script) into assembly file. The C# contains typical C# code containing a single or multiple class definition(s). + + + + string asmFile = CSScript.Evaluator + .CompileAssemblyFromFile( + "MyScript.cs", + "MyScript.dll"); + + + The C# script file. + The path to the assembly file to be compiled. + The compiled assembly file path. + + + + Compiles C# file (script) into assembly file according the compiling context + specified in the argument. + Note, value will be ignored since the + script engine will only build the assembly without loading it. + + The C# script file. + The information about compilation context (e.g. location of the compiler output - + assembly and pdb file). + The compiled assembly file path. + + + + Wraps C# code fragment into auto-generated class (type name DynamicClass) and evaluates it. + + This method is a logical equivalent of but is allows you to define + your script class by specifying class method instead of whole class declaration. + + + + dynamic script = CSScript.Evaluator + .CompileMethod(@"int Sum(int a, int b) + { + return a+b; + }") + .CreateObject("*"); + + var result = script.Sum(7, 3); + + + The C# code. + The compiled assembly. + + + + Sets the filter for referenced assemblies. The filter is to be applied just before the + assemblies are to be referenced during the script execution. + + dynamic script = CSScript.Evaluator + .SetRefAssemblyFilter(asms => + asms.Where(a => !a.FullName.StartsWith("Microsoft.")) + .LoadCode(scriptCode); + + + The filter. + + + + + Wraps C# code fragment into auto-generated class (type name DynamicClass), + evaluates it and loads the class to the current AppDomain. + + Returns non-typed for class-less style of invoking. + + + + + var log = CSScript.Evaluator + .CreateDelegate(@"void Log(string message) + { + Console.WriteLine(message); + }"); + + log("Test message"); + + + The C# code. + The instance of a 'duck typed' + + + + Wraps C# code fragment into auto-generated class (type name DynamicClass), + evaluates it and loads the class to the current AppDomain. + + Returns typed for class-less style of invoking. + + + The delegate return type. + + + var product = CSScript.Evaluator + .CreateDelegate<int>(@"int Product(int a, int b) + { + return a * b; + }"); + + int result = product(3, 2); + + + The C# code. + The instance of a typed + + + + Analyses the script code and returns set of locations for the assemblies referenced from + the code with CS-Script directives (//css_ref). + + The script code. + The assembly search/probing directories. + Array of the referenced assemblies + + + + Returns set of referenced assemblies. + Notre: the set of assemblies is cleared on Reset. + + The method result. + + + + Evaluates and loads C# code to the current AppDomain. Returns instance of the first class defined in the code. + + The following is the simple example of the LoadCode usage: + + dynamic script = CSScript.Evaluator + .LoadCode(@"using System; + public class Script + { + public int Sum(int a, int b) + { + return a+b; + } + }"); + int result = script.Sum(1, 2); + + + The C# script text. + The non default constructor arguments. + Instance of the class defined in the script. + + + + Evaluates and loads C# code to the current AppDomain. Returns instance of the first class defined in the code. + + The following is the simple example of the interface alignment: + + public interface ICalc + { + int Sum(int a, int b); + } + .... + ICalc calc = CSScript.Evaluator + .LoadCode<ICalc>(@"using System; + public class Script + { + public int Sum(int a, int b) + { + return a+b; + } + }"); + int result = calc.Sum(1, 2); + + + The type of the script class instance should be type casted to. + The C# script text. + The non default type T constructor arguments. + Type-casted to the T interface instance of the class defined in the script. + + + + Evaluates (executes) the specified script text, which is a top-level C# code. + It is the most direct equivalent of "eval" available in dynamic languages. This method is only + available for Roslyn evaluator. + You can evaluate simple expressions: + + var result = CSScript.Evaluator.Eval("1 + 2"); + + Or it can be a complex script, which defines its own types: + + var calc = CSScript.Evaluator + .Eval(@"using System; + public class Script + { + public int Sum(int a, int b) + { + return a+b; + } + } + + return new Script();"); + + int sum = calc.Sum(1, 2); + + + Note compiles and executes the script in the current AppDoman. + All AppDomain loaded assemblies of the AppDomain being referenced from the script regardless of + setting. + During the script compilation, this method uses: + + CompileInfo.CodeKind=Microsoft.CodeAnalysis.SourceCodeKind.Script. + + This is the only option that supports script execution for applications published with + PublishSingleFile option. + + + The script text. + The object returned by the script. + + + + Wraps C# code fragment into auto-generated class (type name DynamicClass), + evaluates it and loads the class to the current AppDomain. + + Returns instance of T delegate for the first method in the auto-generated class. + + + + + var Product = CSScript.Evaluator + .LoadDelegate<Func<int, int, int>>( + @"int Product(int a, int b) + { + return a * b; + }"); + + int result = Product(3, 2); + + + The C# code. + Instance of T delegate. + + + + Evaluates and loads C# code from the specified file to the current AppDomain. Returns instance of the first + class defined in the script file assembly. + + Note, the order of the classes in the script assembly is not may not be your script imports other scripts. + In such cases you may prefer using or + instead. + + + The following is the simple example of the interface alignment: + + dynamic script = CSScript.Evaluator + .LoadFile("calc.cs"); + + int result = script.Sum(1, 2); + + + The C# script file. + Optional non-default constructor arguments. + Instance of the class defined in the script file assembly. + + + + Evaluates and loads C# code from the specified file to the current AppDomain. Returns instance of the first + class defined in the script file assembly. + + After initializing the class instance it is aligned to the interface specified by the parameter T. + Note: the script class does not have to inherit from the T parameter as the proxy type + will be generated anyway. + + + Note, the order of the classes in the script assembly is not may not be your script imports other scripts. + In such cases you may prefer using or + instead. + + + The following is the simple example of the interface alignment: + + public interface ICalc + { + int Sum(int a, int b); + } + .... + ICalc calc = CSScript.Evaluator + .LoadFile<ICalc>("calc.cs"); + + int result = calc.Sum(1, 2); + + + The type of the interface type the script class instance should be aligned to. + The C# script text. + Optional non-default constructor arguments. + Aligned to the T interface instance of the class defined in the script file assembly. + + + + Wraps C# code fragment into auto-generated class (type name DynamicClass), + evaluates it and loads the class to the current AppDomain. + + + The following is the simple example of the LoadMethod usage: + + dynamic script = CSScript.Evaluator + .LoadMethod(@"int Product(int a, int b) + { + return a * b; + }"); + + int result = script.Product(3, 2); + + + The C# script text. + Instance of the first class defined in the script assembly. + + + + Wraps C# code fragment into auto-generated class (type name DynamicClass), + evaluates it and loads the class to the current AppDomain. + + After initializing the class instance it is aligned to the interface specified by the + parameter T. + + + + The following is the simple example of the interface alignment: + + public interface ICalc + { + int Sum(int a, int b); + int Div(int a, int b); + } + .... + ICalc script = CSScript.Evaluator + .LoadMethod<ICalc>(@"public int Sum(int a, int b) + { + return a + b; + } + public int Div(int a, int b) + { + return a/b; + }"); + + int result = script.Div(15, 3); + + + + The type of the interface type the script class instance should be aligned to. + + The C# script text. + + Aligned to the T interface instance of the auto-generated class defined in the script. + + + + + References the assemblies from the script code. + + The method analyses and tries to resolve CS-Script directives (e.g. '//css_ref') and + 'used' namespaces based on the optional search directories. + + + The script code. + The assembly search/probing directories. + + The instance of the to allow fluent interface. + + + + + References the given assembly by the assembly path. + + It is safe to call this method multiple times for the same assembly. If the assembly + already referenced it will not be referenced again. + + + The path to the assembly file. + + The instance of the to allow fluent interface. + + + + + References the given assembly. + + It is safe to call this method multiple times for the same assembly. If the assembly + already referenced it will not be referenced again. + + + The assembly instance. + + The instance of the to allow fluent interface. + + + + + References the name of the assembly by its partial name. + + Note that the referenced assembly will be loaded into the host AppDomain in order to + resolve assembly partial name. + + It is an equivalent of Evaluator.ReferenceAssembly(Assembly.LoadWithPartialName(assemblyPartialName)) + + Partial name of the assembly. + + The instance of the to allow fluent interface. + + + + + References the assembly by the given namespace it implements. + + The namespace. + + Set to true if the namespace was successfully resolved (found) and the reference + was added; otherwise, false. + + + The instance of the to allow fluent interface. + + + + + References the assembly by the given namespace it implements. + + Adds assembly reference if the namespace was successfully resolved (found) and, + otherwise does nothing + + + The namespace. + + The instance of the to allow fluent interface. + + + + + References the assembly by the object, which belongs to this assembly. + + It is safe to call this method multiple times for the same assembly. If the assembly + already referenced it will not be referenced again. + + + The object, which belongs to the assembly to be referenced. + + The instance of the to allow fluent interface. + + + + + References the assembly by the object, which belongs to this assembly. + + It is safe to call this method multiple times for the same assembly. If the assembly + already referenced it will not be referenced again. + + + The type which is implemented in the assembly to be referenced. + + The instance of the to allow fluent interface. + + + + + References the assemblies the are already loaded into the current AppDomain. + + The type of assemblies to be referenced. + + The instance of the to allow fluent interface. + + + + + Resets Evaluator. + + Resetting means clearing all referenced assemblies, recreating evaluation infrastructure + (e.g. compiler setting) and reconnection to or recreation of the underlying compiling services. + + + Optionally the default current AppDomain assemblies can be referenced automatically with + . + + + + if set to true the default assemblies of the current AppDomain will be referenced + (see method). + + The freshly initialized instance of the . + + + + Clones the parent . + + This method returns a freshly initialized copy of the . + The cloning 'depth' can be controlled by the . + + + This method is a convenient technique when multiple instances + are required (e.g. for concurrent script evaluation). + + + if set to true all referenced assemblies from the parent + will be referenced in the cloned copy. + The freshly initialized instance of the . + + + var eval1 = CSScript.Evaluator.Clone(); + var eval2 = CSScript.Evaluator.Clone(); + + var sub = eval1.LoadDelegate<Func<int, int, int>>( + @"int Sub(int a, int b) { + return a - b; + }"); + + var sum = eval2.LoadDelegate<Func<int, int, int>>( + @"int Sub(int a, int b) { + return a + b; + }"); + + var result = sum(7, sub(4,2)); + + + + + + Some convenient extension methods for working with . + + + + + Sets referenced assemblies filter for exclusion of some "undesired" assemblies. It is a + convenient method for fine controlling referencing assemblies but without specifying the + complete predicates with . + + dynamic script = CSScript.Evaluator + .ExcludeReferencedAssemblies(new[]{this.GetType().Assembly}) + .LoadCode(scriptCode); + + + The evaluator. + The excluded assemblies. + + + + + Sets referenced assemblies filter for exclusion of some "undesired" assemblies. It is a + convenient method for fine controlling referencing assemblies but without specifying the + complete predicates with . + + dynamic script = CSScript.Evaluator + .ExcludeReferencedAssemblies(this.GetType().Assembly) + .LoadCode(scriptCode); + + + The evaluator. + The excluded assemblies. + + + + + CSScriptLib is compiled as nets standard so some .NETCore API is not available. + So filling the gaps... + + + + + + + Escapes the CS-Script directive (e.g. //css_*) delimiters. + 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. + The correct syntax would be as follows '//css_include script((today)).cs;' + The delimiters characters are ';,(){}'. + However you should check for the accurate list of all delimiters. + + + + The text to be processed. + The escaped string. + + + + Selects the first element that satisfies the specified path. + + The element. + The path. + Selected XML element + + + + Removes the duplicated file system path items from the collection.The duplicates are + identified based on the path being case sensitive depending on the hosting OS file system. + + The list. + A list with the unique items + + + + Determines whether [is shared assembly]. + + The path. + true if [is shared assembly] [the specified path]; otherwise, false. + + + + Converts to bool. + + The text. + Conversion result + + + + Removes the assembly extension. + + Name of the asm. + Result of the string manipulation + + + + Compares two path strings. Handles path being case-sensitive based on the OS file system. + + The path1. + The path2. + The result of the test. + + + + Captures the exception dispatch information. + + The ex. + Processed exception instanse + + + + Files the delete. + + The file path. + if set to true [rethrow]. + + + + Converts an array to a tuple. + Based on this beautiful solution: https://stackoverflow.com/questions/49190830/is-it-possible-for-string-split-to-return-tuple + + + The list. + The first. + + + + + Converts an array to a tuple. + Based on this beautiful solution: https://stackoverflow.com/questions/49190830/is-it-possible-for-string-split-to-return-tuple + + The list. + The first. + The second. + The rest. + + + + ParsingParams is a class that holds parsing parameters (parameters that controls how file is + to be parsed). At this moment they are namespace renaming rules only. + + + + + Compare() is to be used to help with implementation of IComparer for sorting operations. + + + + + Class which is a placeholder for general information of the script file + + + + + Constructor + + + ImportInfo object containing the information how the script file should be parsed. + + + + + Class that implements parsing the single C# script file + + + + + Searches for script file by given script name. Calls ResolveFile(string fileName, + string[] extraDirs, bool throwOnError) with throwOnError flag set to true. + + + + + The resolve file algorithm, + + The default algorithm searches for script file by given script name. Search order: + 1. Current directory + 2. extraDirs (usually %CSSCRIPT_ROOT%\Lib and ExtraLibDirectory) + 3. PATH Also fixes file name if user did not provide extension for script file (assuming + .cs extension) + + + + + + Searches for script file by given script name. Search order: + 1. Current directory + 2. extraDirs (usually %CSSCRIPT_ROOT%\Lib and ExtraLibDirectory) + 3. PATH Also fixes file name if user did not provide extension for script file (assuming + .cs extension) + + If the default implementation isn't suitable then you can set + FileParser.ResolveFilesAlgorithm to the alternative implementation of the probing algorithm. + + + + + + Class that implements parsing the single C# Script file + + + Implementation of the IComparer for sorting operations of collections of FileParser instances + + + + + Class that holds all information about the execution context (probing directories and + dependencies) of a script. + + + + + Primary script that defines the project. + + + + + List of all C# sources defined by the project. This includes the primary script itself + and all other scripts files the imported/included by the primary script. + + + + + List of assemblies the script of the project is referencing. + + + + + List of search folders where CS-Script does probing for imported/included scripts and assemblies. + + + + + Generates the top level view project for a given script. + + Note this method uses the same algorithm as CS-Script executor but it deliberately + doesn't include cached directories and auto-generated files. This method is to be used + by IDs and tools. + + + The script. + The project instance + + + + Gets the CSS configuration. Used by ST3 Syntaxer + + Default config file location + + + + Class that manages parsing the main and all imported (if any) C# Script files + + + + + Gets the script parsing context. This object is effectively a parsing result. + + Parsing result + + + + Processes the imported script. Processing involves lookup for 'static Main' and renaming + it so it does not interfere with the 'static Main' of the primary script. After renaming + is done the new content is saved in the CS-Script cache and the new file location is + returned. The saved file can be used late as an "included script". This technique can be + from 'precompiler' scripts. + + If the script file does not require renaming (static Main is not present) the method + returns the original script file location. + + + The script file. + Path to the script file to be compiled and executed + + + + ApartmentState of a script during the execution (default: ApartmentState.Unknown) + + + + + Collection of the files to be compiled (including dependent scripts) used for script compilation/execution. + + + + + Collection of the imported files (dependent scripts) that were used for script execution. + Note, some of the imported scripts can be temporary files containing scripts processed + according the importing specification (e.g. renamed `static Main`, renamed namespaces). + Use for the names of the original names of the imported scripts + + + + + Collection of the imported files (dependent scripts). + Note, some of the imported scripts can be converted in the temporary files containing scripts processed + according the importing specification (e.g. renamed `static Main`, renamed namespaces). + Use and/or for the names of the actual + files used on compilation/execution. + + + + + Collection of resource files referenced from code + + + + + Collection of compiler options + + + + + Precompilers specified in the primary script file. + + + + + Collection of namespaces referenced from code (including those referenced in dependent scripts) + + + + + Collection of namespaces, which if found in code, should not be resolved into referenced assembly. + + + + + Resolves the NuGet packages into assemblies to be referenced by the script. + + If the package was never installed/downloaded yet CS-Script runtime will try to download it. + + + CS-Script will also analyze the installed package structure in try to reference + compatible assemblies from the package. + + + + if set to true suppresses downloading the NuGet package. Suppressing can be + useful for the quick 'referencing' assessment. + + Collection of the referenced assembly files. + + + + Collection of the NuGet packages + + + + + Collection of referenced assemblies. All assemblies are referenced either from + command-line, code or resolved from referenced namespaces. + + + + + Constructor. + + Script file name + + + + Constructor. + + Script file name + Extra ScriptLibrary directory + + + + Constructor. + + Script file name + Extra ScriptLibrary directory(s) + + flag to indicate if the file parsing/processing error should raise an exception + + + + + The path of the parsed script. + + + + + Gets a value indicating whether the script being parsed is a web application script. + + true if the script is web application; otherwise, false. + + + + Initialization of ScriptParser instance + + Script file name + Extra ScriptLibrary directory(s) + + + + Saves all imported scripts in the temporary location. + + Collection of the saved imported scripts file names + + + + Deletes imported scripts as a cleanup operation + + + + + CS-Script SearchDirectories specified in the parsed script or its dependent scripts. + + + + + Aggregates the references from the script and its imported scripts. It is a logical + equivalent of CSExecutor.AggregateReferencedAssemblies but optimized for later .NET + versions (e.g LINQ) and completely decoupled. Thus it has no dependencies on internal + state (e.g. settings, options.shareHostAssemblies). + + It is the method to call for generating list of ref asms as part of the project info. + + + The search dirs. + The default ref asms. + The default namespaces. + List of references + + + + Information about the script parsing result. + + + + + The packages referenced from the script with `//css_nuget` directive + + + + + The referenced resources referenced from the script with `//css_res` directive + + + + + The referenced assemblies referenced from the script with `//css_ref` directive + + + + + The namespaces imported with C# `using` directive + + + + + The namespaces that are marked as "to ignore" with `//css_ignore_namespace` directive + + + + + The compiler options specified with `//css_co` directive + + + + + The directories specified with `//css_dir` directive + + + + + The precompilers specified with `//css_pc` directive + + + + + All files that need to be compiled as part of the script execution. + + + + + The time of parsing. + + + + + Collection of temp files to be removed during cleanup + + + + + Gets or sets the items (file paths) composing the temporary files collections. + + The items. + + + + Clears the collection. + + + + + A class that hosts the most common properties of the runtime environment. + + + + + Occurs when an exception is not caught. + + + + + Returns the name of the temporary folder in the CSSCRIPT subfolder of Path.GetTempPath(). + + Under certain circumstances it may be desirable to the use the alternative location for + the CS-Script temporary files. In such cases use SetScriptTempDir() to set the + alternative location. + + + Temporary directory name. + + + + Cleans the abandoned script execution cache. + + + + + Cleans the exited scripts. + + + + + The delegate for creating unloadable assembly load + context. The delegate is required to be set from the host process at runtime. It is + because it is not available at compile time since CSScriptLib assembly is compiled as + '.NET Standard 2.0' which does not implement but its + abstract type only. + + CS-Script uses intensive reflection technique to retrieve the host environment implementation. So you no not need to set it. + + + + + + Cleans the snippets. + + + + + Cleans the unused temporary files. + + The dir. + The pattern. + if set to true [verify pid]. + + + + Gets the nuget cache path in the form displayable in Console. + + The nu get cache view. + + + + Gets a value indicating whether the host OS Windows. + + true if the host OS is Windows; otherwise, false. + + + + Note it is not about OS being exactly Linux but rather about OS having Linux type of + file system. For example path being case sensitive + + + + + Gets a value indicating whether this process is an application compiled as a single file (published with PublishSingleFile option). + + + true if this instance is single file application; otherwise, false. + + + + + Gets a value indicating whether the runtime is core. + + true if the runtime is core; otherwise, false. + + + + Returns path to the `Microsoft.WindowsDesktop.App` shared assemblies of the compatible + runtime version. + + Note, there is no warranty that the dotnet dedktop assemblies belong to the same distro + version as dotnet Core: + - C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.0-rc.1.20451.14 + - C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\5.0.0-rc.1.20452.2 + + + + + + Returns path to the `Microsoft.AspNetCore.App` shared assemblies of the compatible + runtime version. + + + + + Determines whether .NET SDK is installed. + + true if [is SDK installed]; otherwise, false. + + + + Gets the directories specified by either relative or absolute path `rootDir`. + `rootDir` can contain wild-cards as per Git 'ignore specification' + + The working dir. + The root dir path as per Git 'ignore specification'. + The method result. + + + + Delegate implementing source file probing algorithm. + + The file. + The extra dirs. + if set to true [throw on error]. + Location of the files matching the resolution input. + + + + Delegate implementing assembly file probing algorithm. + + The file. + The extra dirs. + Location of the files matching the resolution input. + + + + Utility class for assembly probing. + + + + + File to be excluded from assembly search + + + + + Determines whether the string is a legal path token. + + The name. + + true if the string is a legal path token; otherwise, false. + + + + + Resolves namespace/assembly(file) name into array of assembly locations (local and GAC ones). + + 'namespace'/assembly(file) name + Assembly search directories + If the default implementation isn't suitable then you can set CSScript.FindAssemblyAlgorithm + to the alternative implementation of the probing algorithm. + collection of assembly file names where namespace is implemented + + + + Resolves namespace into array of local assembly locations. + (Currently it returns only one assembly location but in future + it can be extended to collect all assemblies with the same namespace) + + namespace/assembly name + directory + collection of assembly file names where namespace is implemented + + + + Resolves namespace into array of global assembly (GAC) locations. + NOTE: this method does nothing on .NET Core as it offers no GAC discovery mechanism. + + 'namespace' name + collection of assembly file names where namespace is implemented + + + + A strongly-typed resource class, for looking up localized strings, etc. + + + + + Returns the cached ResourceManager instance used by this class. + + + + + Overrides the current thread's CurrentUICulture property for all + resource lookups using this strongly typed resource class. + + + + + Looks up a localized resource of type System.Byte[]. + + + + + Looks up a localized resource of type System.Byte[]. + + + + + Looks up a localized resource of type System.Byte[]. + + + + + + + + + + Gets or sets the collection of the temporary files that the runtime will delete on the application exit. + + + The temporary files. + + + + + Gets or sets the probing directories to be used for assembly probings. + + + The probing directories. + + + + + Gets or sets the compiled assembly. + + + The compiled assembly. + + + + + Gets or sets the errors. + + + The errors. + + + + + Gets or sets the output. + + + The output. + + + + + Gets or sets the path to assembly. + + + The path to assembly. + + + + + Gets or sets the native compiler return value, which is a process exit code of the compiler executable (e.g. dotnet.exe). + + + The native compiler return value. + + + + + + + + + + Gets or sets the line number of the syntax causing the error. + + + The line. + + + + + Gets or sets the column number of the syntax causing the error. + + + The column. + + + + + Gets or sets the error number. + + + The error number. + + + + + Gets or sets the error text. + + + The error text. + + + + + Gets or sets a value indicating whether this instance of the error is a warning. + + + true if this instance is warning; otherwise, false. + + + + + Gets or sets the name of the file causing the error. + + + The name of the file. + + + + + Parses the specified compiler output. + + The compiler output. + Error object + + + + Various LINQ extensions + + + + + None of the items matches the specified predicate. + + + The items. + The predicate. + Result of the test + + + + Adds a single item to the collection. + + The type of the source. + The items. + The item. + The original collection instance. + + + + Determines whether the collection is empty. + + + The collection. + + true if the specified collection is empty; otherwise, false. + + + + + A generic LINQ equivalent of C# foreach loop. + + + The collection. + The action. + The original collection instance + + + + A generic LINQ equivalent of C# foreach loop with support for the item index. + + + The collection. + The action. + + + + + Allows updating the object in Fluent expressions. + + + The object. + The action. + + + + + Various PATH extensions + + + + + Copies the file. + + The source path to the file. + The destination path to the file. + if set to true [ignore errors]. + + + + Changes the extension of the file. + + The path. + The extension. + A new path + + + + Gets the extension. + + The path. + File extension + + + + Gets the file name part of the full path. + + The path. + The method result. + + + + Checks if the directory exists. + + The path. + The result of the test. + + + + Gets the full path. + + The path. + The path + + + + Determines whether the path is directory. + + The path. + + true if the specified path is dir; otherwise, false. + + + + + Determines whether the specified path string is valid (does not contain invalid characters). + + The path. + + true if the path is valid; otherwise, false. + + + + + A more convenient API version of . + + The path. + The parts. + A new path. + + + + Gets the special folder path. + + The folder. + A folder path. + + + + Gets the special folder path combined with an array of strings into a path. + + The folder. + The parts. + + + + + Ensures the directory exists. + + The path. + if set to true [rethrow]. + Path of the created/existing directory + + + + Ensures the parent directory of the file exists. + + The file path. + if set to true [rethrow]. + Path of the file + + + + Deletes the directory and its all content. + + The path. + if set to true [handle exceptions]. + if set to true [do not deletе root]. + + The original directory path + + + + + Checks if the file exists. + + The path. + The result of the test. + + + + Gets the directory name from the path. + + The path. + The directory path. + + + + Changes the name of the file. + + The path. + Name of the file. + A new path. + + + + Gets the file name without the extension. + + The path. + File name + + + + Normalizes directory separators in the given path by ensuring the separators are compatible with the target file system. + + The path. + A new normalized path. + + + + Gets the subdirectories of the specified directory path. + + The path. + The mask. + A list of the discovered directories. + + + + The configuration and methods of the global context. + + + + + Removes the build server from the target system. + + true if success; otherwise false + + + + Deploys the build server on the target system. + + + + + Pings the running instance of the build server. + + + + + Gets a value indicating whether build server is deployed. + + true if build server is deployed; otherwise, false. + + + + Gets the path to the assembly implementing Roslyn compiler. + + + + + Gets the path to the dotnet executable. + + The dotnet executable path. + + + + Gets the path to the csc.exe executable for .NET Framework. + + The csc.exe executable path. + + + + Gets or sets the path to the C# compiler executable (e.g. csc.exe or csc.dll) + + The CSC. + + + + Various Reflection extensions for implementing assembly unloading + + + + + Retrieves associated with the assembly and unloads it. + It will throw an exception if the is not created as + unloadable ('IsCollectible'). + Use to control + how the assemblies (compiled scripts) are loaded. + + Note, unloading of assembly is implemented by CLR not CS-Script. This method extension is simply + redirecting the call to the .NET + . Thus it is subject of the + underlying limitations. Thus an AssemblyLoadContext can only be unloaded if it is collectible. And + Unloading will occur asynchronously. + + + Note, using 'dynamic` completely breaks CLR unloading mechanism. Most likely it triggers + an accidental referencing of the assembly or . Meaning that if you are planing to + use assembly unloading you need to use interface based scripting. See `Test_Unloading` + (https://github.com/oleg-shilo/cs-script/blob/master/src/CSScriptLib/src/Client.NET-Core/Program.cs) + sample for details. + + + + + + + Various Reflection extensions + + + + + Returns directory where the specified assembly file is. + + The asm. + The directory path + + + + Returns location of the specified assembly. Avoids throwing an exception in case + of dynamic assembly. + + The asm. + The path to the assembly file + + + + Gets the name of the type. + + The type. + Thew name of the type. + + + + Creates instance of a class from underlying assembly. + + The asm. + The 'Type' full name of the type to create. (see Assembly.CreateInstance()). + You can use wild card meaning the first type found. However only full wild card "*" is supported. + The non default constructor arguments. + + Instance of the 'Type'. Throws an ApplicationException if the instance cannot be created. + + + + + Creates instance of a Type from underlying assembly. + + The asm. + Name of the type to be instantiated. Allows wild card character (e.g. *.MyClass can be used to instantiate MyNamespace.MyClass). + The non default constructor arguments. + + Created instance of the type. + + Type " + typeName + " cannot be found. + + + + Determines whether the assembly is dynamic. + + The asm. + + true if the specified asm is dynamic; otherwise, false. + + + + + Class for automated assembly probing. It implements extremely simple ('optimistic') + probing algorithm. At runtime it attempts to resolve the assemblies via AppDomain.Assembly resolve + event by looking up the assembly files in the user defined list of probing directories. + The algorithm relies on the simple relationship between assembly name and assembly file name: + <assembly file> = <asm name> + ".dll" + + The following is an example of automated assembly probing. + + using (SimpleAsmProbing.For(@"E:\Dev\Libs", @"E:\Dev\Packages")) + { + dynamic script = CSScript.Evaluator + .LoadFile(script_file); + script.Print(); + } + + + + + + + Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + + + + + Releases unmanaged and - optionally - managed resources. + + true to release both managed and unmanaged resources; false to release only unmanaged resources. + + + + Finalizes an instance of the class. + + + + + Initializes a new instance of the class. + + + + + Creates and initializes a new instance of the class. + + The probing dirs. + + + + + Initializes a new instance of the class. + + The probing dirs. + + + + Sets probing dirs and subscribes to the event. + + The probing dirs. + + + + Unsubscribes to the event. + + + + + Various string extensions + + + + + Determines whether the string is empty (or null). + + The text. + + true if the specified text is empty; otherwise, false. + + + + + Determines whether the string is not empty (or null). + + The text. + + true if [is not empty] [the specified text]; otherwise, false. + + + + + Determines whether this instance has text. + + The text. + + true if the specified text has text; otherwise, false. + + + + + Trims a single character form the head and the end of the string. + + The text. + The trim chars. + The result of trimming. + + + + Gets the lines. + + The string. + The method result. + + + + Determines whether this string contains the substring defined by the pattern. + + The text. + The pattern. + if set to true [ignore case]. + + true if [contains] [the specified pattern]; otherwise, false. + + + + + Compares two strings. + + The text. + The pattern. + if set to true [ignore case]. + The result of the test. + + + + Checks if the given string matches any of the provided patterns. + + The text. + The patterns + The method result. + + + + Joins strings the by the specified separator. + + The values. + The separator. + The method result. + + + + The custom implementation of the method. + + The text to generate the hash for.s. + The method result. + +
+
diff --git a/src/CSScriptLib/src/CSScriptLib/output/CSScriptLib.xml b/src/CSScriptLib/src/CSScriptLib/output/CSScriptLib.xml new file mode 100644 index 00000000..2d76a337 --- /dev/null +++ b/src/CSScriptLib/src/CSScriptLib/output/CSScriptLib.xml @@ -0,0 +1,3763 @@ + + + + CSScriptLib + + + + + Very light parser for C# code. The main purpose of it is to be very fast and reliable. + It only extracts code information relative to the CS-Script. + + + + + Class to hold the script information on what pre- or post-execution script needs to be executed. + pre- and post-script CS-Script command format: + //css_prescript file([arg0][, arg1]..[,arg2])[,ignore]; + //file - script file (extension is optional) + //arg0..N - script string arguments; + If $this is specified as arg0..N it will be replaced with the parent script full name at execution time. + + + + + Creates an instance of CmdScriptInfo. + + CS-Script pre- or post-script directive + If set to true the 'statement' is a pre-script otherwise it is a post-script. + The file name of the main script. + + + + Script file and it's arguments. + + + + + If set to 'true' the CmdScriptInfo describes the pre-script, otherwise it is for the post-script. + + + + + If set to 'true' parent script will be aborted on pre/post-script error, otherwise the error will be ignored. + + + + + Class to hold the script initialization information. + + + + + The boolean flag indicating if CoInitializeSecurity (with default parameters) should be called at the start of the script execution. + + + + + The RpcImpLevel of CoInitializeSecurity arguments + + + + + The EoAuthnCap of CoInitializeSecurity arguments + + + + + Initializes a new instance of the class. + + The original argument statement of the //css_init directive. + + + + Class to hold the script importing information, which actually controls how script is imported. + + + + + Creates an instance of ImportInfo. + + CS-Script import directive (//css_import...) string. + name of the parent (primary) script file. + + + + The file to be imported. + + + + + Renaming instructions (old_name vs. new_name) + + + + + If set to 'true' "static...Main" in the imported script is not renamed. + + + + + Initializes a new instance of the class. + + + + + Creates an instance of CSharpParser. + + C# code string + + + + Creates an instance of CSharpParser. + + C# script (code or file). + If set to 'true' the script is a file, otherwise it is a C# code. + + + + Creates an instance of CSharpParser. + + C# script (code or file). + If set to 'true' the script is a file, otherwise it is a C# code. + Additional C# script directives to search. The search result is stored in CSharpParser.CustomDirectives. + + + + Creates an instance of CSharpParser. + + C# script (code or file). + If set to 'true' the script is a file, otherwise it is a C# code. + Additional C# script directives to search. The search result is stored in CSharpParser.CustomDirectives. + Search directories for resolving wild card paths in //css_inc and //css_imp + + + + The result of search for additional C# script directives to search (directive vs. value). + + + + + Global flag to forcefuly supress any C# code analysys. This flag efectively disables + all CS-Script assembly and script probing and most likely some other functionality. + You may ever want to suppress code analysis only for profiling purposes or during performance tuning. + + + + + Parses the C# code. + + C# script (code or file). + If set to 'true' the script is a file, otherwise it is a C# code. + Additional C# script directives to search. The search result is stored in CSharpParser.CustomDirectives. + Search directories for resolving wild card paths in //css_inc and //css_imp + + + + Renames namespaces according renaming instructions. + + Renaming instructions (old_name vs. new_name). + /// If set to 'true' "static...Main" in the imported script is not renamed. + + + + Embedded script arguments. The both script and engine arguments are allowed except "/noconfig" engine command line switch. + + + + + Embedded compiler options. + + + + + Embedded compiler options. + + + + + Precompilers. + + + + + References to the external assemblies and namespaces. + + + + + References to the external assemblies. + + + + + Names of namespaces to be ignored by namespace-to-assembly resolver. + + + + + Additional search directories (for script and assembly probing). + + + + + References to the resource files. + + + + + References to the namespaces. + + + + + References to the NuGet packages. + + + + + C# scripts to be imported. + + + + + Pre- and post-execution scripts. + + + + + Script initialization directives. + + + + + Script C# raw code. + + + + + Script C# code after namespace renaming. + + + + + Enables omitting closing character (";") for CS-Script directives (e.g. "//css_ref System.Xml.dll" instead of "//css_ref System.Xml.dll;"). + + + + + Escapes the CS-Script directive (e.g. //css_*) delimiters. + 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. + The correct syntax would be as follows '//css_include script((today)).cs;' + The delimiters characters are ';,(){}'. + However you should check for the accurate list of all delimiters. + + + + The text to be processed. + The escaped string. + + + + Replaces the user escaped delimiters with internal escaping. +

"{char}{char}" -> "\u{((int)c).ToString("x4")}"

+

"((" -> "\u0028"

+ +
+ The text. + The escaped string. +
+ + + Unescapes the CS-Script directive (e.g. //css_*) delimiters. + 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. + The correct syntax would be as follows '//css_include script((today)).cs;' + The delimiters characters are ';,(){}'. + However you should check for the accurate list of all delimiters. + + + + The text to be processed. + The unescaped string. + + + + The //css_* directive delimiters. + 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. + The correct syntax would be as follows '//css_include script((today)).cs;' + + + + + + Contains the name of the temporary cache folder in the CSSCRIPT subfolder of Path.GetTempPath(). The cache folder is specific for every script file. + + + + + Generates the name of the cache directory for the specified script file. + + Script file name. + Cache directory name. + + + + Settings is an class that holds CS-Script application settings. + + + + + Loads and returns the settings instance. + + + + + Gets the default configuration file path. It is a "css_config.xml" file located in the same directory where the assembly + being executed is (e.g. cscs.exe). + + + The default configuration file location. Returns null if the file is not found. + + + + + List of directories to be used to search (probing) for referenced assemblies and script files. + This setting is similar to the system environment variable PATH. + + + + + Gets or sets the default reference assemblies. + + + The default reference assemblies. + + + + + Clears the search directories. + + The Settings instance. + + + + Adds the search directories aggregated from the unique locations of all assemblies referenced by the host application. + + The dir. + The Settings instance + + + + Adds the search dirs from host application. + The dirs are the list of locations the all currently loaded assemblies are loaded from. + + The Settings instance + + + + Class which is implements CS-Script class library interface. + + + + + Starts the build server. + + + + + Stops the build server. + + + + + Gets the CSScript., which controls the way code evaluation is conducted at runtime. + + The evaluator CSScript.. + + + + Global instance of the generic . This object is to be used for + dynamic loading of the C# code by "compiler as service" based on the + value. + Generic interface provides a convenient way of accessing + compilers without 'committing' to a specific compiler technology (e.g. Mono, Roslyn, CodeDOM). This may be + required during troubleshooting or performance tuning. + Switching between compilers can be done via global + CSScript.. + + By default CSScript. always returns a new instance of + . If this behavior is undesired change the evaluator access + policy by setting .Access value. + + + The instance. + + + if(testingWithMono) + CSScript.EvaluatorConfig.Engine = EvaluatorEngine.Mono; + else + CSScript.EvaluatorConfig.Engine = EvaluatorEngine.Roslyn; + + var sub = CSScript.Evaluator + .LoadDelegate<Func<int, int, int>>( + @"int Sub(int a, int b) { + return a - b; + }"); + + + + + + Returns the name of the temporary folder in the CSSCRIPT subfolder of Path.GetTempPath(). + Under certain circumstances it may be desirable to the use the alternative location for the CS-Script temporary files. + In such cases use SetScriptTempDir() to set the alternative location. + + + Temporary directory name. + + + + Returns the name of the temporary file in the CSSCRIPT subfolder of Path.GetTempPath(). + + Temporary file name. + + + + Settings object containing runtime settings, which controls script compilation/execution. + This is Settings class essentially is a deserialized content of the CS-Script configuration file (css_config.xml). + + + + + Global instance of . This object is to be used for + dynamic loading of the C# code by using Roslyn "compiler as service". + If you need to use multiple instances of th evaluator then you will need to call + .Clone(). + + + The instance. + + + + Global instance of . This object is to be used for + dynamic loading of the C# code by using CodeDom "compiler as service". + If you need to use multiple instances of th evaluator then you will need to call + .Clone(). + + + The instance. + + + + Controls if ScriptCache should be used when script file loading is requested (CSScript.Load(...)). If set to true and the script file was previously compiled and already loaded + the script engine will use that compiled script from the cache instead of compiling it again. + Note the script cache is always maintained by the script engine. The CacheEnabled property only indicates if the cached script should be used or not when CSScript.Load(...) method is called. + + + + + Notes the temporary file to be removed on application exit. + + The file. + + + + Starts the purging old temporary files. + + if set to true [ignore current process scripts]. + + + + Class implementing CodeDom favor of (csc.exe/csc.dll) + + + + + + The flag indicating if the compilation should happen on the build server or locally. + + + + + Timeout for the C# CLI compiler `csc.exe`. + + This compiler is a part of .NET SDK and it is the actual + tool that compiles C# code into assembly when CodeDomEvaluator is used. + This tool under certain circumstances has tendency to hang after even if it successfully + finished the compilation. Thus configurable timeout allows user to configure forcible termination + of the csc.exe process. + + + The default value is -1 (infinite). + + + + + The low level output of the last script compilation. This member is not designed to be a + part of script error handling. For this purpose a normal exception based mechanism the + is a more appropriate choice. + + on another hand is great for troubleshooting problems + associated with the low level completion. IE non script specific failures of csc.exe. + + + + + + Validates the specified information. + + The information. + + CompileInfo.RootClass property should only be used with Roslyn evaluator as " + "it + addresses the limitation associated with Roslyn. Specifically wrapping ALL scripts in + the illegally " + "named parent class. You are using CodeDomEvaluator so you should not + set CompileInfo.RootClass to any custom value + + + + + Compiles the specified script text. + + The script text. + The script file. + The information. + The method result. + + + + References the given assembly. + + It is safe to call this method multiple times for the same assembly. If the assembly + already referenced it will not be referenced again. + + + The assembly instance. + + The instance of the to allow fluent interface. + + + Current version of {EngineName} doesn't support referencing assemblies " + "which are + not loaded from the file location. + + + + + Gets the referenced assemblies files. + + The method result. + + + + Loads and returns set of referenced assemblies. + Notre: the set of assemblies is cleared on Reset. + + The method result. + + + + The information about the location of the compiler output - assembly and pdb file. + + + + + Gets or sets the compiler options for csc.exe. + + This property is only applicable for CodeDOM based script execution as Roslyn engine does + not accept string options for compilation. + + + The compiler options. + + + + The assembly file path. If not specified it will be composed as "<RootClass>.dll". + + + + + The PDB file path. + + Even if the this value is specified the file will not be generated unless .DebugBuild is set to true. + + + + + + Gets or sets the root class name. + + This setting is required as Roslyn cannot produce compiled scripts with the user script + class defined as a top level class. Thus all user defined classes are in fact nested + classes with the root class named by Roslyn as "Submission#0". This leads to the + complications when user wants to reference script class in another script. Specifically + because C# treats "Submission#0" as an illegal class name. + + + C# helps the situation by allowing user specified root name , which is by default is "css_root". + + + The root class name. + + + + Gets or sets the name of the assembly to be built from the script. + + + The name of the assembly. + + + + + Gets or sets the loaded script assembly. + This member is set to the script assembly loaded in the calling ppDomain. + It is particularly useful when you need access the script assembly (e.g. to unload it) + but it is unavailable to the caller because the evaluation expression does not return any result (`void`). + + + The loaded assembly. + + + + + Gets or sets a value indicating whether to prefer loading compiled script from the + assembly file when it is available. + + true if [prefer loading from file]; otherwise, false. + + + + Gets or sets the kind of the script code. This property is used to control the way Roslyn engine is compiling the script code. + + By default it is used for processing the scripts the same way as .cs/.vb files. + While used for processing the scripts as a canonical single file script with the + top-level code. + + + The is the code kind that is used by setting which is + the only API supported in the .NET applications published as single-file. Though this value can also be used in other Roslyn + evaluator scenarios too (e.g. ). + + + + + The kind of the code. + + + + + The exception that is thrown when a the script compiler error occurs. + + + + + Gets or sets the error count associated with the last script compilation. + + The error count. + + + + Initialises a new instance of the class. + + + + + Initialises a new instance of the class. + + The object that holds the serialized object data. + The contextual information about the source or destination. + + + + Initializes a new instance of the class. + + The message. + + + + Initializes a new instance of the class. + + The message. + The exception. + + + + Creates the CompilerException instance from the specified compiler errors. + + The compiler errors. + if set to true hide compiler warnings. + + if set to true all references to the path of the derived auto-generated files + (e.g. errors in the decorated classless scripts) will be replaced with the path of the + original files (e.g. classless script itself). + + The method result. + + + + + + + + + Loads and returns set of referenced assemblies. + Notre: the set of assemblies is cleared on Reset. + + The method result. + + + + Gets or sets the compiler settings. + + The compiler settings. + + + + Loads the assemblies implementing Roslyn compilers. + + Roslyn compilers are extremely heavy and loading the compiler assemblies for with the + first evaluation call can take a significant time to complete (in some cases up to 4 + seconds) while the consequent calls are very fast. + + + You may want to call this method to pre-load the compiler assembly your script + evaluation performance. + + + + + + Compiles the specified script text. + + The script text. + The script file. + The information. + The method result. + + + + + References the given assembly. + + It is safe to call this method multiple times for the same assembly. If the assembly + already referenced it will not be referenced again. + + + The assembly instance. + + The instance of the to allow fluent interface. + + + Current version of {EngineName} doesn't support referencing assemblies " + "which are + not loaded from the file location. + + + + + Evaluates (executes) the specified script text, which is a top-level C# code. + It is the most direct equivalent of "eval" available in dynamic languages. This method is only + available for Roslyn evaluator. + You can evaluate simple expressions: + + var result = CSScript.Evaluator.Eval("1 + 2"); + + Or it can be a complex script, which defines its own types: + + var calc = CSScript.Evaluator + .Eval(@"using System; + public class Script + { + public int Sum(int a, int b) + { + return a+b; + } + } + + return new Script();"); + int sum = calc.Sum(1, 2); + + + Note compiles and executes the script in the current AppDoman. + All AppDomain loaded assemblies of the AppDomain being referenced from the script regardless of + setting. + During the script compilation, this method uses: + + CompileInfo.CodeKind=Microsoft.CodeAnalysis.SourceCodeKind.Script. + + This is the only option that supports script execution for applications published with + PublishSingleFile option. + + This method is the only option that supports script execution for applications published with + PublishSingleFile option. + + The script text. + + The object returned by the script. + + This method is only available for Roslyn evaluator. + Script entry point method could be found. + + + + Evals the specified script text. + + + The script text. + The information. + + + This method is only available for Roslyn evaluator. + or + The parameter `{nameof(info)}.{nameof(info.CodeKind)}` must be set to `{nameof(SourceCodeKind.Script)}`. + + Script entry point method could be found. + + + + Resets Evaluator. + + Resetting means clearing all referenced assemblies, recreating evaluation infrastructure + (e.g. compiler setting) and reconnection to or recreation of the underlying compiling services. + + + Optionally the default current AppDomain assemblies can be referenced automatically with + . + + + + if set to true the default assemblies of the current AppDomain will be referenced + (see method). + + The freshly initialized instance of the . + + + + A wrapper class that encapsulates the functionality of the Roslyn evaluator ( ). + + + + + Clones itself as . + + This method returns a freshly initialized copy of the . The cloning 'depth' can be controlled by the . + + + This method is a convenient technique when multiple + instances are required (e.g. for concurrent script evaluation). + + + + if set to true all referenced assemblies from the parent will be referenced in the cloned copy. + + The freshly initialized instance of the . + + + + Gets or sets a value indicating whether to compile script with debug symbols. + + Note, setting DebugBuild will only affect the current instance of Evaluator. If + you want to emit debug symbols for all instances of Evaluator then use .DebugBuild. + + + true if 'debug build'; otherwise, false. + + + + Gets a value indicating whether this instance is debug. + + true if this instance is debug; otherwise, false. + + + + Initializes a new instance of the class. + + + + + Evaluates (compiles) C# code (script). The C# code is a typical C# code containing a single or multiple class definition(s). + + + + Assembly asm = CSScript.RoslynEvaluator + .CompileCode(@"using System; + public class Script + { + public int Sum(int a, int b) + { + return a+b; + } + }"); + + dynamic script = asm.CreateObject("*"); + var result = script.Sum(7, 3); + + + The C# script text. + The compiled assembly. + + + + Evaluates (compiles) C# code (script). The C# code is a typical C# code containing a + single or multiple class definition(s). + + The method is identical to + except that it allows specifying the destination assembly file with object. + + + + + var info = new CompileInfo + { + AssemblyFile = @"E:\temp\asm.dll" + }; + + Assembly asm = CSScript.Evaluator + .Cast<RoslynEvaluator>() + .CompileCode(@"using System; + public class Script + { + public int Sum(int a, int b) + { + return a+b; + } + }", + info); + + dynamic script = asm.CreateObject("*"); + var result = script.Sum(7, 3); + + + The C# script text. + + The compiled assembly. + + + + Validates the specified information. + + The information. + + + + CS-Script assembly unloading functionality is implemented as a combination of loading + assembly into that is marked as "IsCollectible" and + the ReflectionExtensions. extension method. Unloading is + only available on the runtimes that support it. Otherwise throws an exception on attempt to load the compiled script assembly. + + is designed to allow enabling/disabling of the + assembly unloading should you find that the limitations associated with this .NET Core + specific feature are not acceptable. E.g., collectible assemblies cannot be referenced + from other scripts or in fact any dynamically loaded assembly for that matter. + + + Due to the limitations (though minor) of the underlying .NET Core feature is set to false by default. + + + + + + This property controls script caching. + Caching mechanism allows avoiding multiple compilation of the scripts that have been already compiled and has not changes + since then for the duration of the host process. This feature can dramatically improve the performance in the cases when you are executing + the same script again and again. Even though in such cases caching is not the greatest optimization that can be achieved. + Note that caching has some limitations. Thus the algorithm for checking if the script is changed since the last execution + is limited to verifying the script code (text) only. Thus it needs to be used with caution. + Script caching is disabled by default. + + The following is an example of caching the compilation. + + dynamic printerScript = CSScript.Evaluator + .With(eval => eval.IsCachingEnabled = true) + .LoadFile(script_file); + printerScript.Print(); + + + + + + Returns set of referenced assemblies. + Notre: the set of assemblies is cleared on Reset. + + The method result. + + + + + Gets the referenced assemblies files. + + The method result. + + + + + Compiles C# file (script) into assembly file. The C# contains typical C# code containing + a single or multiple class definition(s). + + The C# script file. + The path to the assembly file to be compiled. + The compiled assembly file path. + + + string asmFile = CSScript.Evaluator + .CompileAssemblyFromFile("MyScript.cs", "MyScript.dll"); + + + + + + Compiles C# code (script) into assembly file. The C# code is a typical C# code containing a single or multiple class definition(s). + + + + string asmFile = CSScript.Evaluator + .CompileAssemblyFromCode( + @"using System; + public class Script + { + public int Sum(int a, int b) + { + return a+b; + } + }", + "MyScript.dll"); + + + The C# script text. + The path to the assembly file to be compiled. + The compiled assembly file path. + + + + Compiles the specified script text without loading it into the AppDomain or + writing to the file system. + + + + try + { + CSScript.Evaluator + .Check(@"using System; + public class Script + { + public int Sum(int a, int b) + { + error + return a+b; + } + }"); + } + catch (Exception e) + { + Console.WriteLine("Compile error: " + e.Message); + } + + + The script text. + + + + Compiles the specified script text. + + The script text. + The script file. + The information. + The method result. + + + + + Wraps C# code fragment into auto-generated class (type name DynamicClass) and evaluates it. + + This method is a logical equivalent of but is allows you to define + your script class by specifying class method instead of whole class declaration. + + + + dynamic script = CSScript.RoslynEvaluator + .CompileMethod(@"int Sum(int a, int b) + { + return a+b; + }") + .CreateObject("*"); + + var result = script.Sum(7, 3); + + + The C# code. + The compiled assembly. + + + + Wraps C# code fragment into auto-generated class (type name DynamicClass), + evaluates it and loads the class to the current AppDomain. + + Returns non-typed for class-less style of invoking. + + + + + var log = CSScript.Evaluator + .CreateDelegate(@"void Log(string message) + { + Console.WriteLine(message); + }"); + + log("Test message"); + + + The C# code. + The instance of a non-typed + + + + Wraps C# code fragment into auto-generated class (type name DynamicClass), + evaluates it and loads the class to the current AppDomain. + + Returns typed for class-less style of invoking. + + + The delegate return type. + + + var product = CSScript.RoslynEvaluator + .CreateDelegate<int>(@"int Product(int a, int b) + { + return a * b; + }"); + + int result = product(3, 2); + + + The C# code. + The instance of a typed + + + + Analyses the script code and returns set of locations for the assemblies referenced from + the code with CS-Script directives (//css_ref). + + The script code. + The assembly search/probing directories. + Array of the referenced assemblies + + + + Analyses the script file code and returns set of locations for the assemblies referenced from + the code with CS-Script directives (//css_ref). + + The script file. + The assembly search/probing directories. + + Array of the referenced assemblies + + + + + Evaluates and loads C# code to the current AppDomain. Returns instance of the first class defined in the code. + + The following is the simple example of the LoadCode usage: + + dynamic script = CSScript.RoslynEvaluator + .LoadCode(@"using System; + public class Script + { + public int Sum(int a, int b) + { + return a+b; + } + }"); + int result = script.Sum(1, 2); + + + The C# script text. + The non default constructor arguments. + Instance of the class defined in the script. + + + + Evaluates and loads C# code to the current AppDomain. Returns instance of the first + class defined in the code. + + + The type of the script class instance should be type casted to. + + The C# script text. + The non default type T constructor arguments. + Aligned to the T interface instance of the class defined in the script. + + The following is the simple example of the interface alignment: + + public interface ICalc + { + int Sum(int a, int b); + } + .... + ICalc calc = CSScript.Evaluator + .LoadCode<ICalc>(@"using System; + public class Script + { + public int Sum(int a, int b) + { + return a+b; + } + }"); + int result = calc.Sum(1, 2); + + + + + + Wraps C# code fragment into auto-generated class (type name DynamicClass), + evaluates it and loads the class to the current AppDomain. + + Returns instance of T delegate for the first method in the auto-generated class. + + + + + var Product = CSScript.Evaluator + .LoadDelegate<Func<int, int, int>>( + @"int Product(int a, int b) + { + return a * b; + }"); + + int result = Product(3, 2); + + + The C# code. + Instance of T delegate. + + + + Evaluates and loads C# code from the specified file to the current AppDomain. Returns instance of the first + class defined in the script file assembly. + + Note, the order of the classes in the script assembly is not may not be your script imports other scripts. + In such cases you may prefer using or + instead. + + + The C# script file. + Optional non-default constructor arguments. + + Instance of the class defined in the script file assembly. + + The following is the simple example of the interface alignment: + + dynamic script = CSScript.Evaluator.LoadFile("calc.cs"); + int result = script.Sum(1, 2); + + + + + Evaluates and loads C# code from the specified file to the current AppDomain. Returns instance of the first + class defined in the script file assembly. + + After initializing the class instance it is aligned to the interface specified by the parameter T. + Note: the script class does not have to inherit from the T parameter as the proxy type + will be generated anyway. + Note, the order of the classes in the script assembly is not may not be your script imports other scripts. + In such cases you may prefer using or + instead. + + + The type of the interface type the script class instance should be aligned to. + The C# script text. + Optional non-default constructor arguments. + + Aligned to the T interface instance of the class defined in the script file assembly. + + The following is the simple example of the interface alignment: + + public interface ICalc + { + int Sum(int a, int b); + } + .... + ICalc calc = CSScript.Evaluator + .LoadFile<ICalc>("calc.cs"); + int result = calc.Sum(1, 2); + + + + + Wraps C# code fragment into auto-generated class (type name DynamicClass), + evaluates it and loads the class to the current AppDomain. + + + The following is the simple example of the LoadMethod usage: + + dynamic script = CSScript.RoslynEvaluator + .LoadMethod(@"int Product(int a, int b) + { + return a * b; + }"); + + int result = script.Product(3, 2); + + + The C# script text. + Instance of the first class defined in the script. + + + + Wraps C# code fragment into auto-generated class (type name DynamicClass), + evaluates it and loads the class to the current AppDomain. + + After initializing the class instance it is aligned to the interface specified by the + parameter T. + + + + The following is the simple example of the interface alignment: + + public interface ICalc + { + int Sum(int a, int b); + int Div(int a, int b); + } + .... + ICalc script = CSScript.RoslynEvaluator + .LoadMethod<ICalc>(@"public int Sum(int a, int b) + { + return a + b; + } + public int Div(int a, int b) + { + return a/b; + }"); + int result = script.Div(15, 3); + + + + The type of the interface type the script class instance should be aligned to. + + The C# script text. + + Aligned to the T interface instance of the auto-generated class defined in the script. + + + + + Gets or sets the flag indicating if the script code should be analyzed and the + assemblies that the script depend on (via '//css_...' and 'using ...' directives) should + be referenced. + + + + + + References the assemblies from the script code. + + The method analyses and tries to resolve CS-Script directives (e.g. '//css_ref') and + 'used' namespaces based on the optional search directories. + + + The script code. + The assembly search/probing directories. + + The instance of the to allow fluent interface. + + + + + References the given assembly by the assembly path. + + It is safe to call this method multiple times for the same assembly. If the assembly + already referenced it will not be referenced again. + + + The path to the assembly file. + + The instance of the to allow fluent interface. + + + + + Gets the name of the engine (e.g. 'csc' or 'dotnet'). + + The name of the engine. + + + + References the given assembly. + + It is safe to call this method multiple times for the same assembly. If the assembly + already referenced it will not be referenced again. + + + The assembly instance. + + The instance of the to allow fluent interface. + + + + + References the name of the assembly by its partial name. + + Note that the referenced assembly will be loaded into the host AppDomain in order to + resolve assembly partial name. + + It is an equivalent of Evaluator.ReferenceAssembly(Assembly.Load(assemblyPartialName)) + + Name of the assembly. + + The instance of the to allow fluent interface. + + + + + References the assembly by the given namespace it implements. + + The namespace. + + Set to true if the namespace was successfully resolved (found) and the reference + was added; otherwise, false. + + + The instance of the to allow fluent interface. + + + + + References the assembly by the given namespace it implements. + + Adds assembly reference if the namespace was successfully resolved (found) and, + otherwise does nothing + + + The namespace. + + The instance of the to allow fluent interface. + + + + + The filter assemblies + + + + + Sets the filter for referenced assemblies. The filter is to be applied just before the + assemblies are to be referenced during the script execution. + + dynamic script = CSScript.Evaluator + .SetRefAssemblyFilter(asms => + asms.Where(a => !a.FullName.StartsWith("Microsoft.")) + .LoadCode(scriptCode); + + + The filter. + + + + + References the assembly by the object, which belongs to this assembly. + + It is safe to call this method multiple times for the same assembly. If the assembly + already referenced it will not be referenced again. + + + The object, which belongs to the assembly to be referenced. + + The instance of the to allow fluent interface. + + + + + References the assembly by the object, which belongs to this assembly. + + It is safe to call this method multiple times for the same assembly. If the assembly + already referenced it will not be referenced again. + + + The type which is implemented in the assembly to be referenced. + + The instance of the to allow fluent interface. + + + + + References the assemblies the are already loaded into the current AppDomain. + + The type of assemblies to be referenced. + + The instance of the to allow fluent interface. + + + + + Resets Evaluator. + + Resetting means clearing all referenced assemblies, recreating evaluation infrastructure + (e.g. compiler setting) and reconnection to or recreation of the underlying compiling services. + + + Optionally the default current AppDomain assemblies can be referenced automatically with + . + + + + if set to true the default assemblies of the current AppDomain will be referenced + (see method). + + The freshly initialized instance of the . + + + + Compiles C# file (script) into assembly file according the compiling context + specified in the argument. + Note, value will be ignored since the + script engine will only build the assembly without loading it. + + The C# script file. + The information about compilation context (e.g. location of the compiler output - + assembly and pdb file). + + The compiled assembly file path. + + + + + Evaluates (executes) the specified script text, which is a top-level C# code. + It is the most direct equivalent of "eval" available in dynamic languages. This method is only + available for Roslyn evaluator. + You can evaluate simple expressions: + + var result = CSScript.Evaluator.Eval("1 + 2"); + + Or it can be a complex script, which defines its own types: + + var calc = CSScript.Evaluator + .Eval(@"using System; + public class Script + { + public int Sum(int a, int b) + { + return a+b; + } + } + return new Script();"); + int sum = calc.Sum(1, 2); + + + Note compiles and executes the script in the current AppDoman. + All AppDomain loaded assemblies of the AppDomain being referenced from the script regardless of + setting. + During the script compilation, this method uses: + + CompileInfo.CodeKind=Microsoft.CodeAnalysis.SourceCodeKind.Script. + + This is the only option that supports script execution for applications published with + PublishSingleFile option. + + + The script text. + + The object returned by the script. + + + + + + Delegate which is used as a return type for AsmHelper.GetMethodInvoker(). + + AsmHelper.GetStaticMethod() and AsmHelper.GetMethod() allow obtaining dynamic method + delegate emitted on the base of the MethodInfo (from the compiled script type). + + Optional method parameters. + Returns MethodInfo return value + + + + Delegate which is used as a return type for AsmHelper.GetMethodInvoker(). + + AsmHelper.GetStaticMethod() and AsmHelper.GetMethod() allow obtaining dynamic method + delegate emitted on the base of the MethodInfo (from the compiled script type). + + The delegate return type. + Optional method parameters. + Returns MethodInfo return value + + + + Delegate implementing cs script statement expansion. + + The text to expand. + Returns a string with each statement variable replaced by its value. + + + + Type of the assemblies to be loaded/referenced. + + + + + No assemblies + + + + + All static current AppDomain assemblies + + + + + All static and non-GAC current AppDomain assemblies + + + + + All current AppDomain assemblies + + + + + Type of the evaluator engine. + + This enum is used to control type of compiler the generic CSScript. encapsulates. + + + + + + Roslyn compilation services + + + + + CodeDom compilation infrastructure + + + + + Runtime instantiation model for CS-Script evaluators (e.g CSScript. ). + + + + + Every time the member variable is accessed the same static object is returned. + + + + + Every time the member variable is accessed a new object is created. + + + + + Class that contains configuration options for controlling dynamic code evaluation with + CSScript. . + + + + + Gets or sets the default access type for CS-Script evaluators. + + This property controls the how the generic CS-Script evaluators are instantiated when + accessed (e.g. CSScript. or ). + + + The access. + + + + Default value of the . DebugBuild property + controlling the generation of the debug symbols. + In case of evaluator setting this property to true + will also set conditional compiling symbol `DEBUG`. + + CSScript.EvaluatorConfig.DebugBuild = true; + dynamic script = CSScript.Evaluator + .LoadMethod(... + + + + + + + Gets or sets the compiler options. Since out of two supported compilers (for hosting scenarios) only CodeDom engine (csc.exe) + supports options effectively this property is a user specified string of CLI arguments for `csc.exe`. + If you want to specify compiler options per script execution then you can use . + + + The compiler options. + + + + + Gets or sets the PDB format. This property is only used if is set to true. + + + The PDB format. + + + + + Flag that controls if the host AppDo,main referenced assemblies are automatically + referenced at creation of . + + + + + Flag that controls if the host AppDomain referenced assemblies are automatically + referenced at creation of . + Note, the assemblies are getting referenced with an automatic call + with the default argument. + This may not be consistent with your intend. If it is the case then it is recommended that you call + with the desired argument explicitly. + + + + + Gets or sets the default evaluator engine type. + + This property controls the type of compiler the generic CSScript. encapsulates. + + + The default evaluator engine. + + + + Defines a custom algorithm how to expand script code. The default implementation + calls but a host application + might define a more complex algorithm. + + + + + + + + + A generic interface of the CS-Script evaluator. It encapsulates the generic functionality of + the evaluator regardless of the nature of the underlying compiling services (e.g. Mono, + Roslyn, CodeDom). + + + + + Gets or sets a value indicating whether to compile script with debug symbols. + + Note, setting DebugBuild will only affect the current instance of Evaluator. If + you want to emit debug symbols for all instances of Evaluator then use .DebugBuild. + + + true if 'debug build'; otherwise, false. + + + + CS-Script assembly unloading functionality is implemented as a combination of loading + assembly into that is marked as + "IsCollectible" and the ReflectionExtensions. extension method. + Unloading is only available on the runtimes that support it. Otherwise throws an exception on attempt to + load the compiled script assembly. + + is designed to allow enabling/disabling of the + assembly unloading should you find that the limitations associated with this .NET Core + specific feature are not acceptable. E.g., collectible assemblies cannot be referenced + from other scripts or in fact any dynamically loaded assembly for that matter. + + + Note, using 'dynamic` completely breaks CLR unloading mechanism. Most likely it triggers + an accidental referencing of the assembly or . Meaning that if you are planing to + use assembly unloading you need to use interface based scripting. See `Test_Unloading` + (https://github.com/oleg-shilo/cs-script/blob/master/src/CSScriptLib/src/Client.NET-Core/Program.cs) + sample for details. + + + + + + This property controls script caching. + Caching mechanism allows avoiding multiple compilation of the scripts that have been already compiled and has not changes + since then for the duration of the host process. This feature can dramatically improve the performance in the cases when you are executing + the same script again and again. Even though in such cases caching is not the greatest optimization that can be achieved. + Note that caching has some limitations. Thus the algorithm for checking if the script is changed since the last execution + is limited to verifying the script code (text) only. Thus it needs to be used with caution. + Script caching is disabled by default. + + The following is an example of caching the compilation. + + dynamic printerScript = CSScript.Evaluator + .With(eval => eval.IsCachingEnabled = true) + .LoadFile(script_file); + printerScript.Print(); + + + + + + Gets or sets the flag indicating if the script code should be analyzed and the + assemblies that the script depend on (via '//css_...' and 'using ...' directives) should + be referenced. + + + + + + Evaluates (compiles) C# code (script). The C# code is a typical C# code containing a single or multiple class definition(s). + + + + Assembly asm = CSScript.Evaluator + .CompileCode(@"using System; + public class Script + { + public int Sum(int a, int b) + { + return a+b; + } + }"); + + dynamic script = asm.CreateObject("*"); + var result = script.Sum(7, 3); + + + The C# script text. + The information about compilation context (e.g. location of the compiler output - + assembly and pdb file). + The compiled assembly. + + + + Compiles the specified script text without loading it into the AppDomain or + writing to the file system. + + + + try + { + CSScript.Evaluator + .Check(@"using System; + public class Script + { + public int Sum(int a, int b) + { + error + return a+b; + } + }"); + } + catch (Exception e) + { + Console.WriteLine("Compile error: " + e.Message); + } + + + The script text. + + + + Compiles C# code (script) into assembly file. The C# code is a typical C# code containing a single or multiple class definition(s). + + + + string asmFile = CSScript.Evaluator + .CompileAssemblyFromCode( + @"using System; + public class Script + { + public int Sum(int a, int b) + { + return a+b; + } + }", + "MyScript.dll"); + + + The C# script text. + The path to the assembly file to be compiled. + The compiled assembly file path. + + + + Compiles C# file (script) into assembly file. The C# contains typical C# code containing a single or multiple class definition(s). + + + + string asmFile = CSScript.Evaluator + .CompileAssemblyFromFile( + "MyScript.cs", + "MyScript.dll"); + + + The C# script file. + The path to the assembly file to be compiled. + The compiled assembly file path. + + + + Compiles C# file (script) into assembly file according the compiling context + specified in the argument. + Note, value will be ignored since the + script engine will only build the assembly without loading it. + + The C# script file. + The information about compilation context (e.g. location of the compiler output - + assembly and pdb file). + The compiled assembly file path. + + + + Wraps C# code fragment into auto-generated class (type name DynamicClass) and evaluates it. + + This method is a logical equivalent of but is allows you to define + your script class by specifying class method instead of whole class declaration. + + + + dynamic script = CSScript.Evaluator + .CompileMethod(@"int Sum(int a, int b) + { + return a+b; + }") + .CreateObject("*"); + + var result = script.Sum(7, 3); + + + The C# code. + The compiled assembly. + + + + Sets the filter for referenced assemblies. The filter is to be applied just before the + assemblies are to be referenced during the script execution. + + dynamic script = CSScript.Evaluator + .SetRefAssemblyFilter(asms => + asms.Where(a => !a.FullName.StartsWith("Microsoft.")) + .LoadCode(scriptCode); + + + The filter. + + + + + Wraps C# code fragment into auto-generated class (type name DynamicClass), + evaluates it and loads the class to the current AppDomain. + + Returns non-typed for class-less style of invoking. + + + + + var log = CSScript.Evaluator + .CreateDelegate(@"void Log(string message) + { + Console.WriteLine(message); + }"); + + log("Test message"); + + + The C# code. + The instance of a 'duck typed' + + + + Wraps C# code fragment into auto-generated class (type name DynamicClass), + evaluates it and loads the class to the current AppDomain. + + Returns typed for class-less style of invoking. + + + The delegate return type. + + + var product = CSScript.Evaluator + .CreateDelegate<int>(@"int Product(int a, int b) + { + return a * b; + }"); + + int result = product(3, 2); + + + The C# code. + The instance of a typed + + + + Analyses the script code and returns set of locations for the assemblies referenced from + the code with CS-Script directives (//css_ref). + + The script code. + The assembly search/probing directories. + Array of the referenced assemblies + + + + Returns set of referenced assemblies. + Notre: the set of assemblies is cleared on Reset. + + The method result. + + + + Evaluates and loads C# code to the current AppDomain. Returns instance of the first class defined in the code. + + The following is the simple example of the LoadCode usage: + + dynamic script = CSScript.Evaluator + .LoadCode(@"using System; + public class Script + { + public int Sum(int a, int b) + { + return a+b; + } + }"); + int result = script.Sum(1, 2); + + + The C# script text. + The non default constructor arguments. + Instance of the class defined in the script. + + + + Evaluates and loads C# code to the current AppDomain. Returns instance of the first class defined in the code. + + The following is the simple example of the interface alignment: + + public interface ICalc + { + int Sum(int a, int b); + } + .... + ICalc calc = CSScript.Evaluator + .LoadCode<ICalc>(@"using System; + public class Script + { + public int Sum(int a, int b) + { + return a+b; + } + }"); + int result = calc.Sum(1, 2); + + + The type of the script class instance should be type casted to. + The C# script text. + The non default type T constructor arguments. + Type-casted to the T interface instance of the class defined in the script. + + + + Evaluates (executes) the specified script text, which is a top-level C# code. + It is the most direct equivalent of "eval" available in dynamic languages. This method is only + available for Roslyn evaluator. + You can evaluate simple expressions: + + var result = CSScript.Evaluator.Eval("1 + 2"); + + Or it can be a complex script, which defines its own types: + + var calc = CSScript.Evaluator + .Eval(@"using System; + public class Script + { + public int Sum(int a, int b) + { + return a+b; + } + } + + return new Script();"); + + int sum = calc.Sum(1, 2); + + + Note compiles and executes the script in the current AppDoman. + All AppDomain loaded assemblies of the AppDomain being referenced from the script regardless of + setting. + During the script compilation, this method uses: + + CompileInfo.CodeKind=Microsoft.CodeAnalysis.SourceCodeKind.Script. + + This is the only option that supports script execution for applications published with + PublishSingleFile option. + + + The script text. + The object returned by the script. + + + + Wraps C# code fragment into auto-generated class (type name DynamicClass), + evaluates it and loads the class to the current AppDomain. + + Returns instance of T delegate for the first method in the auto-generated class. + + + + + var Product = CSScript.Evaluator + .LoadDelegate<Func<int, int, int>>( + @"int Product(int a, int b) + { + return a * b; + }"); + + int result = Product(3, 2); + + + The C# code. + Instance of T delegate. + + + + Evaluates and loads C# code from the specified file to the current AppDomain. Returns instance of the first + class defined in the script file assembly. + + Note, the order of the classes in the script assembly is not may not be your script imports other scripts. + In such cases you may prefer using or + instead. + + + The following is the simple example of the interface alignment: + + dynamic script = CSScript.Evaluator + .LoadFile("calc.cs"); + + int result = script.Sum(1, 2); + + + The C# script file. + Optional non-default constructor arguments. + Instance of the class defined in the script file assembly. + + + + Evaluates and loads C# code from the specified file to the current AppDomain. Returns instance of the first + class defined in the script file assembly. + + After initializing the class instance it is aligned to the interface specified by the parameter T. + Note: the script class does not have to inherit from the T parameter as the proxy type + will be generated anyway. + + + Note, the order of the classes in the script assembly is not may not be your script imports other scripts. + In such cases you may prefer using or + instead. + + + The following is the simple example of the interface alignment: + + public interface ICalc + { + int Sum(int a, int b); + } + .... + ICalc calc = CSScript.Evaluator + .LoadFile<ICalc>("calc.cs"); + + int result = calc.Sum(1, 2); + + + The type of the interface type the script class instance should be aligned to. + The C# script text. + Optional non-default constructor arguments. + Aligned to the T interface instance of the class defined in the script file assembly. + + + + Wraps C# code fragment into auto-generated class (type name DynamicClass), + evaluates it and loads the class to the current AppDomain. + + + The following is the simple example of the LoadMethod usage: + + dynamic script = CSScript.Evaluator + .LoadMethod(@"int Product(int a, int b) + { + return a * b; + }"); + + int result = script.Product(3, 2); + + + The C# script text. + Instance of the first class defined in the script assembly. + + + + Wraps C# code fragment into auto-generated class (type name DynamicClass), + evaluates it and loads the class to the current AppDomain. + + After initializing the class instance it is aligned to the interface specified by the + parameter T. + + + + The following is the simple example of the interface alignment: + + public interface ICalc + { + int Sum(int a, int b); + int Div(int a, int b); + } + .... + ICalc script = CSScript.Evaluator + .LoadMethod<ICalc>(@"public int Sum(int a, int b) + { + return a + b; + } + public int Div(int a, int b) + { + return a/b; + }"); + + int result = script.Div(15, 3); + + + + The type of the interface type the script class instance should be aligned to. + + The C# script text. + + Aligned to the T interface instance of the auto-generated class defined in the script. + + + + + References the assemblies from the script code. + + The method analyses and tries to resolve CS-Script directives (e.g. '//css_ref') and + 'used' namespaces based on the optional search directories. + + + The script code. + The assembly search/probing directories. + + The instance of the to allow fluent interface. + + + + + References the given assembly by the assembly path. + + It is safe to call this method multiple times for the same assembly. If the assembly + already referenced it will not be referenced again. + + + The path to the assembly file. + + The instance of the to allow fluent interface. + + + + + References the given assembly. + + It is safe to call this method multiple times for the same assembly. If the assembly + already referenced it will not be referenced again. + + + The assembly instance. + + The instance of the to allow fluent interface. + + + + + References the name of the assembly by its partial name. + + Note that the referenced assembly will be loaded into the host AppDomain in order to + resolve assembly partial name. + + It is an equivalent of Evaluator.ReferenceAssembly(Assembly.LoadWithPartialName(assemblyPartialName)) + + Partial name of the assembly. + + The instance of the to allow fluent interface. + + + + + References the assembly by the given namespace it implements. + + The namespace. + + Set to true if the namespace was successfully resolved (found) and the reference + was added; otherwise, false. + + + The instance of the to allow fluent interface. + + + + + References the assembly by the given namespace it implements. + + Adds assembly reference if the namespace was successfully resolved (found) and, + otherwise does nothing + + + The namespace. + + The instance of the to allow fluent interface. + + + + + References the assembly by the object, which belongs to this assembly. + + It is safe to call this method multiple times for the same assembly. If the assembly + already referenced it will not be referenced again. + + + The object, which belongs to the assembly to be referenced. + + The instance of the to allow fluent interface. + + + + + References the assembly by the object, which belongs to this assembly. + + It is safe to call this method multiple times for the same assembly. If the assembly + already referenced it will not be referenced again. + + + The type which is implemented in the assembly to be referenced. + + The instance of the to allow fluent interface. + + + + + References the assemblies the are already loaded into the current AppDomain. + + The type of assemblies to be referenced. + + The instance of the to allow fluent interface. + + + + + Resets Evaluator. + + Resetting means clearing all referenced assemblies, recreating evaluation infrastructure + (e.g. compiler setting) and reconnection to or recreation of the underlying compiling services. + + + Optionally the default current AppDomain assemblies can be referenced automatically with + . + + + + if set to true the default assemblies of the current AppDomain will be referenced + (see method). + + The freshly initialized instance of the . + + + + Clones the parent . + + This method returns a freshly initialized copy of the . + The cloning 'depth' can be controlled by the . + + + This method is a convenient technique when multiple instances + are required (e.g. for concurrent script evaluation). + + + if set to true all referenced assemblies from the parent + will be referenced in the cloned copy. + The freshly initialized instance of the . + + + var eval1 = CSScript.Evaluator.Clone(); + var eval2 = CSScript.Evaluator.Clone(); + + var sub = eval1.LoadDelegate<Func<int, int, int>>( + @"int Sub(int a, int b) { + return a - b; + }"); + + var sum = eval2.LoadDelegate<Func<int, int, int>>( + @"int Sub(int a, int b) { + return a + b; + }"); + + var result = sum(7, sub(4,2)); + + + + + + Some convenient extension methods for working with . + + + + + Sets referenced assemblies filter for exclusion of some "undesired" assemblies. It is a + convenient method for fine controlling referencing assemblies but without specifying the + complete predicates with . + + dynamic script = CSScript.Evaluator + .ExcludeReferencedAssemblies(new[]{this.GetType().Assembly}) + .LoadCode(scriptCode); + + + The evaluator. + The excluded assemblies. + + + + + Sets referenced assemblies filter for exclusion of some "undesired" assemblies. It is a + convenient method for fine controlling referencing assemblies but without specifying the + complete predicates with . + + dynamic script = CSScript.Evaluator + .ExcludeReferencedAssemblies(this.GetType().Assembly) + .LoadCode(scriptCode); + + + The evaluator. + The excluded assemblies. + + + + + CSScriptLib is compiled as nets standard so some .NETCore API is not available. + So filling the gaps... + + + + + + + Escapes the CS-Script directive (e.g. //css_*) delimiters. + 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. + The correct syntax would be as follows '//css_include script((today)).cs;' + The delimiters characters are ';,(){}'. + However you should check for the accurate list of all delimiters. + + + + The text to be processed. + The escaped string. + + + + Selects the first element that satisfies the specified path. + + The element. + The path. + Selected XML element + + + + Removes the duplicated file system path items from the collection.The duplicates are + identified based on the path being case sensitive depending on the hosting OS file system. + + The list. + A list with the unique items + + + + Determines whether [is shared assembly]. + + The path. + true if [is shared assembly] [the specified path]; otherwise, false. + + + + Converts to bool. + + The text. + Conversion result + + + + Removes the assembly extension. + + Name of the asm. + Result of the string manipulation + + + + Compares two path strings. Handles path being case-sensitive based on the OS file system. + + The path1. + The path2. + The result of the test. + + + + Captures the exception dispatch information. + + The ex. + Processed exception instanse + + + + Files the delete. + + The file path. + if set to true [rethrow]. + + + + Converts an array to a tuple. + Based on this beautiful solution: https://stackoverflow.com/questions/49190830/is-it-possible-for-string-split-to-return-tuple + + + The list. + The first. + + + + + Converts an array to a tuple. + Based on this beautiful solution: https://stackoverflow.com/questions/49190830/is-it-possible-for-string-split-to-return-tuple + + The list. + The first. + The second. + The rest. + + + + ParsingParams is a class that holds parsing parameters (parameters that controls how file is + to be parsed). At this moment they are namespace renaming rules only. + + + + + Compare() is to be used to help with implementation of IComparer for sorting operations. + + + + + Class which is a placeholder for general information of the script file + + + + + Constructor + + + ImportInfo object containing the information how the script file should be parsed. + + + + + Class that implements parsing the single C# script file + + + + + Searches for script file by given script name. Calls ResolveFile(string fileName, + string[] extraDirs, bool throwOnError) with throwOnError flag set to true. + + + + + The resolve file algorithm, + + The default algorithm searches for script file by given script name. Search order: + 1. Current directory + 2. extraDirs (usually %CSSCRIPT_ROOT%\Lib and ExtraLibDirectory) + 3. PATH Also fixes file name if user did not provide extension for script file (assuming + .cs extension) + + + + + + Searches for script file by given script name. Search order: + 1. Current directory + 2. extraDirs (usually %CSSCRIPT_ROOT%\Lib and ExtraLibDirectory) + 3. PATH Also fixes file name if user did not provide extension for script file (assuming + .cs extension) + + If the default implementation isn't suitable then you can set + FileParser.ResolveFilesAlgorithm to the alternative implementation of the probing algorithm. + + + + + + Class that implements parsing the single C# Script file + + + Implementation of the IComparer for sorting operations of collections of FileParser instances + + + + + Class that holds all information about the execution context (probing directories and + dependencies) of a script. + + + + + Primary script that defines the project. + + + + + List of all C# sources defined by the project. This includes the primary script itself + and all other scripts files the imported/included by the primary script. + + + + + List of assemblies the script of the project is referencing. + + + + + List of search folders where CS-Script does probing for imported/included scripts and assemblies. + + + + + Generates the top level view project for a given script. + + Note this method uses the same algorithm as CS-Script executor but it deliberately + doesn't include cached directories and auto-generated files. This method is to be used + by IDs and tools. + + + The script. + The project instance + + + + Gets the CSS configuration. Used by ST3 Syntaxer + + Default config file location + + + + Class that manages parsing the main and all imported (if any) C# Script files + + + + + Gets the script parsing context. This object is effectively a parsing result. + + Parsing result + + + + Processes the imported script. Processing involves lookup for 'static Main' and renaming + it so it does not interfere with the 'static Main' of the primary script. After renaming + is done the new content is saved in the CS-Script cache and the new file location is + returned. The saved file can be used late as an "included script". This technique can be + from 'precompiler' scripts. + + If the script file does not require renaming (static Main is not present) the method + returns the original script file location. + + + The script file. + Path to the script file to be compiled and executed + + + + ApartmentState of a script during the execution (default: ApartmentState.Unknown) + + + + + Collection of the files to be compiled (including dependent scripts) used for script compilation/execution. + + + + + Collection of the imported files (dependent scripts) that were used for script execution. + Note, some of the imported scripts can be temporary files containing scripts processed + according the importing specification (e.g. renamed `static Main`, renamed namespaces). + Use for the names of the original names of the imported scripts + + + + + Collection of the imported files (dependent scripts). + Note, some of the imported scripts can be converted in the temporary files containing scripts processed + according the importing specification (e.g. renamed `static Main`, renamed namespaces). + Use and/or for the names of the actual + files used on compilation/execution. + + + + + Collection of resource files referenced from code + + + + + Collection of compiler options + + + + + Precompilers specified in the primary script file. + + + + + Collection of namespaces referenced from code (including those referenced in dependent scripts) + + + + + Collection of namespaces, which if found in code, should not be resolved into referenced assembly. + + + + + Resolves the NuGet packages into assemblies to be referenced by the script. + + If the package was never installed/downloaded yet CS-Script runtime will try to download it. + + + CS-Script will also analyze the installed package structure in try to reference + compatible assemblies from the package. + + + + if set to true suppresses downloading the NuGet package. Suppressing can be + useful for the quick 'referencing' assessment. + + Collection of the referenced assembly files. + + + + Collection of the NuGet packages + + + + + Collection of referenced assemblies. All assemblies are referenced either from + command-line, code or resolved from referenced namespaces. + + + + + Constructor. + + Script file name + + + + Constructor. + + Script file name + Extra ScriptLibrary directory + + + + Constructor. + + Script file name + Extra ScriptLibrary directory(s) + + flag to indicate if the file parsing/processing error should raise an exception + + + + + The path of the parsed script. + + + + + Gets a value indicating whether the script being parsed is a web application script. + + true if the script is web application; otherwise, false. + + + + Initialization of ScriptParser instance + + Script file name + Extra ScriptLibrary directory(s) + + + + Saves all imported scripts in the temporary location. + + Collection of the saved imported scripts file names + + + + Deletes imported scripts as a cleanup operation + + + + + CS-Script SearchDirectories specified in the parsed script or its dependent scripts. + + + + + Aggregates the references from the script and its imported scripts. It is a logical + equivalent of CSExecutor.AggregateReferencedAssemblies but optimized for later .NET + versions (e.g LINQ) and completely decoupled. Thus it has no dependencies on internal + state (e.g. settings, options.shareHostAssemblies). + + It is the method to call for generating list of ref asms as part of the project info. + + + The search dirs. + The default ref asms. + The default namespaces. + List of references + + + + Information about the script parsing result. + + + + + The packages referenced from the script with `//css_nuget` directive + + + + + The referenced resources referenced from the script with `//css_res` directive + + + + + The referenced assemblies referenced from the script with `//css_ref` directive + + + + + The namespaces imported with C# `using` directive + + + + + The namespaces that are marked as "to ignore" with `//css_ignore_namespace` directive + + + + + The compiler options specified with `//css_co` directive + + + + + The directories specified with `//css_dir` directive + + + + + The precompilers specified with `//css_pc` directive + + + + + All files that need to be compiled as part of the script execution. + + + + + The time of parsing. + + + + + Collection of temp files to be removed during cleanup + + + + + Gets or sets the items (file paths) composing the temporary files collections. + + The items. + + + + Clears the collection. + + + + + A class that hosts the most common properties of the runtime environment. + + + + + Occurs when an exception is not caught. + + + + + Returns the name of the temporary folder in the CSSCRIPT subfolder of Path.GetTempPath(). + + Under certain circumstances it may be desirable to the use the alternative location for + the CS-Script temporary files. In such cases use SetScriptTempDir() to set the + alternative location. + + + Temporary directory name. + + + + Cleans the abandoned script execution cache. + + + + + Cleans the exited scripts. + + + + + The delegate for creating unloadable assembly load + context. The delegate is required to be set from the host process at runtime. It is + because it is not available at compile time since CSScriptLib assembly is compiled as + '.NET Standard 2.0' which does not implement but its + abstract type only. + + CS-Script uses intensive reflection technique to retrieve the host environment implementation. So you no not need to set it. + + + + + + Cleans the snippets. + + + + + Cleans the unused temporary files. + + The dir. + The pattern. + if set to true [verify pid]. + + + + Gets the nuget cache path in the form displayable in Console. + + The nu get cache view. + + + + Gets a value indicating whether the host OS Windows. + + true if the host OS is Windows; otherwise, false. + + + + Note it is not about OS being exactly Linux but rather about OS having Linux type of + file system. For example path being case sensitive + + + + + Gets a value indicating whether this process is an application compiled as a single file (published with PublishSingleFile option). + + + true if this instance is single file application; otherwise, false. + + + + + Gets a value indicating whether the runtime is core. + + true if the runtime is core; otherwise, false. + + + + Returns path to the `Microsoft.WindowsDesktop.App` shared assemblies of the compatible + runtime version. + + Note, there is no warranty that the dotnet dedktop assemblies belong to the same distro + version as dotnet Core: + - C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.0-rc.1.20451.14 + - C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\5.0.0-rc.1.20452.2 + + + + + + Returns path to the `Microsoft.AspNetCore.App` shared assemblies of the compatible + runtime version. + + + + + Determines whether .NET SDK is installed. + + true if [is SDK installed]; otherwise, false. + + + + Gets the directories specified by either relative or absolute path `rootDir`. + `rootDir` can contain wild-cards as per Git 'ignore specification' + + The working dir. + The root dir path as per Git 'ignore specification'. + The method result. + + + + Delegate implementing source file probing algorithm. + + The file. + The extra dirs. + if set to true [throw on error]. + Location of the files matching the resolution input. + + + + Delegate implementing assembly file probing algorithm. + + The file. + The extra dirs. + Location of the files matching the resolution input. + + + + Utility class for assembly probing. + + + + + File to be excluded from assembly search + + + + + Determines whether the string is a legal path token. + + The name. + + true if the string is a legal path token; otherwise, false. + + + + + Resolves namespace/assembly(file) name into array of assembly locations (local and GAC ones). + + 'namespace'/assembly(file) name + Assembly search directories + If the default implementation isn't suitable then you can set CSScript.FindAssemblyAlgorithm + to the alternative implementation of the probing algorithm. + collection of assembly file names where namespace is implemented + + + + Resolves namespace into array of local assembly locations. + (Currently it returns only one assembly location but in future + it can be extended to collect all assemblies with the same namespace) + + namespace/assembly name + directory + collection of assembly file names where namespace is implemented + + + + Resolves namespace into array of global assembly (GAC) locations. + NOTE: this method does nothing on .NET Core as it offers no GAC discovery mechanism. + + 'namespace' name + collection of assembly file names where namespace is implemented + + + + A strongly-typed resource class, for looking up localized strings, etc. + + + + + Returns the cached ResourceManager instance used by this class. + + + + + Overrides the current thread's CurrentUICulture property for all + resource lookups using this strongly typed resource class. + + + + + Looks up a localized resource of type System.Byte[]. + + + + + Looks up a localized resource of type System.Byte[]. + + + + + Looks up a localized resource of type System.Byte[]. + + + + + + + + + + Gets or sets the collection of the temporary files that the runtime will delete on the application exit. + + + The temporary files. + + + + + Gets or sets the probing directories to be used for assembly probings. + + + The probing directories. + + + + + Gets or sets the compiled assembly. + + + The compiled assembly. + + + + + Gets or sets the errors. + + + The errors. + + + + + Gets or sets the output. + + + The output. + + + + + Gets or sets the path to assembly. + + + The path to assembly. + + + + + Gets or sets the native compiler return value, which is a process exit code of the compiler executable (e.g. dotnet.exe). + + + The native compiler return value. + + + + + + + + + + Gets or sets the line number of the syntax causing the error. + + + The line. + + + + + Gets or sets the column number of the syntax causing the error. + + + The column. + + + + + Gets or sets the error number. + + + The error number. + + + + + Gets or sets the error text. + + + The error text. + + + + + Gets or sets a value indicating whether this instance of the error is a warning. + + + true if this instance is warning; otherwise, false. + + + + + Gets or sets the name of the file causing the error. + + + The name of the file. + + + + + Parses the specified compiler output. + + The compiler output. + Error object + + + + Various LINQ extensions + + + + + None of the items matches the specified predicate. + + + The items. + The predicate. + Result of the test + + + + Adds a single item to the collection. + + The type of the source. + The items. + The item. + The original collection instance. + + + + Determines whether the collection is empty. + + + The collection. + + true if the specified collection is empty; otherwise, false. + + + + + A generic LINQ equivalent of C# foreach loop. + + + The collection. + The action. + The original collection instance + + + + A generic LINQ equivalent of C# foreach loop with support for the item index. + + + The collection. + The action. + + + + + Allows updating the object in Fluent expressions. + + + The object. + The action. + + + + + Various PATH extensions + + + + + Copies the file. + + The source path to the file. + The destination path to the file. + if set to true [ignore errors]. + + + + Changes the extension of the file. + + The path. + The extension. + A new path + + + + Gets the extension. + + The path. + File extension + + + + Gets the file name part of the full path. + + The path. + The method result. + + + + Checks if the directory exists. + + The path. + The result of the test. + + + + Gets the full path. + + The path. + The path + + + + Determines whether the path is directory. + + The path. + + true if the specified path is dir; otherwise, false. + + + + + Determines whether the specified path string is valid (does not contain invalid characters). + + The path. + + true if the path is valid; otherwise, false. + + + + + A more convenient API version of . + + The path. + The parts. + A new path. + + + + Gets the special folder path. + + The folder. + A folder path. + + + + Gets the special folder path combined with an array of strings into a path. + + The folder. + The parts. + + + + + Ensures the directory exists. + + The path. + if set to true [rethrow]. + Path of the created/existing directory + + + + Ensures the parent directory of the file exists. + + The file path. + if set to true [rethrow]. + Path of the file + + + + Deletes the directory and its all content. + + The path. + if set to true [handle exceptions]. + if set to true [do not deletе root]. + + The original directory path + + + + + Checks if the file exists. + + The path. + The result of the test. + + + + Gets the directory name from the path. + + The path. + The directory path. + + + + Changes the name of the file. + + The path. + Name of the file. + A new path. + + + + Gets the file name without the extension. + + The path. + File name + + + + Normalizes directory separators in the given path by ensuring the separators are compatible with the target file system. + + The path. + A new normalized path. + + + + Gets the subdirectories of the specified directory path. + + The path. + The mask. + A list of the discovered directories. + + + + The configuration and methods of the global context. + + + + + Removes the build server from the target system. + + true if success; otherwise false + + + + Deploys the build server on the target system. + + + + + Pings the running instance of the build server. + + + + + Gets a value indicating whether build server is deployed. + + true if build server is deployed; otherwise, false. + + + + Gets the path to the assembly implementing Roslyn compiler. + + + + + Gets the path to the dotnet executable. + + The dotnet executable path. + + + + Gets the path to the csc.exe executable for .NET Framework. + + The csc.exe executable path. + + + + Gets or sets the path to the C# compiler executable (e.g. csc.exe or csc.dll) + + The CSC. + + + + Various Reflection extensions for implementing assembly unloading + + + + + Retrieves associated with the assembly and unloads it. + It will throw an exception if the is not created as + unloadable ('IsCollectible'). + Use to control + how the assemblies (compiled scripts) are loaded. + + Note, unloading of assembly is implemented by CLR not CS-Script. This method extension is simply + redirecting the call to the .NET + . Thus it is subject of the + underlying limitations. Thus an AssemblyLoadContext can only be unloaded if it is collectible. And + Unloading will occur asynchronously. + + + Note, using 'dynamic` completely breaks CLR unloading mechanism. Most likely it triggers + an accidental referencing of the assembly or . Meaning that if you are planing to + use assembly unloading you need to use interface based scripting. See `Test_Unloading` + (https://github.com/oleg-shilo/cs-script/blob/master/src/CSScriptLib/src/Client.NET-Core/Program.cs) + sample for details. + + + + + + + Various Reflection extensions + + + + + Returns directory where the specified assembly file is. + + The asm. + The directory path + + + + Returns location of the specified assembly. Avoids throwing an exception in case + of dynamic assembly. + + The asm. + The path to the assembly file + + + + Gets the name of the type. + + The type. + Thew name of the type. + + + + Creates instance of a class from underlying assembly. + + The asm. + The 'Type' full name of the type to create. (see Assembly.CreateInstance()). + You can use wild card meaning the first type found. However only full wild card "*" is supported. + The non default constructor arguments. + + Instance of the 'Type'. Throws an ApplicationException if the instance cannot be created. + + + + + Creates instance of a Type from underlying assembly. + + The asm. + Name of the type to be instantiated. Allows wild card character (e.g. *.MyClass can be used to instantiate MyNamespace.MyClass). + The non default constructor arguments. + + Created instance of the type. + + Type " + typeName + " cannot be found. + + + + Determines whether the assembly is dynamic. + + The asm. + + true if the specified asm is dynamic; otherwise, false. + + + + + Class for automated assembly probing. It implements extremely simple ('optimistic') + probing algorithm. At runtime it attempts to resolve the assemblies via AppDomain.Assembly resolve + event by looking up the assembly files in the user defined list of probing directories. + The algorithm relies on the simple relationship between assembly name and assembly file name: + <assembly file> = <asm name> + ".dll" + + The following is an example of automated assembly probing. + + using (SimpleAsmProbing.For(@"E:\Dev\Libs", @"E:\Dev\Packages")) + { + dynamic script = CSScript.Evaluator + .LoadFile(script_file); + script.Print(); + } + + + + + + + Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + + + + + Releases unmanaged and - optionally - managed resources. + + true to release both managed and unmanaged resources; false to release only unmanaged resources. + + + + Finalizes an instance of the class. + + + + + Initializes a new instance of the class. + + + + + Creates and initializes a new instance of the class. + + The probing dirs. + + + + + Initializes a new instance of the class. + + The probing dirs. + + + + Sets probing dirs and subscribes to the event. + + The probing dirs. + + + + Unsubscribes to the event. + + + + + Various string extensions + + + + + Determines whether the string is empty (or null). + + The text. + + true if the specified text is empty; otherwise, false. + + + + + Determines whether the string is not empty (or null). + + The text. + + true if [is not empty] [the specified text]; otherwise, false. + + + + + Determines whether this instance has text. + + The text. + + true if the specified text has text; otherwise, false. + + + + + Trims a single character form the head and the end of the string. + + The text. + The trim chars. + The result of trimming. + + + + Gets the lines. + + The string. + The method result. + + + + Determines whether this string contains the substring defined by the pattern. + + The text. + The pattern. + if set to true [ignore case]. + + true if [contains] [the specified pattern]; otherwise, false. + + + + + Compares two strings. + + The text. + The pattern. + if set to true [ignore case]. + The result of the test. + + + + Checks if the given string matches any of the provided patterns. + + The text. + The patterns + The method result. + + + + Joins strings the by the specified separator. + + The values. + The separator. + The method result. + + + + The custom implementation of the method. + + The text to generate the hash for.s. + The method result. + +
+