Cel.NET
2.3.1
dotnet add package Cel.NET --version 2.3.1
NuGet\Install-Package Cel.NET -Version 2.3.1
<PackageReference Include="Cel.NET" Version="2.3.1" />
<PackageVersion Include="Cel.NET" Version="2.3.1" />
<PackageReference Include="Cel.NET" />
paket add Cel.NET --version 2.3.1
#r "nuget: Cel.NET, 2.3.1"
#:package Cel.NET@2.3.1
#addin nuget:?package=Cel.NET&version=2.3.1
#tool nuget:?package=Cel.NET&version=2.3.1
Cel.NET - Common Expression Language for .NET
This is a C# port of the Common Expression Language (CEL), based on CEL-Java.
The CEL specification can be found here.
Getting started
A very simple start:
using Cel.Checker;
using Cel.Tools;
public class MyClass
{
public void MyScriptUsage()
{
// Build the script factory
ScriptHost scriptHost = ScriptHost.NewBuilder().Build();
// create the script, will be parsed and checked
Script script = scriptHost.BuildScript("x + ' ' + y")
.WithDeclarations(
// Variable declarations - we need `x` and `y` in this example
Decls.NewVar("x", Decls.String),
Decls.NewVar("y", Decls.String))
.Build();
IDictionary<string, object> arguments = new Dictionary<string, object>();
arguments.Add("x", "hello");
arguments.Add("y", "world");
string result = script.Execute<string>(arguments);
Console.WriteLine(result); // Prints "hello world"
}
}
Protobuf and Json.NET and plain C# objects
Protobuf (via Google.Protobuf) objects and schema is supported out of the box.
It is also possible to use plain C# and Json.NET objects as arguments by using the
Cel.Common.Types.Json.JsonRegistry.
Code sample similar to the one above. It takes a user-provided object type MyInput.
using Cel.Checker;
using Cel.Tools;
public class MyClass
{
public bool EvalWithJsonObject(MyInput input, string checkName)
{
// Build the script factory
ScriptHost scriptHost = ScriptHost.NewBuilder()
.Registry(JsonRegistry.NewRegistry())
.Build();
// Create the script, will be parsed and checked.
// It checks whether the property `Name` in the "Json-ized" class `MyInput` is
// equal to the value of `checkName`.
Script script = scriptHost.BuildScript("inp.Name == checkName")
// Variable declarations - we need `inp` + `checkName` in this example
.WithDeclarations(
Decls.NewVar("inp", Decls.NewObjectType(typeof(MyInput).FullName)),
Decls.NewVar("checkName", Decls.String))
// Register our Json-NET object input type
.WithTypes(typeof(MyInput))
.Build();
IDictionary<string, object> arguments = new Dictionary<string, object>();
arguments.Add("inp", input);
arguments.Add("checkName", checkName);
bool result = script.Execute<bool>(arguments);
return result;
}
}
Note that the Json.NET field-names are used as property names in Cel.NET. It is not necessary to annotate "plain C#" classes with Json.NET attributes.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 was computed. 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 was computed. 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 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 Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| .NET Framework | net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- Antlr4.Runtime.Standard (>= 4.13.1)
- Apache.Avro (>= 1.12.1)
- Google.Protobuf (>= 3.26.1)
- Grpc.Core.Api (>= 2.63.0)
- Newtonsoft.Json (>= 13.0.4)
- NodaTime (>= 3.3.3)
-
.NETStandard 2.1
- Antlr4.Runtime.Standard (>= 4.13.1)
- Apache.Avro (>= 1.12.1)
- Google.Protobuf (>= 3.26.1)
- Grpc.Core.Api (>= 2.63.0)
- Newtonsoft.Json (>= 13.0.4)
- NodaTime (>= 3.3.3)
-
net10.0
- Antlr4.Runtime.Standard (>= 4.13.1)
- Apache.Avro (>= 1.12.1)
- Google.Protobuf (>= 3.26.1)
- Grpc.Core.Api (>= 2.63.0)
- Newtonsoft.Json (>= 13.0.4)
- NodaTime (>= 3.3.3)
-
net8.0
- Antlr4.Runtime.Standard (>= 4.13.1)
- Apache.Avro (>= 1.12.1)
- Google.Protobuf (>= 3.26.1)
- Grpc.Core.Api (>= 2.63.0)
- Newtonsoft.Json (>= 13.0.4)
- NodaTime (>= 3.3.3)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Cel.NET:
| Package | Downloads |
|---|---|
|
Confluent.SchemaRegistry.Rules
Provides schema rules support. |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on Cel.NET:
| Repository | Stars |
|---|---|
|
confluentinc/confluent-kafka-dotnet
Confluent's Apache Kafka .NET client
|
| Version | Downloads | Last Updated |
|---|---|---|
| 2.3.1 | 10,118 | 9/10/2026 |
| 2.3.0 | 380 | 9/7/2026 |
| 2.2.1 | 520 | 8/28/2026 |
| 2.2.0 | 555 | 8/24/2026 |
| 2.1.3 | 129 | 8/23/2026 |
| 2.1.2 | 147 | 8/23/2026 |
| 2.1.1 | 151 | 8/23/2026 |
| 2.1.0 | 417 | 8/19/2026 |
| 2.0.0 | 763 | 8/15/2026 |
| 1.2.0 | 296 | 8/14/2026 |
| 1.1.0 | 12,201 | 7/2/2026 |
| 1.0.0 | 48,477 | 11/27/2025 |
| 0.4.0 | 12,301 | 8/14/2025 |
| 0.3.2 | 33,077 | 9/10/2024 |
| 0.3.1 | 4,654 | 7/9/2024 |
| 0.3.0 | 1,943 | 11/14/2022 |
| 0.2.0 | 705 | 9/14/2022 |
| 0.1.0 | 707 | 9/14/2022 |