Nukepayload2 / VBScriptDotNet

A patched VB interactive that runs with stable releases of Roslyn
MIT License
1 stars 1 forks source link

VBScriptDotNet

A patched VB interactive that runs with stable releases of Roslyn.

How to run VB interactive

Install binaries

Download VB Interactive

Store page: https://www.microsoft.com/store/productId/9N210C9TDZ95?ocid=pdpshare

Run with Visual Studio

Run with .NET 8 SDK

Available features

Configure script compilation with vbi.rsp

R Directive

The following code calls Newtonsoft.Json 13.0.3 stored in Windows NuGet package cache to serialize a number to JSON and prints the value in VB format.

#R "C:\Users\<your user name>\.nuget\packages\newtonsoft.json\13.0.3\lib\net8.0\Newtonsoft.Json.dll"
Newtonsoft.Json.JsonConvert.SerializeObject(1)

? Directive

Prints a value in VB format. The following code prints vbCrLf or vbLf depends on which OS you're using.

? Environment.NewLine

Top-level code

You can use Dim, Sub and Function without wrapping them explicitly. The following code prints Fibonacci sequence without declaring a class or module.

Function Fibonacci(n As Integer) As Integer
    If n <= 1 Then
        Return n
    Else
        Return Fibonacci(n - 1) + Fibonacci(n - 2)
    End If
End Function

Sub PrintFibonacci(count As Integer)
    Console.WriteLine(String.Join(",",
        From i In Enumerable.Range(1, count)
        Select Fibonacci(i)))
End Sub

Dim count = 10
PrintFibonacci(count)

Known issues

Significant problems:

For more information, see https://github.com/Nukepayload2/VBScriptDotNet/issues