{"id":29027334,"url":"https://github.com/rameel/ramstack.expressionparser","last_synced_at":"2025-06-26T06:05:27.248Z","repository":{"id":278616916,"uuid":"936108469","full_name":"rameel/ramstack.expressionparser","owner":"rameel","description":"A flexible expression parser library for .NET, allowing dynamic evaluation and binding of expressions with context-aware support.","archived":false,"fork":false,"pushed_at":"2025-05-24T18:53:37.000Z","size":70,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-24T19:08:29.236Z","etag":null,"topics":["expression-parser","parser"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rameel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-02-20T14:43:16.000Z","updated_at":"2025-05-24T18:52:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"29dc24c5-3a42-4e20-8407-3ef1e3539ea0","html_url":"https://github.com/rameel/ramstack.expressionparser","commit_stats":null,"previous_names":["rameel/ramstack.expressionparser"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/rameel/ramstack.expressionparser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rameel%2Framstack.expressionparser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rameel%2Framstack.expressionparser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rameel%2Framstack.expressionparser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rameel%2Framstack.expressionparser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rameel","download_url":"https://codeload.github.com/rameel/ramstack.expressionparser/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rameel%2Framstack.expressionparser/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262010866,"owners_count":23244414,"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":["expression-parser","parser"],"created_at":"2025-06-26T06:05:26.623Z","updated_at":"2025-06-26T06:05:27.218Z","avatar_url":"https://github.com/rameel.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ramstack.ExpressionParser\r\n[![NuGet](https://img.shields.io/nuget/v/Ramstack.ExpressionParser.svg)](https://nuget.org/packages/Ramstack.ExpressionParser)\r\n[![MIT](https://img.shields.io/github/license/rameel/ramstack.expressionparser)](https://github.com/rameel/ramstack.expressionparser/blob/main/LICENSE)\r\n\r\n**Ramstack.ExpressionParser** is a flexible expression parser library for .NET,\r\nallowing dynamic evaluation and binding of expressions with context-aware support.\r\n\r\n## Getting Started\r\n\r\nTo install the `Ramstack.ExpressionParser` [NuGet package](https://www.nuget.org/packages/Ramstack.ExpressionParser) to your project, run the following command:\r\n\r\n```shell\r\ndotnet add package Ramstack.ExpressionParser\r\n```\r\n\r\n## Usage\r\n\r\n```csharp\r\nvar result = ExpressionParser.Parse(\"math.min(2 + 3, 2 * 3)\");\r\nif (result.Success)\r\n{\r\n    var lambda = Expression.Lambda\u003cFunc\u003cint\u003e\u003e(result.Value);\r\n    var fn = lambda.Compile();\r\n\r\n    Console.WriteLine(fn());\r\n}\r\n```\r\n\r\n### Using `ContextAwareBinder`\r\n\r\n`ContextAwareBinder` allows binding expressions to a specific context,\r\nmaking it possible to reference its properties, fields, and methods directly within expressions.\r\n\r\n- The provided context acts as an implicit **this**, meaning you can access its members without prefixes.\r\n- Case-insensitive binding: identifiers in expressions are resolved in case-insensitive manner (e.g., level, Level, and LEVEL are treated the same).\r\n\r\n```csharp\r\nvar parameter = Expression.Parameter(typeof(LogEvent), \"logEvent\");\r\nvar binder = new ContextAwareBinder(parameter);\r\n\r\nvar result = ExpressionParser.Parse(\"level == LogLevel.Error \u0026\u0026 string.IsNullOrEmpty(source)\", binder);\r\nvar predicate = Expression\r\n    .Lambda\u003cPredicate\u003cLogEvent\u003e\u003e(result.Value, parameter)\r\n    .Compile();\r\n```\r\n\r\nHere, `IsEnabled` evaluates the parsed expression against a `LogEvent` instance:\r\n```csharp\r\npublic bool IsEnabled(LogEvent logEvent)\r\n{\r\n    return _predicate(logEvent);\r\n}\r\n```\r\n\r\nThis makes it easy to create dynamic, human-readable expressions for filtering or evaluating objects at runtime.\r\n\r\n## Supported Versions\r\n\r\n|      | Version    |\r\n|------|------------|\r\n| .NET | 6, 7, 8, 9 |\r\n\r\n## Contributions\r\n\r\nBug reports and contributions are welcome.\r\n\r\n## License\r\n\r\nThis package is released under the **MIT License**.\r\nSee the [LICENSE](https://github.com/rameel/ramstack.expressionparser/blob/main/LICENSE) file for details.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frameel%2Framstack.expressionparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frameel%2Framstack.expressionparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frameel%2Framstack.expressionparser/lists"}