Roslyn Integration - oleg-shilo/cs-script.net-framework GitHub Wiki
The content of this page is preliminary and is not applicable to any available release.
Adding CS-Script engine and Roslyn integration to the application.
Add package (.NET Core)
dotnet add package CS-Script.Core
Get package (.NET)
Install-Package CS-Script.lib.Roslyn
Executing the scripts. Selecting the engine is an optional step that is only required for .NET (full) but not for .NET Core:
// Next line isn't needed on .NET Core as Roslyn is the only engine available for it.
CSScript.EvaluatorConfig.Engine = EvaluatorEngine.Roslyn;
dynamic script = CSScript.Evaluator
.LoadCode(@"using System;
public class Script
{
public int Sum(int a, int b)
{
return a+b;
}
}");
var result = script.Sum(7, 3);
Debugging scripts is now possible for both .NET and .NET Core runtimes. You can use either VS "Step into (F11)" or place a breakpoint into the script.
CSScript.EvaluatorConfig.DebugBuild = true;
var product = CSScript.Evaluator
.CreateDelegate<int>(@"int Product(int a, int b)
{
System.Diagnostics.Debugger.Break();
return a * b;
}");
int result = product(3, 2);