{"id":22275691,"url":"https://github.com/dahomey-technologies/dahomey.expressionevaluator","last_synced_at":"2025-07-28T16:32:25.931Z","repository":{"id":98703597,"uuid":"93948938","full_name":"dahomey-technologies/Dahomey.ExpressionEvaluator","owner":"dahomey-technologies","description":"Evaluate C# Formulas at Runtime","archived":false,"fork":false,"pushed_at":"2020-10-10T11:58:56.000Z","size":34,"stargazers_count":41,"open_issues_count":3,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-10T17:47:06.389Z","etag":null,"topics":["csharp","dotnet","dotnet-standard","evaluate","evaluator","expression","expression-evaluator","expression-parser","formula","formula-parser","parse","parser","unity","unity3d"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dahomey-technologies.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-06-10T15:40:53.000Z","updated_at":"2024-07-27T14:14:26.000Z","dependencies_parsed_at":"2023-03-09T15:00:32.809Z","dependency_job_id":null,"html_url":"https://github.com/dahomey-technologies/Dahomey.ExpressionEvaluator","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dahomey-technologies%2FDahomey.ExpressionEvaluator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dahomey-technologies%2FDahomey.ExpressionEvaluator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dahomey-technologies%2FDahomey.ExpressionEvaluator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dahomey-technologies%2FDahomey.ExpressionEvaluator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dahomey-technologies","download_url":"https://codeload.github.com/dahomey-technologies/Dahomey.ExpressionEvaluator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227932626,"owners_count":17843136,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","dotnet","dotnet-standard","evaluate","evaluator","expression","expression-evaluator","expression-parser","formula","formula-parser","parse","parser","unity","unity3d"],"created_at":"2024-12-03T14:11:33.809Z","updated_at":"2024-12-03T14:11:34.619Z","avatar_url":"https://github.com/dahomey-technologies.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dahomey.ExpressionEvaluator\nEvaluate C# Formulas at Runtime\n\n## Supported Platforms\n* .Net Standard 2.0. Compatible with \n  * .Net Core 2.0+\n  * .Net Framework 4.6.1+\n  * Unity 2018.1+\n\nDahomey.ExpressionEvaluator code does not trigger any AOT complilation. It means it can be used safely with Unity IL2CPP.\n\n## Installation\n### NuGet\nhttps://www.nuget.org/packages/Dahomey.ExpressionEvaluator/\n\n`Install-Package Dahomey.ExpressionEvaluator`\n\n### Compilation from source\n  1. `dotnet restore`\n  2. `dotnet pack -c Release`\n\n## Examples\n### Parse a numeric expression\n```csharp\nExpressionParser parser = new ExpressionParser();\nparser.RegisterVariable\u003cint\u003e(\"a\");\nINumericExpression expr = parser.ParseNumericExpression(\"1 + a\");\n\nint a = 2;\ndouble result = expr.Evaluate(new Dictionary\u003cstring, object\u003e { { \"a\", a } });\nConsole.WriteLine(result);\n```\nThe result will be:\n```csharp\n3\n```\n\n### Parse a numeric expression with member access\n```csharp\nclass A\n{\n    public B B { get; set; }\n}\n\nclass B\n{\n    public int Id { get; set; }\n}\n\nExpressionParser parser = new ExpressionParser();\nparser.RegisterVariable\u003cA\u003e(\"a\");\nINumericExpression expr = parser.ParseNumericExpression(\"1 + a.B.Id\");\n\nA a = new A { B = new B { Id = 12 } };\ndouble result = expr.Evaluate(new Dictionary\u003cstring, object\u003e { { \"a\", a } });\nConsole.WriteLine(result);\n```\nThe result will be:\n```csharp\n13\n```\n\n### Parse a numeric expression with array or list access\n```csharp\nExpressionParser parser = new ExpressionParser();\nparser.RegisterVariable\u003cList\u003cint\u003e\u003e(\"a\");\nINumericExpression expr = parser.ParseNumericExpression(\"1 + a[1]\");\n\nList\u003cint\u003e a = new List\u003cint\u003e { 1, 2 };\ndouble result = expr.Evaluate(new Dictionary\u003cstring, object\u003e { { \"a\", a } });\nConsole.WriteLine(result);\n```\nThe result will be:\n```csharp\n3\n```\n\n### Parse a numeric expression with function access\n```csharp\nFunc\u003cdouble, double\u003e func = n =\u003e Math.Cos(n);\nExpressionParser parser = new ExpressionParser();\nparser.RegisterFunction(\"cos\", func);\nINumericExpression expr = parser.ParseNumericExpression(\"1 + cos(12)\");\n\ndouble result = expr.Evaluate()\nConsole.WriteLine(result);\n```\nThe result will be:\n```csharp\n1.8438539587324922\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdahomey-technologies%2Fdahomey.expressionevaluator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdahomey-technologies%2Fdahomey.expressionevaluator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdahomey-technologies%2Fdahomey.expressionevaluator/lists"}