A free & open source .NET global tool

A command-line C# REPL

Prototype code, probe libraries, and see what the compiler does under-the-hood, without leaving the terminal.

$ dotnet tool install -g csharprepl
Source on GitHub

MPL-2.0 licensed·Windows·macOS · Linux

// prototype

Try ideas without the ceremony

Run C# and see the result immediately; no scratch console projects needed. Command-line autocomplete with inline documentation keeps the reference at your fingertips.

A csharprepl session building and draining a PriorityQueue, with syntax-highlighted output.

Ctrl+Enter

Rich output formatting

Results are formatted with syntax highlighting and Spectre.Console rendering. Press Ctrl+Enter on any line for a detailed, member-by-member view of the object.

DateTime.Now shown two ways in the REPL: a one-line default representation, then a Ctrl+Enter member-by-member breakdown.

#r "nuget: …"

Pull in any NuGet package

Reference a package with the #r directive and start using it on the next line. The completion window shows documentation for the package's methods and types.

Installing the NSubstitute NuGet package with #r and immediately using it in the REPL.

#r "App.csproj"

Point it at your own code

The same #r directive takes assemblies, .csproj projects, and .sln / .slnx solutions. Load your project, then call straight into it.

Building and referencing a local .csproj from the REPL, then calling its Main method.

F12

Jump to the real source

Googling for a library's implementation? Press F12 instead on any symbol to open its original source in the browser, for every assembly that supports Source Link.

Pressing F12 on DateTime.Now opens the corresponding source on GitHub.

F9 · F8

See what the compiler does

Press F9 for the IL of any statement, or F8 for the lowered C#. Explore async state machines, lambda closures, and foreach / using expansions made explicit. Hold Ctrl to see Release-mode optimizations. Powered by ILSpy.

The IL disassembly for a Console.WriteLine call, shown inline in the REPL.

csharprepl connect <pid>

Attach and modify a running process

Beyond its own process, csharprepl can attach to another .NET 10 app and evaluate C# inside it, reading and writing live statics and DI-resolved services, with the same interactivity as the normal REPL. Use #replace or #wrap to modify method implementations.

A real Roslyn engine is injected via the .NET runtime's startup-hook support; the target opts in by setting a few environment variables. Development and diagnostics only! Never connect to a production process.

csharprepl connected to a running ASP.NET Core app, reading live configuration and DI-resolved services from inside the process, alongside the target app's console.

// keyboard reference

Familiar keyboard shortcuts

Editing and navigation mirror Visual Studio, so the keyboard shortcuts feel natural.

Evaluate

  • Run, or break the lineEnter
  • Insert a newlineShift+Enter
  • Run with detailCtrl+Enter
  • AutocompleteCtrl+Space
  • Cancel · clear · exitCtrl+C L D

Inspect

  • MSDN docs for symbolF1
  • Go to sourceF12
  • IL (Debug · Release)F9 Ctrl+F9
  • Lowered C# (Debug · Release)F8 Ctrl+F8

Reference

  • NuGet package#r "nuget: …"
  • Project or solution#r "App.csproj"
  • Assembly by name or path#r "Lib.dll"
  • Bring your own themetheme.json

$ get started

Install the global tool

Requires the .NET 10 SDK. Runs on Windows, macOS, and Linux.

$ dotnet tool install -g csharprepl

Update later with dotnet tool update -g csharprepl