{"id":16367064,"url":"https://github.com/igor-tkachev/linq.expressions.deconstruct","last_synced_at":"2025-03-23T02:32:50.450Z","repository":{"id":65462583,"uuid":"199951500","full_name":"igor-tkachev/Linq.Expressions.Deconstruct","owner":"igor-tkachev","description":"Pattern matching support for System.Linq.Expressions.","archived":false,"fork":false,"pushed_at":"2024-04-15T19:06:25.000Z","size":146,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-12T02:48:24.979Z","etag":null,"topics":[],"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/igor-tkachev.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":"2019-08-01T01:07:48.000Z","updated_at":"2024-09-25T17:22:20.000Z","dependencies_parsed_at":"2023-12-28T01:03:43.216Z","dependency_job_id":null,"html_url":"https://github.com/igor-tkachev/Linq.Expressions.Deconstruct","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igor-tkachev%2FLinq.Expressions.Deconstruct","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igor-tkachev%2FLinq.Expressions.Deconstruct/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igor-tkachev%2FLinq.Expressions.Deconstruct/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igor-tkachev%2FLinq.Expressions.Deconstruct/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/igor-tkachev","download_url":"https://codeload.github.com/igor-tkachev/Linq.Expressions.Deconstruct/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221842719,"owners_count":16890189,"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":[],"created_at":"2024-10-11T02:48:27.773Z","updated_at":"2024-10-28T14:46:13.395Z","avatar_url":"https://github.com/igor-tkachev.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿# Linq.Expressions.Deconstruct\r\n\r\n\r\n[![Build status](https://ci.appveyor.com/api/projects/status/j4dym9acp0i9aau0/branch/master?svg=true)](https://ci.appveyor.com/project/igor-tkachev/linq-expressions-deconstruct/branch/master) [![NuGet Version and Downloads count](https://buildstats.info/nuget/Linq.Expressions.Deconstruct)](https://www.nuget.org/packages/Linq.Expressions.Deconstruct/)\r\n\r\n\r\n```c#\r\n[Test]\r\npublic void MatchTest()\r\n{\r\n    Expression\u003cFunc\u003cint,int\u003e\u003e f = i =\u003e i * 2;\r\n\r\n    switch (f.ToExpr())\r\n    {\r\n        case Lambda(Multiply(Parameter(\"i\") p1, Constant(2)), [(\"i\") p2])\r\n            when p1 == p2 :\r\n            Console.WriteLine(\"Pattern Matched!\");\r\n            break;\r\n        default:\r\n            Console.WriteLine(f);\r\n            Assert.Fail();\r\n            break;\r\n    }\r\n}\r\n```\r\n\r\n\r\n```c#\r\n[Test]\r\npublic void ConstantFoldingTest()\r\n{\r\n    Expression\u003cFunc\u003cint,int\u003e\u003e f = i =\u003e i * 0 + 0 + i + 10 * (i * 0 + 2);\r\n\r\n    var f1 = f.TransformEx(ex =\u003e ex switch\r\n    {\r\n        Multiply(Constant(0) e,   _)               =\u003e e,               // 0 * e =\u003e 0\r\n        Multiply(_,               Constant(0) e)   =\u003e e,               // e * 0 =\u003e 0\r\n        Multiply(Constant(1),     var e)           =\u003e e,               // 1 * e =\u003e e\r\n        Multiply(var e,           Constant(1))     =\u003e e,               // e * 1 =\u003e e\r\n        Divide  (Constant(0) e,   _)               =\u003e e,               // 0 / e =\u003e 0\r\n        Divide  (var e,           Constant(1))     =\u003e e,               // e / 1 =\u003e e\r\n        Add     (Constant(0),     var e)           =\u003e e,               // 0 + e =\u003e e\r\n        Add     (var e,           Constant(0))     =\u003e e,               // e + 0 =\u003e e\r\n        Subtract(Constant(0),     var e)           =\u003e Negate(e),       // 0 - e =\u003e -e\r\n        Subtract(var e,           Constant(0))     =\u003e e,               // e - 0 =\u003e e\r\n        Multiply(Constant(int x), Constant(int y)) =\u003e Constant(x * y), // x * y =\u003e e\r\n        Divide  (Constant(int x), Constant(int y)) =\u003e Constant(x / y), // x / y =\u003e e\r\n        Add     (Constant(int x), Constant(int y)) =\u003e Constant(x + y), // x + y =\u003e e\r\n        Subtract(Constant(int x), Constant(int y)) =\u003e Constant(x - y), // x - y =\u003e e\r\n        _                                          =\u003e ex\r\n    });\r\n\r\n    Assert.IsTrue(f1.EqualsTo(i =\u003e i + 20));\r\n}\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figor-tkachev%2Flinq.expressions.deconstruct","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Figor-tkachev%2Flinq.expressions.deconstruct","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figor-tkachev%2Flinq.expressions.deconstruct/lists"}