CDS.CSharpScript2
2.4.1
dotnet add package CDS.CSharpScript2 --version 2.4.1
NuGet\Install-Package CDS.CSharpScript2 -Version 2.4.1
<PackageReference Include="CDS.CSharpScript2" Version="2.4.1" />
<PackageVersion Include="CDS.CSharpScript2" Version="2.4.1" />
<PackageReference Include="CDS.CSharpScript2" />
paket add CDS.CSharpScript2 --version 2.4.1
#r "nuget: CDS.CSharpScript2, 2.4.1"
#:package CDS.CSharpScript2@2.4.1
#addin nuget:?package=CDS.CSharpScript2&version=2.4.1
#tool nuget:?package=CDS.CSharpScript2&version=2.4.1
CDS.CSharpScript2
Roslyn-powered C# scripting engine for .NET 10.
Description
CDS.CSharpScript2 lets you embed full C# scripting — compilation, execution, IntelliSense, and
syntax classification — into any .NET 10 application.
Features
- Compile & execute C# scripts with Roslyn, with support for globals (host-supplied state).
- IntelliSense — code completion, symbol classification, and signature help (call tips).
- Diagnostics — surface compiler errors and warnings back to your UI.
- Assembly references — reference any managed assembly, including third-party NuGet packages.
- Immutable configuration — compose
ScriptEnvironmentinstances fluently; safe to cache and share.
Quick Start
Simple execution
using CDS.CSharpScript2;
using var context = await ScriptContext.CreateAsync();
var ctx = context.ApplyScript("1 + 1");
var executable = await new ScriptExecutor(ctx).CompileAsync<int>();
int result = await executable.RunAsync<int>(); // 2
With global variables
public class MyGlobals
{
public double X { get; set; }
public double Y { get; set; }
}
var env = ScriptEnvironment.Default.WithGlobalType<MyGlobals>();
using var context = await ScriptContext.CreateAsync(env);
var ctx = context.ApplyScript("X * Y");
var executable = await new ScriptExecutor(ctx).CompileAsync<double>();
double result = await executable.RunAsync<double>(new MyGlobals { X = 3, Y = 4 }); // 12.0
With additional namespaces and references
var env = ScriptEnvironment.Default
.WithAdditionalNamespaceForType<System.Text.StringBuilder>()
.WithAdditionalReferenceForType<MathNet.Numerics.Constants>();
using var context = await ScriptContext.CreateAsync(env);
Key Types
| Type | Purpose |
|---|---|
ScriptEnvironment |
Immutable configuration: namespace imports, assembly references, globals type |
ScriptContext |
Roslyn workspace document paired with an environment; disposable |
ScriptExecutor |
Compiles a ScriptContext into an ExecutableScript |
ExecutableScript |
Compiled script ready to run; reports diagnostics and accepts a globals object |
Editor Integration
Pair with the editor package for a ready-to-use WinForms control:
- CDS.CSharpScript2.ScintillaEditor — full-featured Scintilla5-based editor with live IntelliSense
Requirements
- .NET 10.0
Attributions
Icon by Flaticon Uicons
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
| .NET Framework | net48 is compatible. net481 was computed. |
-
.NETFramework 4.8
- Microsoft.CodeAnalysis.CSharp (>= 5.3.0)
- Microsoft.CodeAnalysis.CSharp.Features (>= 5.3.0)
- Microsoft.CodeAnalysis.CSharp.Scripting (>= 5.3.0)
- Microsoft.CodeAnalysis.CSharp.Workspaces (>= 5.3.0)
-
net10.0
- Microsoft.CodeAnalysis.CSharp (>= 5.3.0)
- Microsoft.CodeAnalysis.CSharp.Features (>= 5.3.0)
- Microsoft.CodeAnalysis.CSharp.Scripting (>= 5.3.0)
- Microsoft.CodeAnalysis.CSharp.Workspaces (>= 5.3.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on CDS.CSharpScript2:
| Package | Downloads |
|---|---|
|
CDS.CSharpScript2.ScintillaEditor
Scintilla5-based WinForms editor control for embedding C# script editing in .NET 10 Windows applications. Provides syntax highlighting, IntelliSense, code completion, call tips, and hover info — all powered by Roslyn. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.4.1 | 50 | 7/1/2026 |
| 2.3.1-alpha.0.5 | 40 | 7/1/2026 |