Skip to main content
net10.0

A general-purpose, embeddable scripting language for .NET with C# syntax, compiled execution, low-allocation runtime paths, and host-controlled access.

Published
Sep 11, 2026
1mo ago
Total Downloads
3.5K
3,501

Install

dotnet add package Facepunch.Breen --version 1.0.0-rc.3
ProductVersions
.NET
net10.0

README

Breen

Breen is a scripting language for C# applications. It looks and works like C#, because that's the idea.

Use the Facepunch.Breen package with .NET 10. Scripts run as compiled code, with inputs and C# APIs supplied by your application.

Example script

Save this as score.breen:

// A global keeps its value between runs. This initializer runs once.
[Global]
int TotalScore = 0;

// Define a struct to keep a round's data and scoring logic together.
struct RoundScore
{
    public int Kills;
    public int Bonus;

    // Structs can have methods too.
    public int Total() => Kills * 100 + Bonus;
}

// Define a function we can call for each round.
int AddRound(int kills, int bonus)
{
    // This local struct belongs to this call.
    var round = new RoundScore { Kills = kills, Bonus = bonus };

    // Call its method and add the result to our running total.
    TotalScore += round.Total();
    return TotalScore;
}

// Kills and Bonus are inputs supplied by the application.
// With 3 kills and a bonus of 5, each run adds 305 to the total.
return AddRound(Kills, Bonus);

Quick start

dotnet add package Facepunch.Breen --prerelease
using Breen;

var system = new ScriptSystem(new ScriptSystemOptions
{
    Resolver = new DefaultResolver()
});

system.SetStore("global", new ScriptStore());

var script = system.CreateScript(File.ReadAllText("score.breen"));
script.Set("Kills", 3);
script.Set("Bonus", 5);

var result = script.Run();
if (!result.Success)
{
    throw new InvalidOperationException(result.Error!.Message, result.Exception);
}

int score = script.ReturnValue.Get<int>(); // 305

[Breen.Store("global")]
[AttributeUsage(AttributeTargets.Field)]
public sealed class GlobalAttribute : Attribute { }

Keep the system and script around for repeated runs; Run() compiles on first use. Change inputs with Set() and run again. Use them sequentially on one thread.

DefaultResolver exposes public C# APIs. Supply your own IResolver to restrict which types and members scripts can access.

Features

βœ… Use classes βœ… Define classes βœ… Use structs βœ… Define structs
βœ… Use methods βœ… Define methods βœ… Use enums βœ… Define enums
βœ… Locals βœ… Globals βœ… Loops βœ… Arrays
βœ… Constructors βœ… Overloads βœ… Recursion βœ… Try catch
βœ… Static methods βœ… Public/private fields βœ… Collections βœ… String interpolation
βœ… Use generic classes βœ… Use generic structs βœ… Use generic methods βœ… Sandboxed APIs
βœ… Use properties βœ… Use indexers βœ… Use interfaces βœ… Execution budgets
βœ… Null checks βœ… Persistent state βœ… Editor completion βœ… Calls from C#
πŸ”΄ Define generic classes πŸ”΄ Define generic structs πŸ”΄ Define generic methods πŸ”΄ Define interfaces
πŸ”΄ Inheritance πŸ”΄ Define properties πŸ”΄ Define indexers πŸ”΄ Define operators
πŸ”΄ Define static fields πŸ”΄ Define readonly fields πŸ”΄ Lambdas πŸ”΄ Async/await
πŸ”΄ Define records πŸ”΄ Define nested types πŸ”΄ Switch πŸ”΄ Named arguments

Script.Call() invokes a top-level function and keeps initialized script state between calls. Run() reruns top-level setup. To call an object's method from C#, wrap it in a top-level script function.

Execution has a configurable instruction budget and a 128-call recursion limit. Unused function and type declarations preserve the normal execution fast paths.

Changes from Previous Version

No structural changes between v1.0.0-rc.2 and v1.0.0-rc.3.

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

This version is marked prerelease. Validate its API and upgrade path before production use.Compatibility metadata lists 1 target framework; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.