Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/whiteblackgoose/naivecsharpfsharpeval

This package is only to test something. It synchronously evaluates C# or F# code and returns the string output.
https://github.com/whiteblackgoose/naivecsharpfsharpeval

Last synced: 18 days ago
JSON representation

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

Awesome Lists containing this project

README

        

# Naive # Eval

[![Nuget (with prereleases)](https://img.shields.io/nuget/vpre/NaiveSharpEval?label=NuGet&logo=nuget)](https://www.nuget.org/packages/NaiveSharpEval/)

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#

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

### Call F# from C#

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

### Call C# from F#

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

### Call F# from F#

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