dynamicexpresso / DynamicExpresso

C# expressions interpreter
http://dynamic-expresso.azurewebsites.net/
MIT License
1.91k stars 364 forks source link

.NET Standard/Core support #48

Closed davideicardi closed 6 years ago

davideicardi commented 7 years ago

See dotNetCore branch.

aligin commented 7 years ago

Are the dotNetCore branch usable? I'm choosing the library to parse and evaluate logic expressions, but our stack is full .NET Core. So if the branch is usable can you share it in Nuget as prerelease? Thanks a lot.

davideicardi commented 7 years ago

Not yet. @manfredk worked on it some time ago but then we have changed some minor things on master. So it should be probably merged again and completed with the .NET core feature. I think it should be quite easy but... Of course any help is welcome 😄 .

aligin commented 7 years ago

So, the question is. Should the code must be migrated to dotNetCore (dotnet 4.5 and netstandard1.6) or both dotnet4 and dotnet core? @manfredk tried second variant while I see, for example IdentityServer4 migrated to clean dotNetCore. I'll be glad to help with migration.

davideicardi commented 7 years ago

I still not played with .NET Core and company ... So I'm really not an expert on this and I don't know what to suggest.

@manfredk Any suggestion?

If you want you can try to continue @manfredk branch or start a new branch with a different approach if you prefer.

In general I think that we should continue to support all .NET versions at least for one or two years, but probably new features can be implemented only on new .NET core.

manfredk commented 7 years ago

@davideicardi @aligin I recently came across the github project by Stef Heyenrath who ported System.Linq.Dynamic.Core. Though still a quick hack, I managed to integrate DynamicExpresso in our UWP Windows10 project and it works quite well, but had not yet time to update my fork.

I would definitely try to take the inspiration by his port of the ExpressionParser (see: https://github.com/StefH/System.Linq.Dynamic.Core/blob/master/src/System.Linq.Dynamic.Core/ExpressionParser.cs)

aligin commented 7 years ago

@manfredk @davideicardi It seems I've done porting to netcoreapp1.1 without System.Linq.Dynamic.Core in separate branch. All tests passed and samples works like a charm.

@manfredk you did a great job. I used your platform specific code mostly. I found a bug in MemberInfo FindPropertyOrField() in Parser.cs. These strings

var fields = type.GetFields(....
var properties = type.GetProperties(....

must be

var fields = t.GetFields(....
var properties = t.GetProperties(....

I targeted the library to 2 frameworks: netcoreapp1.1 and net40. So people who uses .net 4.0 can still use the library from nuget.

There is no Nunit 2.6 netcore implementation, so I've done the migration to nunit 3.6 (mostly ExpectedExceptionAttribute became Assert.Throws).

Also I've added ASP.NET Core sample to DynamicExpressoWebShell. It contains the same code, exept WebShell.cs. I've used ASP.NET Core DI.

I'll push a branch in an hour.

@davideicardi to compile project you must install https://www.microsoft.com/net/download/core#/current/sdk first. I've copied to project.json all fields from .nuspec so all you need to make a package in DynamicExpresso.Core project directory make

dotnet pack -c Release

The tool will make .nupkg and .symbols.nupkg in \bin directory and will automatically target the package to two frameworks.

aligin commented 7 years ago

@davideicardi Can you create branch dotNetCoreApp? I'll make pull request.

manfredk commented 7 years ago

@aligin Sergey, thanks for the hint, I'll fix that as soon as possible.

davideicardi commented 7 years ago

Thanks @aligin ! 👍 Just created dotNetCoreApp branch from master. Let me know if you need anything else.

Again thanks a lot for your help guys!

davideicardi commented 7 years ago

Now that we have the new dotNetCoreApp branch do you think that we can remove the previous dotNetCore branch? Or can be useful for other integrations?

aligin commented 7 years ago

@davideicardi Sorry for late reply. I've succesfully integrated the library from dotNetCoreApp in my .net Core application. I think you may remove previos branch, cause it targets only windows universal framework and does not completed. So I've found how to test .net 4.0 framework in this solution. We must return back DynamicExpresso.Core.csproj and maybe create another .sln file. I'll experiment on this. In that way there will be not so much pain to support both 4.0 framework and .net Core.

davideicardi commented 6 years ago

I'm again working on this. I have created a new branch dotNetStandard, using the new csproj format and targeting net4.6.1 and netstandard2.0

davideicardi commented 6 years ago

Here a preview package for .NET Core 2.0 and .NET 4.61: https://www.nuget.org/packages/DynamicExpresso.Core/2.0.0-alpha

Any feedback is appreciated