Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return void, set field value #2

Open
friuns2 opened this issue Jul 22, 2017 · 9 comments
Open

return void, set field value #2

friuns2 opened this issue Jul 22, 2017 · 9 comments
Labels

Comments

@friuns2
Copy link

friuns2 commented Jul 22, 2017

does it support any those?

var typeResolver = new KnownTypeResolver(typeof(Test), typeof(Console));
var test = new Test();
var exprTree = CSharpExpression.Evaluate<Test,int>("test.te=23", test,typeResolver:typeResolver);
throws error Unexpected symbol '='

var exprTree = CSharpExpression.Evaluate<System.void>("Console.Write(123)",typeResolver:typeResolver);
will not work because cannot use System.void
@deniszykov
Copy link
Owner

Hi. It is only support expressions. "a=b" is a statement.

"void" returning expressions currently are not supported too. I know it will be bit ugly, but you can wrap "Write" with your method which return something.

Mutation could be done with methods - "test.SetValue(23)"

@friuns2
Copy link
Author

friuns2 commented Jul 25, 2017

ok thanks, too bad statements would be usefull :)

@catdawg
Copy link

catdawg commented Nov 29, 2017

I really need this feature, so before I dig into the code to figure out how to add it, is there a strong reason why this is not supported? Thanks!

@deniszykov
Copy link
Owner

I really need this feature

Which one?

  1. Action expressions (void return type)
  2. Statements

@catdawg
Copy link

catdawg commented Nov 29, 2017

Sorry should have been clearer 😅 the void expressions.

@deniszykov
Copy link
Owner

Actually not much. New methods for CSharpExpression a few changes in Binder and AotCompiler. I could try to implement it tomorrow.

On the other hand, statements is a huge feature and in the near future I do not plan to implement it.

@catdawg
Copy link

catdawg commented Nov 30, 2017

If you could implement this, I would be extremely likely to use your lib :) Thanks for the fast responses btw!

@deniszykov
Copy link
Owner

deniszykov commented Nov 30, 2017

I have updated NuGet package to version 2.2.0 where Action delegates are supported.
Or you could build from sources 4c49d86. Or wait for Unity Asset Store update.

@catdawg
Copy link

catdawg commented Dec 1, 2017

Cool! I'll try it out, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants