All Projects → shaked6540 → csharp

shaked6540 / csharp

Licence: MIT license
Run c# code from the command line, like python or javascript

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to csharp

swiftreplmadness
Example of using your own packages in the Swift REPL
Stars: ✭ 18 (-18.18%)
Mutual labels:  repl
blac
bitFlyer Lightning API Console
Stars: ✭ 16 (-27.27%)
Mutual labels:  repl
charm
A [ functional stack ] based language.
Stars: ✭ 26 (+18.18%)
Mutual labels:  repl
sliver
REPL for SilverStripe, powered by Psysh. Interactively debug and tinker with a sliver of your code.
Stars: ✭ 17 (-22.73%)
Mutual labels:  repl
crosis
A JavaScript client that speaks Replit's container protocol
Stars: ✭ 85 (+286.36%)
Mutual labels:  repl
moleculer-repl
REPL module for Moleculer framework
Stars: ✭ 24 (+9.09%)
Mutual labels:  repl
Ipython
Official repository for IPython itself. Other repos in the IPython organization contain things like the website, documentation builds, etc.
Stars: ✭ 15,107 (+68568.18%)
Mutual labels:  repl
maverick
Web IDE and REPL for the Ink programming language, written in pure Ink on a self-hosted compiler toolchain
Stars: ✭ 26 (+18.18%)
Mutual labels:  repl
gorilla-repl
A fork of Jony Epsilon's rich REPL for Clojure in the notebook style.
Stars: ✭ 22 (+0%)
Mutual labels:  repl
igcc
Interactive GCC - C/C++ REPL.
Stars: ✭ 38 (+72.73%)
Mutual labels:  repl
dotnet-repl
A polyglot REPL built on .NET Interactive
Stars: ✭ 522 (+2272.73%)
Mutual labels:  repl
fundot
The Fundot programming language.
Stars: ✭ 15 (-31.82%)
Mutual labels:  repl
go-notebook
Go-Notebook is inspired by Jupyter Project (link) in order to document Golang code.
Stars: ✭ 33 (+50%)
Mutual labels:  repl
generic-for-core
🏗️ Generic Repository & UOW Pattern For ASP.NET Core
Stars: ✭ 55 (+150%)
Mutual labels:  net-core-3-1
bspl
Bit-Shift-Print Loop
Stars: ✭ 17 (-22.73%)
Mutual labels:  repl
PocoDynamo
C# .NET Typed POCO Client for AWS Dynamo DB
Stars: ✭ 39 (+77.27%)
Mutual labels:  net-core
dotnet-setversion
.NET Core CLI tool to update the version information in .NET Core *.csproj files
Stars: ✭ 61 (+177.27%)
Mutual labels:  net-core
ipld-explorer-cli
🔎 Explore the IPLD directed acyclic graph with your keyboard
Stars: ✭ 22 (+0%)
Mutual labels:  repl
duct-figwheel-component
A component for running Figwheel
Stars: ✭ 18 (-18.18%)
Mutual labels:  repl
TimeRecorder
工数管理アプリ
Stars: ✭ 51 (+131.82%)
Mutual labels:  net-core

csharp

Run c# code from the command line, like python or javascript.

Gif

Features

  • Run c# code form the command line
  • No semicolons needed
  • Load external assemblies
  • Save scripts
  • Single executeable, ready to run out of the box
  • Supports Windows, Linux, macOS, and Android (Instructions to install on android will be at the bottom)
  • Autocomplete when pressing tab

Built-in functions

help

help is a function that takes any object or a Type and prints all its methods, properties, fields and events. Sometimes its faster to just type help(typeof(int)) than to open the documentaion. img

variables

variables is a function that prints all the variables that exist in the current script session and their values. img

Installing

You don't need to do anything special to install csharp, just go to the actions page (note: if the artifacts got deleted, you can simply fork this repository and run the default action yourself), select the newest entry, download the version that matches your needs then extract it and run it. If you have .NET Core 3.1 installed, select the framework dependent version, if not, select the self contained version.

Or build it by yourself and drop it in a folder.

I recommend adding the executable location to PATH.

Here is how to add a value to PATH on Linux

Here is how to add a value to PATH on Windows

Building

  1. Clone the project using git
  2. Open a commandline and run dotnet publish -c Release --self-contained false -p:PublishSingleFile=true -r win-x64. Replace --self-contained false to --self-contained true if you wish to build a self contained version of the program. Replace win-x64 with your platform if you build for an OS other than windows.

Configuring

csharp can be configured using a config file, simply place a 'Config.json' file in the same folder as the exectueable and add the following properties.

Note: you don't need to add all of them, they are all optional.

  • Assemblies: An array of strings containing file names of assemblies that will be loaded when csharp runs. Usually, there will be a bunch of dll files here. The assemblies must be in the same folder as the executeable
  • Namespaces: An array of strings containing names of namespaces that will be included when running csharp. This is equivalent to "using x;"
  • BeforeScriptFile: A string containing a path to file that will be loaded before user input. This is useful if you want to exectue something every time you start csharp, for example, creating a variable that holds the names of all the files in the current directory
  • SaveScripts: A boolean to indicate whether the running code will be saved to a .txt file or not.
  • SavedScriptsLocation: A string containing a path to a folder where the scripts will be saved. If this property is missing but SaveScripts is set to true, it defaults to a folder called Scripts which will be created where the exectueable resides
  • NewlinePrefix: A string indicating what prefix will be displayed when csharp prompts a user input. The default value is "> "
  • MultilineCodeKeyword: A string indicating what value, when entered, will wait until the EndKeyword is inserted before exectuing the code. This means you will be able to insert as many new lines as you want without executing the code until EndKeyword is entered. The default value is lines
  • EndKeyword: A string indicating what value, when entered, will execute the code that was writtin since MultilineCodeKeyword was entered. If MultilineCodeKeyword was not entered prior to using this keyword, the program will exit. The default value is end

An example of a full Config.json file:

{
    "Assemblies": ["MoreLinq.dll"],
    "Namespaces": ["MoreLinq","System.Text.Json"],
    "BeforeScriptFile": "D:\\csharp\\BeforeScript.cs",
    "SaveScripts": true,
    "SavedScriptsLocation": "D:\\csharp\\Scripts",
    "NewlinePrefix": "> ",
    "MultilineCodeKeyword": "lines",
    "EndKeyword": "end"
}

An example of a BeforeScript.cs (Note: semicolons are optional here too!) :

public static void cw(object o) => Console.WriteLine(o);
var files = Directory.GetFiles(Directory.GetCurrentDirectory());
class MyClass
{
    public int myInt
    public string myString
    
    public MyClass(int myInt, string myString) 
    {
        this.myInt = myInt
        this.myString = myString
    }
    
    public void Print() 
    {
        cw($"{myInt} - {myString}");
    }
    
}

var myClass = new MyClass(5, "Hello")
myClass.Print()

Installing on Android

  1. Install termux.
  2. Install ubunutu using this guide
  3. (Optional) If you want to use the framework dependent build of the program, install .NET Core 3.1 from here (32bit) or here (64bit) and follow the instructions provided
  4. Thats it! run the program. I recommend adding the executeable location to PATH so you don't need to navigate to it every time. I also recommend adding the startubuntu.sh script to PATH or create an alias for it in .bashrc.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].