Skip to content

MicroCS Studio

github-actions[bot] edited this page Oct 12, 2026 · 3 revisions

MicroCS Studio

A browser IDE for boards running MicroCS: file manager, C# editor and REPL over USB (Web Serial). Visual Studio 2022 Dark look.

Run it

Click Connect, pick the board's serial port, done. Firefox and Safari have no Web Serial: the editor works there, but it can't connect to a board.

Files

File What it holds
index.html page layout
studio.css look: Visual Studio 2022 Dark / Light, C# colours (--t-* variables)
studio.js the app: serial link and shell protocol, editor, file manager, console
templates/ the templates and examples: one folder per category, plain .cs files + a templates.txt describing them (how to add one)
templates.js generated from templates/ by python3 gen_templates.py (the page loads it; CI checks it is current)
snippets.js completion snippets (label, detail, text with $0 for the caret)
api.js class and member names known to the runtime (completion fallback)
docs.js signatures and one-line docs of every library member (completion details, parameter info, hover)
lang.js C# language service: symbols of the open file, type inference, call context

No build step for the app: edit a file and reload the page. After changing a template run python3 tools/studio/gen_templates.py (or make studio-templates).

Editor keys

Keys Action
Ctrl+Space · Ctrl+Shift+Space completion (with docs) · parameter info (↑/↓ switch overloads)
Ctrl+F · Ctrl+H · F3 / Shift+F3 find · replace · next / previous match
Ctrl+G · Ctrl+] go to line · jump to the matching bracket
Shift+Alt+F format document
Alt+↑/↓ · Shift+Alt+↑/↓ · Ctrl+D · Ctrl+Shift+K move line · copy line · duplicate · delete line
Ctrl+/ · Tab / Shift+Tab toggle comment · indent / outdent
F5 / Ctrl+Enter · Ctrl+Shift+Enter · Ctrl+S save and run · run the selection · save

Document an API

docs.js holds one line per member, e.g.

@GPIO | Digital pins (modules/hal)
Write(pin pin, bool value): void | Drives the pin: true / 1 = high, false / 0 = low
.Value: bool | (a leading "." = instance member)      const Rising: int | constant

Repeat a line for each overload; new(...) lines are constructors.

Templates dialog

Alt+T (or Templates) opens it: categories on the left (Recent holds the last ones you used), search across names, descriptions and code (every word must match; name hits come first and are highlighted), a preview with tags, line count, a copy button and a link to the source file. ↑/↓, PgUp/PgDn, Home/End move, Enter adds the template as a new file (named so it doesn't clash with an open tab), Ctrl+Enter inserts it at the cursor, Esc clears the search, then closes. Saving a new file over an existing one on the device asks first.

Connection notes

Studio leaves DTR/RTS as the browser opens the port (both asserted), which does not reset ESP32 boards with the usual auto-reset circuit or the native USB-Serial-JTAG. Reset board pulses EN like esptool. A board that sits in the ROM download mode is reset once automatically. If a board needs the lines low, enable ⋯ → Release DTR/RTS on connect.

Jobs

Scheduler.Every / Scheduler.After jobs keep running after their script returns (and after its file is deleted). So that re-running a script does not stack copies, Run first sends cancel scripts (⋯ → Stop script jobs before each Run, on by default); jobs.cfg jobs are left alone. ⋯ → Show running jobs lists them, ⋯ → Stop all jobs cancels every job until the next reset.

Add a template

Append to templates.js:

T("GPIO", "My blinker", "myblink.cs",
  "One line shown in the list.", String.raw`
var led = new Pin(2, GPIO.Output);
led.Toggle();
`);

String.raw keeps \n and other escapes as they are, so you can paste C# straight in. node tests/studio/test_templates.js ./mcs compiles and runs every C# template on the simulated board. Templates that use U8g2 / U8x8 start with an if (!Drivers.Has("u8g2")) { ...; return; } hint and are run against the simulated OLED with a u8g2 build: make fetch-u8g2 mcs-u8g2 && node tests/studio/test_templates.js build/mcs_u8g2 --only=u8g2. tests/studio/test_studio.js tests the page in a headless browser.

Protocol and features: docs/STANDALONE.md.

Clone this wiki locally