before any one mark this as duplicate please try to understand what i need
I have a software created in C# ASP.NET MVC5 were user can create any formula basically if..Else,switch condition which might include some custom function also from my custom DLL which include datediff,DatePart.
So for this scenario early we were using VBScript with the help of MSScriptControl but we decided to move for C# like syntax for formula.
i have explore much like CodeDom and Roslyn but the problem is it take almost AVG 130 ms for compile of 10 line of code.
later i have also try to implement CS-Script which is much slow than above two because it internally uses CodeDOM,Roslyn,MONO as compiler option.
Now what i'm looking is alternate of VBScript which almost take 11 ms for compile and execute.
Please suggest me any other way or tool for this scenario.
How to improve compile time using CSharpCodeProvider
`using Microsoft.CSharp;
using System;
using System.CodeDom.Compiler;`
`namespace abc
{
public class Abc
{
static void Main()
{
var code = @"
using System;
namespace First
{
public class program
{
public static int Main()
{
if(Convert.ToDateTime(""01-04-2019
10:25:00"")>Convert.ToDateTime(""01-04-2019 15:00:00""))
{
return 1;
}
else
{
return 0;
}
}
}
}";
Console.WriteLine(code);
var options = new CompilerParameters();
options.GenerateExecutable = false;
options.GenerateInMemory = false;
var provider = new CSharpCodeProvider();
var compile = provider.CompileAssemblyFromSource(options, code);
var type = compile.CompiledAssembly.GetType("First.program");
var abc = Activator.CreateInstance(type);`
`var method = type.GetMethod("Main");
var result = method.Invoke(abc, null);`
`Console.WriteLine(result); //output:`
`}`
`}`
`}`