[Mono-dev] Mono.CSharp.Evaluator: x.GetType Bug?

lukebuehler lukas.buehler at gmail.com
Fri Jan 25 18:10:59 UTC 2013


No that doesn't work.

1. Your code gives me the same exception
2. A quick look with reflector shows me that eval.Run is just a wrapper
over eval.Evaluate.
3. To prove it, this works:
    evaluator.Evaluate("class A{ public int X;}", out result, out set);
    evaluator.Evaluate("var a = new A{X=10};", out result, out set);
    evaluator.Evaluate("var b = new A{X=20};", out result, out set);
    // this prints 30 without an exception
    evaluator.Evaluate("print(a.X+b.X);", out result, out set);

It's only the GetType call that trips up the compiler.

Cheers
-luke


On Fri, Jan 25, 2013 at 12:58 PM, Robert Jordan [via Mono] <
ml-node+s1490590n4658289h95 at n4.nabble.com> wrote:

> On 25.01.2013 18:33, lukebuehler wrote:
> >      //this doesnt work
> >      evaluator.Evaluate("var a = new A();", out result, out set);
> >      //Error here:
> >      evaluator.Evaluate("a.GetType();", out result, out set);
> >      Console.WriteLine(result);
>
> Local variables don't survive the evaluation. You must "Run()" them:
>
> evaluator.Run("var a = new A();");
> evaluator.Evaluate("a.GetType();");
>
>
> Robert
>
>
> _______________________________________________
> Mono-devel-list mailing list
> [hidden email] <http://user/SendEmail.jtp?type=node&node=4658289&i=0>
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://mono.1490590.n4.nabble.com/Mono-CSharp-Evaluator-x-GetType-Bug-tp4658288p4658289.html
>  To unsubscribe from Mono.CSharp.Evaluator: x.GetType Bug?, click here<http://mono.1490590.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4658288&code=bHVrYXMuYnVlaGxlckBnbWFpbC5jb218NDY1ODI4OHw5NTQyOTA5MA==>
> .
> NAML<http://mono.1490590.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://mono.1490590.n4.nabble.com/Mono-CSharp-Evaluator-x-GetType-Bug-tp4658288p4658290.html
Sent from the Mono - Dev mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20130125/763117bd/attachment.html>


More information about the Mono-devel-list mailing list