DynamicScriptExecutor 1.7.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package DynamicScriptExecutor --version 1.7.0
NuGet\Install-Package DynamicScriptExecutor -Version 1.7.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DynamicScriptExecutor" Version="1.7.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DynamicScriptExecutor" Version="1.7.0" />
<PackageReference Include="DynamicScriptExecutor" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DynamicScriptExecutor --version 1.7.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DynamicScriptExecutor, 1.7.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DynamicScriptExecutor@1.7.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DynamicScriptExecutor&version=1.7.0
#tool nuget:?package=DynamicScriptExecutor&version=1.7.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
DynamicScriptExecutor
<img src="https://www.nuget.org/Content/gallery/img/logo-header.svg?sanitize=true" height="30px">
Enables exectime execution of C#/VB.NET scripts without pre-compilation. Supports Func delegate generation, DLLs, flexible exec options, and async capabilities.
Download
DynamicScriptExecutor is available as Nuget Package now.
Getting started
Hello World
string codeHelloWorld = @" using System; class Exec { public void Main() { Console.WriteLine(""Hello World""); } } "; DynamicScriptExecutor.ScriptExecutor.Exec(codeHelloWorld); // Hello World If you want to hold an InstanceObject
string codeStatic = @" using System; public static class Exec { public static int count = 1; public static void Main() { Console.WriteLine(""Hello World Static: "" + count++); } } "; ExecOption execOptionStatic = new ExecOption() { IsStatic = true }; execOptionStatic.InstanceObject = new InstanceObject(codeStatic, execOptionStatic); ScriptExecutor.Exec(execOptionStatic); // Hello World Static: 1 ScriptExecutor.Exec(execOptionStatic); // Hello World Static: 2 If you want to create delegate
string codeDelegateHelloWorld = @" using System; public class Exec { public string DelegateHelloWorldFunc() { return ""Delegate Hello World""; } } "; var DelegateHelloWorldFunc = DynamicScriptExecutor.ScriptExecutor.GenerateFunc<string>(codeDelegateHelloWorld, new ExecOption() { MethodName = "DelegateHelloWorldFunc" }); Console.WriteLine(DelegateHelloWorldFunc(null)); // Delegate Hello World If you only want to write functions and don't want to write using statement
string codeGenerateClassWithFunction = @" public ExternalResultClass DoSth() { return ExternalClass.DoSth(); } "; ExecOption generateClassWithFunctionOption = new ExecOption(); generateClassWithFunctionOption.ExtraDllFileList = new List<string> { "ExternalDll.dll" }; generateClassWithFunctionOption.MethodName = "DoSth"; string codeGeneratedClassWithFunction = ScriptExecutor.GenerateClassWithFunction(codeGenerateClassWithFunction, generateClassWithFunctionOption); API
ScriptExecutor
object Exec(string code, ExecOption execOption = null) Task<object> ExecAsync(string code, ExecOption execOption = null) object Exec(ICollection<string> codeList, ExecOption execOption = null) Task<object> ExecAsync(ICollection<string> codeList, ExecOption execOption = null) object Exec(ExecOption execOption) Task<object> ExecAsync(ExecOption execOption) Func<object[], object> GenerateFunc(string code, ExecOption execOption = null) Func<object[], object> GenerateFunc(ExecOption execOption) Func<object[], TResult> GenerateFunc<TResult>(string code, ExecOption execOption = null) Func<object[], TResult> GenerateFunc<TResult>(ExecOption execOption) Func<T1, TResult> GenerateFunc<T1, TResult>(string code, ExecOption execOption = null) Func<T1, TResult> GenerateFunc<T1, TResult>(ExecOption execOption) Func<T1, T2, TResult> GenerateFunc<T1, T2, TResult>(string code, ExecOption execOption = null) Func<T1, T2, TResult> GenerateFunc<T1, T2, TResult>(ExecOption execOption) Func<T1, T2, T3, TResult> GenerateFunc<T1, T2, T3, TResult>(string code, ExecOption execOption = null) Func<T1, T2, T3, TResult> GenerateFunc<T1, T2, T3, TResult>(ExecOption execOption) Func<T1, T2, T3, T4, TResult> GenerateFunc<T1, T2, T3, T4, TResult>(string code, ExecOption execOption = null) Func<T1, T2, T3, T4, TResult> GenerateFunc<T1, T2, T3, T4, TResult>(ExecOption execOption) Func<T1, T2, T3, T4, T5, TResult> GenerateFunc<T1, T2, T3, T4, T5, TResult>(string code, ExecOption execOption = null) Func<T1, T2, T3, T4, T5, TResult> GenerateFunc<T1, T2, T3, T4, T5, TResult>(ExecOption execOption) Func<T1, T2, T3, T4, T5, T6, TResult> GenerateFunc<T1, T2, T3, T4, T5, T6, TResult>(string code, ExecOption execOption = null) Func<T1, T2, T3, T4, T5, T6, TResult> GenerateFunc<T1, T2, T3, T4, T5, T6, TResult>(ExecOption execOption) Func<T1, T2, T3, T4, T5, T6, T7, TResult> GenerateFunc<T1, T2, T3, T4, T5, T6, T7, TResult>(string code, ExecOption execOption = null) Func<T1, T2, T3, T4, T5, T6, T7, TResult> GenerateFunc<T1, T2, T3, T4, T5, T6, T7, TResult>(ExecOption execOption) Func<T1, T2, T3, T4, T5, T6, T7, T8, TResult> GenerateFunc<T1, T2, T3, T4, T5, T6, T7, T8, TResult>(string code, ExecOption execOption = null) Func<T1, T2, T3, T4, T5, T6, T7, T8, TResult> GenerateFunc<T1, T2, T3, T4, T5, T6, T7, T8, TResult>(ExecOption execOption) Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult> GenerateFunc<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult>(string code, ExecOption execOption = null) Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult> GenerateFunc<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult>(ExecOption execOption) Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult> GenerateFunc<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult>(string code, ExecOption execOption = null) Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult> GenerateFunc<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult>(ExecOption execOption) string GenerateClassWithFunction(string code, ExecOption execOption = null) string GenerateClassWithFunction(string code, ICollection<string> extraDllNamespaces, ExecOption execOption = null) DllHelper
FileSystemInfo[] GetDllInfos(string path) ICollection<string> GetExtraDllNamespaces(ExecOption execOption) InstanceObject
InstanceObject
InstanceObject(string code, ExecOption execOption = null) InstanceObject(ICollection<string> codeList, ExecOption execOption = null) Options
ExecOption
ExecOption(object[] paramList = null , ICollection<string> extraDllFolderList = null , ICollection<string> extraDllFileList = null , string methodName = "Main" , string className = "Exec" , InstanceObject instanceObject = null , ScriptLanguage scriptLanguage = ScriptLanguage.CSharp , bool nonPublic = false , bool isStatic = false , bool addDefaultUsingWhenGeneratingClass = true , bool addExtraUsingWhenGeneratingClass = true , bool includeDllInBaseFolder = true) object[] paramList; ICollection<string> extraDllFolderList; ICollection<string> extraDllFileList; string methodName; string className; InstanceObject instanceObject; ScriptLanguage scriptLanguage; bool nonPublic; bool isStatic; bool addDefaultUsingWhenGeneratingClass; bool addExtraUsingWhenGeneratingClass; bool includeDllInBaseFolder; ScriptLanguage
- CSharp
- VisualBasic
Useage
DynamicScriptExecutor.ExecOption execOption = new DynamicScriptExecutor.ExecOption(...); DynamicScriptExecutor.ScriptExecutor.Exec(code, execOption); | Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard. -
net6.0
- Microsoft.CodeAnalysis.CSharp (>= 4.4.0)
- Microsoft.CodeAnalysis.VisualBasic (>= 4.4.0)
-
net7.0
- Microsoft.CodeAnalysis.CSharp (>= 4.4.0)
- Microsoft.CodeAnalysis.VisualBasic (>= 4.4.0)
-
net8.0
- Microsoft.CodeAnalysis.CSharp (>= 4.4.0)
- Microsoft.CodeAnalysis.VisualBasic (>= 4.4.0)
-
net9.0
- Microsoft.CodeAnalysis.CSharp (>= 4.4.0)
- Microsoft.CodeAnalysis.VisualBasic (>= 4.4.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.