CS2SX — Write Nintendo Switch Homebrew in C#
CS2SX — Write Nintendo Switch Homebrew in C#
A C#-to-C transpiler that builds ready-to-run .nro files
Have you ever wanted to write Switch homebrew but found C/C++ intimidating?
CS2SX lets you write standard C# and compiles it directly to a Nintendo Switch
.nro — no C knowledge required.
A C#-to-C transpiler that builds ready-to-run .nro files
Have you ever wanted to write Switch homebrew but found C/C++ intimidating?
CS2SX lets you write standard C# and compiles it directly to a Nintendo Switch
.nro — no C knowledge required.
You write this:
public class MyApp : SwitchApp{ private int _x = 640, _y = 360; private int _vx = 4, _vy = 3; public override void OnInit() => Graphics.Init(1280, 720); public override void OnFrame() { Graphics.FillScreen(Color.Black); _x += _vx; _y += _vy; if (_x < 20 || _x > 1260) _vx = -_vx; if (_y < 20 || _y > 700) _vy = -_vy; Graphics.FillCircle(_x, _y, 20, Color.RGB(0, 200, 255)); Graphics.DrawText(10, 10, "Press + to exit", Color.White, 1); if (Input.IsDown(NpadButton.Plus)) Environment.Exit(0); }}Run cs2sx build and put your .nro on your switch.
How it works
CS2SX is a transpiler — it reads your C# source using Roslyn (the official
Microsoft compiler frontend), converts it to clean C, and then hands it off to
DevkitPro's aarch64 GCC to produce the final .nro.
The entire workflow is one command:
cs2sx new MyApp # scaffold a new projectcs2sx build MyApp.csproj # transpile → compile → package → .nroCopy the .nro to /switch/MyApp/ on your SD card and launch it from the
Homebrew Menu. That's it.
What C# features are supported?
CS2SX supports a large and practical subset of C#:
- Full OOP — classes, inheritance, abstract/virtual/override, interfaces, generics
- Collections — List<T>, Dictionary<K,V>, Stack<T>, Queue<T>, HashSet<T>
- LINQ — Where, Select, OrderBy, GroupBy, First, Sum, Any, All and 30+ more
- Strings — interpolation, Trim/Replace/Split/Join, StringBuilder
- Value types — struct, enum, Nullable<T>, tuple returns
- Modern syntax — pattern matching, switch expressions, ??, ?.
- Extension methods, params[], ref/out parameters
Graphics & Input
CS2SX ships a built-in 2D framebuffer API:
// Shapes, text, texturesGraphics.FillRect(100, 100, 400, 200, Color.RGB(30, 30, 80));Graphics.FillCircle(640, 360, 80, Color.Green);Graphics.FillTriangle(900, 150, 1100, 150, 1000, 300, Color.Orange);Graphics.DrawText(10, 10, $"Score: {_score}", Color.White, 2);Graphics.DrawTextShadow(10, 50, "Shadow text", Color.White, Color.Black, 2);// Load BMP textures from romfs (embedded in the .nro)Texture icon = Graphics.LoadTexture("romfs:/icon.bmp");Graphics.DrawTextureCenteredScaled(icon, 0, 0, 1280, 720, 128, 128);// Buttons, analog sticks, touch screenif (Input.IsDown(NpadButton.A)) Jump();if (Input.IsHeld(NpadButton.ZR)) Shoot();StickPos stick = Input.GetStickLeft();TouchState touch = Input.GetTouch();if (touch.count > 0) Graphics.FillCircle(touch.X0, touch.Y0, 30, Color.Red);Project structure
A CS2SX project is a standard .csproj you can open in Visual Studio or Rider —
with full IntelliSense, autocomplete and error highlighting.
MyApp/├── MyApp.csproj ← open in any IDE├── cs2sx.json ← app name, author, icon├── MyApp.cs ← your code├── icon.jpg ← 256×256 app icon└── romfs/ ← assets embedded in .nro (BMPs, etc.)cs2sx.json:
{ "name": "MyApp", "author": "YourName", "version": "1.0.0", "icon": "icon.jpg"}Requirements
- .NET 8 SDK
- devkitA64 + libnx
- Environment variable DEVKITPRO set to your DevkitPro install path
//Install CS2SX via dotnetdotnet pack -c Releasedotnet tool install --global --add-source ./bin/Release CS2SXKnown limitations
Being honest up front:
- One SwitchApp subclass per project (the main entry point)
- Interpolated strings ($"...") create stack buffers — safe in locals and output calls, but don't store them in fields
- No garbage collector — heap objects live until freed (the transpiler handles this automatically for most cases)
- async/await compiles synchronously
- No Reflection
Source & Download
CS2SX is fully open source under the MIT license.
Download on Github:
Here you can see the Github page and releases
Example Projects:
Here you can see example Projects build with CS2SX
Issues, PRs and feature requests are welcome.
If you build something with it, I'd love to see it posted here!
Built with Roslyn · DevkitPro · libnx










