All Projects → gearz-lab → lambda2js

gearz-lab / lambda2js

Licence: MIT license
Converts a C# expression tree (from Linq namespace) to a syntatically correct javascript code.

Programming Languages

C#
18002 projects
Visual Basic .NET
514 projects

Projects that are alternatives of or similar to lambda2js

linqjs
use linq and lambda in javascript on es6, can use linq function in an Object or an Array or a String value | 一个方便对数组、字典、树形数据进行操作、筛选等操作的工具库
Stars: ✭ 17 (-66.67%)
Mutual labels:  linq, lambda
Jaque
Lets Java 8 Lambdas to be represented as objects in the form of expression trees at runtime
Stars: ✭ 152 (+198.04%)
Mutual labels:  linq, lambda
Fluentvalidation.blazor
Fluent Validation-powered Blazor component for validating standard <EditForm> 🌌 ✅
Stars: ✭ 140 (+174.51%)
Mutual labels:  linq, lambda
Dapper.lnskydb
基于Dapper的LINQ扩展,支持Lambda表达式,支持按时间分库分表,也可以自定义分库分表方法,且实体类有T4模版自动生成.省去手写实体类的麻烦。已在实际项目使用
Stars: ✭ 228 (+347.06%)
Mutual labels:  linq, lambda
Masuit.tools
ldqk.xyz/55
Stars: ✭ 2,539 (+4878.43%)
Mutual labels:  linq, lambda
Linq.Expression.Optimizer
System.Linq.Expression expressions optimizer. http://thorium.github.io/Linq.Expression.Optimizer
Stars: ✭ 81 (+58.82%)
Mutual labels:  linq, expression-tree
aws-node-custom-user-pool
Serverless AWS Cognito Custom User Pool Example
Stars: ✭ 15 (-70.59%)
Mutual labels:  lambda
lambda-runtime-pypy3.5
AWS Lambda Runtime for PyPy 3.5
Stars: ✭ 17 (-66.67%)
Mutual labels:  lambda
aws-is-how
Know How Guide and Hands on Guide for AWS
Stars: ✭ 27 (-47.06%)
Mutual labels:  lambda
imprenta
An AWS lambda in python 3 that generates PDF files from HTML using jinja, pdfkit and wkhtmltopdf.
Stars: ✭ 18 (-64.71%)
Mutual labels:  lambda
terraform-aws-efs-backup
Terraform module designed to easily backup EFS filesystems to S3 using DataPipeline
Stars: ✭ 40 (-21.57%)
Mutual labels:  lambda
dotnet-learning
Материалы для обучения C# и ASP.NET
Stars: ✭ 62 (+21.57%)
Mutual labels:  linq
iot-button-ec2-controller
Allows the start/stop of EC2 instances using an AWS IoT button
Stars: ✭ 23 (-54.9%)
Mutual labels:  lambda
ebs-snapshot-lambda
AWS lambda function to snapshot EBS volumes and purge old snapshots.
Stars: ✭ 37 (-27.45%)
Mutual labels:  lambda
lambda-lite-js
a tiny FUNCITONAL LANGUAGE implemented by javascript. 一个函数式语言,使用 js 实现。
Stars: ✭ 77 (+50.98%)
Mutual labels:  lambda
FastLinq
Drop-in-place Memory and Performance optimizations for LINQ
Stars: ✭ 22 (-56.86%)
Mutual labels:  linq
jenkinsfile-runner-lambda
Run Jenkinsfiles in AWS Lambda
Stars: ✭ 52 (+1.96%)
Mutual labels:  lambda
serverless-lumigo-plugin
Serverless monitoring and troubleshooting plugin to easily apply distributed tracing
Stars: ✭ 59 (+15.69%)
Mutual labels:  lambda
FancyDialog
Kotlin + DSL风格代替传统的Builder模式 诸多可配置项 高阶函数代替自定义回调接口 书写起来超级顺手
Stars: ✭ 24 (-52.94%)
Mutual labels:  lambda
lambda-example
Example REST service for a Lambda article I wrote
Stars: ✭ 23 (-54.9%)
Mutual labels:  lambda

Lambda2Js

This is an ExpressionTree (lambda) to Javascript converter.

It is portable, so that you can use it in most environments.

Its purpose is to convert a C# expression tree (from Linq name space) to a syntactically correct javascript code.

It can be extended to customize the mapping of expressions:

  • support custom static methods, instead of emitting code that would otherwise depend on external Javascript
  • support custom types, converting method calls and properties accordingly

It is well tested, and won't break. More than 140 tests passing.

This project uses Semantic versioning.

Installing NuGet package:

PM> Install-Package Lambda2Js

Samples

Converting lambda with boolean and numeric operations:

Expression<Func<MyClass, object>> expr = x => x.PhonesByName["Miguel"].DDD == 32 || x.Phones.Length != 1;
var js = expr.CompileToJavascript();
// js = PhonesByName["Miguel"].DDD===32||Phones.length!==1

Converting lambda with LINQ expression, containing an inner lambda:

Expression<Func<MyClass, object>> expr = x => x.Phones.FirstOrDefault(p => p.DDD > 10);
var js = expr.CompileToJavascript();
// js = System.Linq.Enumerable.FirstOrDefault(Phones,function(p){return p.DDD>10;})

Converting lambda with Linq Select method:

Expression<Func<string[], IEnumerable<char>>> expr = array => array.Select(x => x[0]);
var js = expr.CompileToJavascript(
    new JavascriptCompilationOptions(
        JsCompilationFlags.BodyOnly | JsCompilationFlags.ScopeParameter,
        new[] { new LinqMethods(), }));
// js = array.map(function(x){return x[0];})

Clone using ToArray and targeting ES6:

Expression<Func<string[], IEnumerable<string>>> expr = array => array.ToArray();
var js = expr.Body.CompileToJavascript(
    ScriptVersion.Es60,
    new JavascriptCompilationOptions(new LinqMethods()));
// js = [...array]

Developing custom plugins

You can develop and use some built-in plugins. See the readme.md in the Plugins folder.

Building and testing

ATENTION! Please, run the ProjectsGenerator before doing any of these:

  • build the signed assembly

  • running tests for specific frameworks

    Run Projects Generator

Due to current Visual Studio limitations, I had to create a project generator to create some of the csproj files:

  • Lambda2Js.Signed.csproj is generated using the Lambda2Js.csproj as it's template. It will copy the package version to the FileVersion and to the AssemblyVersion fields to keep them consistent. Also, it adds the ".Signed" string where appropriate in file names and in project name, and finally it includes a reference to the snk file.

  • Lambda2Js.Tests.$(TargetFramework).csproj are generated from Lambda2Js.Tests.csproj. That is needed because this project is a multitargeted test project, and Visual Studio cannot see the tests inside after compiling it... so what I did was: create copy projects that have only one target framework for each of the possible targets.

Testing

To test support on the .Net 4.0, you need to run the Test.Net-v4.0.csproj because this framework version does not support the native test attributes to do automatic testing.

To test other framework versions, please, take a look at the TargetedTests solution folder. In that folder you will find all the tests. Unload all of them, but keep the framework version you want to test, then build it. Visual Studio will see the newly built tests and will list them. If the other frameworks test projects are not unloaded, Visual Studio may or may not list them.

Errors while building test projects

Make sure to NOT LOAD MORE THAN ONE test project inside the TargetedTests solution folder.

  • Load a single test project

    Load Single Test Project

  • Update Test Framework Packages

    Update Test Framework Packages

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].