Thank you very much for your sharing. It's awesome that we don't need to download the compiler through nuget anymore!
In order to speed up the execution, I converted the CsScript class to a library and generated a dll.
Then I created a function named "Temp" and executed the sample code below. The speed is very fast,
however, I don't know how to make it support various types of parameters and return values. The following is the operation demonstration.
If it could be simplified to the following way of calling, it would be very convenient.
Macro Macro7
In order to speed up the execution, I converted the CsScript class to a library and generated a dll.
Then I created a function named "Temp" and executed the sample code below. The speed is very fast,
however, I don't know how to make it support various types of parameters and return values. The following is the operation demonstration.
If it could be simplified to the following way of calling, it would be very convenient.
out LaHttpCall(F"code={_s}" "fun=Add" "a=6" "b=7")
out LaHttpCall(F"code={_s}" "fun=Hi" "name=Lisa")
Macro Macro7
_s=
;{}public class Class1
;{
;,public static int Add(int a, int b)
;,{ return a + b; }
;}
out LaHttpCall("Temp" F"code={_s}" "cla=Class1" "fun=Add" "a=6" "b=7")
;__________________________________________________________________Todo: make HSFun_Temp.cs support various types of parameters and return values
_s=
;{}public class Class8 {
;,public static string Hi(string name) {
;,,string r = $"hello {name} ";
;,,Console.WriteLine(r);
;,,return r;
;,}
;}
;out LaHttpCall("Temp" F"code={_s}" "cla=Class8" "fun=Hi" "name=Lisa") ;;Todo:
// class "HSFun_Temp.cs"
/*/ r CsScript.dll; /*/
//Todo: make Temp support various types of parameters and return values
static partial class Functions {
public static int Temp(string code, string cla, string fun, int a, int b) {
var c = CsScript.Compile(code);
var f = c.GetMethod<Func<int, int, int>>(cla, fun);
return f(a, b);
}
}