SerializableFormula 2.1.0

dotnet add package SerializableFormula --version 2.1.0                
NuGet\Install-Package SerializableFormula -Version 2.1.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="SerializableFormula" Version="2.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SerializableFormula --version 2.1.0                
#r "nuget: SerializableFormula, 2.1.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.
// Install SerializableFormula as a Cake Addin
#addin nuget:?package=SerializableFormula&version=2.1.0

// Install SerializableFormula as a Cake Tool
#tool nuget:?package=SerializableFormula&version=2.1.0                

Serializable Formula

Serializable Formula is a fast library used to calculate a text based formula input all contained in a convienent serializable object. Add your own custom functions and variables. Calculate Boolean, String and Float outputs.



Start by creating a simple SerializableFormula object, setting the desired result type and the formula text.

	var newFormula = new SerializableFormula();
	newFormula.FormulaResultType = TResultType.Float;
	newformula.FormulaText = "Average(a, b, c, d, e)";

Defining Custom Variables

Now you have to define each part of the function. The SerializableFormula object above has no ability to process each function until you tell it what each part does.

Define your variables:

	var a = new FormulaVariable("a", 4);
	var b = new FormulaVariable("b", 2);
	var c = new FormulaVariable("c", 7);
	var d = new FormulaVariable("d", 10);
	var e = new FormulaVariable("e", 20);

Defining Functions

Define the Average function:

	var average = new TAverageFunction();

The Average function is a custom function that comes bundled with the SerializableFormula. More about custom functions later.

Verify Syntax

Use the VerifySyntax() function to return an object SyntaxCheckResult which contains:

  • ExpressionError : A string containing a human friendly error message
  • ExpressionErrorToken : A string with just the erroneous text token
  • ExpressionErrorPosition : A integer representing the position in the formula string where the error occurs


Finally, we can obtain our result by calling the function that matches our output type:

  • var result = newFormula.CalculateText();
  • var result = newFormula.CalculateLogical();
  • var result = newFormula.CalculateArithmetic();

Custom Functions

In order to create a custom function all you have to do is create a new object that implements IFormulaFunction. Once implemented you can add your function to a SerializableFormula using the AddFunction() method.

Default Identifiers

These identifiers are always a part of SerializableFormula. They cannot be used to name Functions or Variables.


  • or
  • xor
  • and
  • true
  • false
  • not
  • if
  • case

Math Operators

  • +
  • -
  • <
  • <=
  • >
  • >=
  • <>
  • =
  • /
  • *
  • ^
  • (
  • )
  • ,
Product 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 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  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 tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on SerializableFormula:

Package Downloads

A WPF component that hosts a Serializable Formula

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.0 242 4/19/2023
2.0.0 144 4/18/2023
1.10.0 309 12/16/2022
1.9.0 317 11/14/2022
1.8.1 419 3/1/2021
1.8.0 430 3/1/2021
1.7.1 1,002 7/17/2018
1.7.0 911 7/16/2018
1.6.1 1,308 5/14/2018
1.6.0 1,222 5/14/2018
1.4.0 1,496 5/2/2018
1.3.0 1,015 5/2/2018
1.2.0 964 4/30/2018
1.1.0 1,120 4/30/2018
1.0.0 1,550 4/28/2018

Fixed issues with the "not" operator.