/NaiveCSharpFSharpEval

This package is only to test something. It synchronously evaluates C# or F# code and returns the string output.

Primary LanguageF#MIT LicenseMIT

Naive # Eval

Nuget (with prereleases)

This package is only to test something. It synchronously evaluates C# or F# code and returns the string output if succeeded.

Examples

Call C# from C#

if (NaiveSharpEval.Executor.ExecuteCSharp("(double)(1 + 2)", out var res))
    Console.WriteLine(res);
else
    Console.WriteLine("Error!");

Call F# from C#

if (NaiveSharpEval.Executor.ExecuteFSharp("(+) 1 2", out var res))
    Console.WriteLine(res);
else
    Console.WriteLine("Error!");

Call C# from F#

match NaiveSharpEval.Executor.ExecuteCSharp "(double)(1 + 2)" with
| (true, res) -> printfn "%s" res
| _ -> printfn "%s" "Error!"

Call F# from F#

match NaiveSharpEval.Executor.ExecuteFSharp "(+) 1 2" with
| (true, res) -> printfn "%s" res
| _ -> printfn "%s" "Error!"