CSScript.LoadMethod

24 views
Skip to first unread message

Nicolas vautrin

unread,
Jul 4, 2019, 6:10:19 PM7/4/19
to CS-Script
          Hello,
IsOutOfDateAlgorithm  always return true, do you know why ?
      
            CSScript.CacheEnabled = true;

            CSScript.IsOutOfDateAlgorithm = (script, dll) =>
            {
                bool ret = CSScript.CachProbing.Advanced(script, dll);
                return ret;
            };

var code = @"int Sqr(int a)
                            {
                                return a * a;
                            }";

                dynamic script = CSScript.LoadMethod(code, "sqrt.dll", true).CreateObject("*");

Oleg Shilo

unread,
Jul 6, 2019, 9:20:18 PM7/6/19
to cs-s...@googlegroups.com
`IsOutOfDateAlgorithm ` is an algorithm that answers the question "Is the script file changed since the last execution?"

Since you are not using script file but script code, the algorithm will always respond "yes the script file is changed". This response is the only reliable logical return result as script code is written in a random script file before being executed. Thus every time it is a new file.

Saying that `CSScript.CacheEnabled = true` still works within a single session (process). Thus if you call ` CSScript.LoadMethod(code, "sqrt.dll", true) ` N times it will be compiled only once. Thus a break point in your ` CSScript.IsOutOfDateAlgorithm = (script, dll) => . . .` will be fired only once.

If you truly need to achieve inter-session caching then you will need to handle `code->file` transition by yourself.
=====================

You may want to use https://github.com/oleg-shilo/cs-script/issues for further discussions. It's just more convenient communication channel.


Reply all
Reply to author
Forward
0 new messages