GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — REPL

REPL

Jump to bottom Edit New page
Adam Ralph edited this page Mar 5, 2015 · 7 revisions

scriptcs supports REPL which is an acronym for Read–Eval–Print Loop. The scriptcs REPL allows you to quickly try out and experiment with C# code without the need of a script file or IDE.

The REPL uses the context of the directory it's executed in, so you automatically have access to all installed packages.

You can also (just like in script files) use the #load and #r directives to reference CSX files and assemblies.

Usage

The scriptcs REPL can be started by running scriptcs without any parameters.
To exit, press CTRL+C at any time.

Referencing assemblies from REPL

To reference other assemblies, you can use the #r directive.

C:\>scriptcs
scriptcs (ctrl-c to exit or :help for help)

> #r "MyAssembly.dll" 

The scriptcs runtime will first try to resolve and load the assembly from the bin folder, and if that fails, try loading it from the GAC.

Referencing script files from REPL

To reference other script files, you can use the #load directive. The path provided can be either absolute or relative.

C:\>scriptcs
scriptcs (ctrl-c to exit or :help for help)

> #load "MyFile.csx"
> #load "C:/MyFile.csx"

Referencing NuGet packages from REPL

In the example below, we install the Newtonsoft.Json NuGet package and use it inside the scriptcs REPL.

C:\>scriptcs -install Newtonsoft.Json
INFO : Installing packages...
Installing packages...
Installed: Newtonsoft.Json
Package installation succeeded.
Saving packages in scriptcs_packages.config...
Creating scriptcs_packages.config...
Added Newtonsoft.Json (v6.0.8, .NET 4.5) to scriptcs_packages.config
Successfully updated scriptcs_packages.config.

C:\>scriptcs
scriptcs (ctrl-c to exit or :help for help)

> using Newtonsoft.Json;
> JsonConvert.SerializeObject(DateTime.Now);
"2013-05-22T12:50:47.2474102+02:00"
Add a custom footer

Table of contents

  • Home
    • Goals and Roadmap
      • 1.0
    • Contributors
    • Who is using scriptcs
    • Installation
  • Build scriptcs
  • Building on Mac and Linux
  • Using scriptcs
  • The command line
  • Package installation
  • Writing a script
  • Compiling (and caching) to a .dll
  • Debugging a script
  • REPL
  • Running scripts in Atom
  • REPL
    • REPL Commands
  • Script Packs
    • Script Pack overview
    • Script Packs master list
    • Authoring script packs
  • Script Libraries
    • Script Library overview
  • Modules
    • Module overview
    • Modules master list
  • Hosting
  • Community
    • Community posts
    • Presentations & talks
    • Screencasts
  • Known Issues
    • NuGet v3

Clone this wiki locally

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.