Arc.UniInk
0.1.3
.NET 10.0
This package targets .NET 10.0. The package is compatible with this framework or higher.
.NET Standard 2.1
This package targets .NET Standard 2.1. The package is compatible with this framework or higher.
dotnet add package Arc.UniInk --version 0.1.3
NuGet\Install-Package Arc.UniInk -Version 0.1.3
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="Arc.UniInk" Version="0.1.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Arc.UniInk" Version="0.1.3" />
<PackageReference Include="Arc.UniInk" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Arc.UniInk --version 0.1.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Arc.UniInk, 0.1.3"
#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.
#:package Arc.UniInk@0.1.3
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Arc.UniInk&version=0.1.3
#tool nuget:?package=Arc.UniInk&version=0.1.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
✒️ UniInk - AOT C# Interpreter
😀Start
Download This is Enough !
📝RoadMap
- Support more features.
- Nuget Package Support.
- Unity Package Support.
- Write more test cases.
- Serializable function? Maybe interesting?
- improve the readability.
- thread safe support (or provide a thread safe way to execute many expression).
✨Features
The UniInk is a single file, you can download/copy the file and put it in your project.
You can easy to extend the operator and function and more,because the code is clear and simple( only 2000lines )
The performance is very good, the GC is 0 and the boxing is 0.
| Method | Mean | Error | StdDev | Median | Gen0 | Gen1 | Allocated |
|---|---|---|---|---|---|---|---|
| TEST_Arithmetic__UniInkSpeed | 293,666.10 ns | 333.563 ns | 260.424 ns | 293,632.98 ns | - | - | 68 B |
| TEST_Arithmetic__UniInkSpeed_Compiled | 175,568.29 ns | 3,454.616 ns | 5,063.732 ns | 176,105.37 ns | - | - | 658 B |
| TEST_Arithmetic__ExpressionEvaluator | 2,622,376.28 ns | 10,903.378 ns | 10,199.026 ns | 2,623,418.75 ns | 390.6250 | 11.7188 | 2068334 B |
| TEST_Arithmetic__Sprache | 2,797,690.07 ns | 91,953.442 ns | 265,306.706 ns | 2,677,421.88 ns | 535.1563 | 19.5313 | 2817177 B |
| TEST_Arithmetic__ParsecSharp | 1,114,429.92 ns | 21,943.809 ns | 27,751.892 ns | 1,113,960.74 ns | 162.1094 | - | 851830 B |
summary : UniInkSpeed is fast , and UniInkSpeed support more features. would you like to try it?
Evaluate Expression
✨Support Arithmetic Operations ( Easy extend Operator )
// 1. Create a new instance of the interpreter
var Ink = new UniInk_Speed();
// 2. Evaluate the expression , and as it to InkValue
var res1 = Ink.Evaluate(" +9 * (1+1 + 1 + 1 + 1+1+1)") as InkValue;
// 3. Get the result with the type you want, the result is 63
Console.WriteLine(res1.Value_int);
// PS : the process of calculation is 0 GC and 0 Boxing
// if you want improve the performance further , recycle the InkValue
InkValue.Release(res1); // now the GC is 0 completely!
Other example
var Ink = new UniInk_Speed();
// float type
var res = Ink.Evaluate("3333333.3333333f-3.3f+3.3f+ 3.3f - 3.3f") as InkValue;
Console.WriteLine(res.Value_float);
// double type
var res2 = Ink.Evaluate("+123456789.987654321d + 987654321.123456789d") as InkValue;
Console.WriteLine(res2.Value_double);
✨Support Logical Operations ( Easy extend Operator )
// bool type
var res = Ink.Evaluate("1 < 2 || 2 ==1 || 2 < 1") as InkValue;
Console.WriteLine(res.Value_bool);
Evaluate Scripts
✨Support Variable Assignment
// the result will return the last expression
var res = Ink.Evaluate("var aaa= 123 ; var bbb =aaa + 1 ; aaa + bbb ") as InkValue;
Console.WriteLine(res.Value_int);
✨Support Function Call
// has API to register the function such as CRE:
UniInk_Speed.RegisterFunction("CRE", new(prms =>
{
var param1 = (InkValue)prms[0];
var param2 = (InkValue)prms[1];
return new Card() { ID = param1, Rarity = param2 };
}));
// the result will return the last expression
var res = Ink.Evaluate("var a = CRE(1,3) ; GET(a, Rarity) == 3 ") as InkValue;
✨Support Lambda Expression
// this may be complex, but we also support it
var res = Ink.Evaluate("FLT(Config,var c => GET(c, Rarity) == 2 && GET(c, ID) == 1)") as InkValue;
✨Support Property Getter
// use register variable to set getter
UniInk_Speed.RegisterVariable("grower", InkValue.SetGetter(value =>
{
value.ValueType = TypeCode.Int32;
value.Value_int = grower++; // grower is a member variable
}));
// the result is different every time
var res = Ink.Evaluate("grower + 10086") as InkValue;
✨Support Control Flow(If Statement)
//Not Support Nested call now like : if ( xxx ) { if ( ) { } }
var script= @" if ( 1 > 2 )
{
123
}
else if ( 3 > 6 )
{
456
}
else if ( 3 < 6 )
{
return 456
}
else
{
return 666
} ";
// you should copy the UniInk_Extensions.cs to your project
// it may enlightened you to write the custom extension
var res = Ink.Evaluate_IfStatement(script) as InkValue;
💬Support
If you have any questions, suggestions, or need assistance, please feel free to open an issue on the UniInk repository. We're here to help! 😊
Let's script with UniInk and unlock the full potential of your projects! 🚀💡🌟
| 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 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. 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. |
| 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- No dependencies.
-
net10.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.