GitHub - mx7b7/codesnip-avalonia: CodeSnip — a cross-platform snippet manager and local code runner with multi-language interpreter support and Compiler Explorer integration.

4 min read Original article ↗

CodeSnip — a snippet manager & local code runner with multi-language interpreter support and Compiler Explorer integration.

This project began as a port of the original CodeSnip (WPF) application to Avalonia, but has since grown beyond a direct port with new features and improvements.

.NET Platform License: MIT Status

⬇️ Download

GitHub Release


Slideshow GIF


✨ Features

  • Local storage with SQLite
    All snippets are stored privately on your device.

  • Snippet organization:

    • Hierarchical: Language → Category → Snippet (TreeView)
    • Filter by name or tags
    • Instant search
  • AvaloniaEdit integration:

    • Dual‑Mode syntax highlighting: Support for both native XSHD and TextMateSharp tokenizers.
    • Syntax highlighting (light/dark mode)
    • Toggle single-line and multi-line comments
  • Highlighting Editor:

    • Dual-Mode Editing: Tabbed interface for both visual tweaks (colors, font styles) and advanced source code editing.
    • Direct XSHD Source Editing: Edit raw .xshd XML for full control over rules, spans, and keywords.
    • Preview on Demand: Apply changes from the XSHD source to the main editor before saving.
    • Validation: Integrated validation engine checks for XML errors and XSHD schema compliance.
    • Note: The Highlighting Editor is designed exclusively for editing XSHD syntax definition files.

  • Compiler Explorer (Godbolt) integration:

    • Compile snippets without installing compilers locally
    • Support for 30+ languages
    • Add or edit available compilers
    • Select compiler and flags
    • View stdout/stderr output
    • View assembly output with syntax highlighting for supported languages
    • Generate shareable shortlinks to Compiler Explorer
  • Local Code Execution:

    • Run scripts using built‑in support for Shell scripts (.sh), C#, F#, PowerShell, Python, PHP, Perl, Lua, Ruby, Node.js, and Java (via JShell) directly using local interpreters.
    • Dual-mode runner: Internal execution or external native terminal.
    • Internal Mode: Quiet execution inside the app.
    • External mode: Native terminal, full interactivity, sudo/password input, and script arguments from the app.
      • Supported languages: Python, JavaScript, Lua, PowerShell, Bash, and Java.
    • Note: If an interpreter is not in your system's PATH, you can place its portable executable (e.g., lua, node, csrunner, fsrunner) in the Tools/Interpreters directory within the application's installation folder.

    • For C# and F# execution, you can use these custom wrappers:
      • C#: csrunner
      • F#: fsrunner or fsrunner-alt
      • These wrappers are provided as Gists for convenience, as building for all platforms is not feasible.

  • UI/UX:

    • Responsive interface using Avalonia's SimpleTheme
    • Flyout panels for additional windows (settings, editors, actions, etc.)
    • Automatic loading of theme and syntax definitions
  • Export & Sharing:

    • Copy As: Copy selected code as Markdown, HTML, BBCode, Base64, or JSON string.
    • Export to File: Save the entire snippet or a specific selection as a PNG Images or in its original language format.

🧩 Supported Syntax Engines

Engine Status Language Coverage
XSHD (AvaloniaEdit) Built‑in 36+ bundled definitions (light/dark variants) • Unlimited via custom .xshd files
TextMateSharp Supported 60+ bundled grammars from TextMateSharp.Grammars • Unlimited via local .tmLanguage.json files

📦 Libraries

This project uses the following open-source libraries:


🧹 Code Formatters

CodeSnip integrates various code formatters. The application first looks for the required executable in the Tools directory within its installation folder. If not found, it falls back to searching the system's PATH.

Supported Formatters


⚙️ Build

To build and run CodeSnip, you need the .NET 10 SDK.

Note: The application has been tested on Windows 10 and Linux Mint 22.3, macOS support is untested.

🚀 Quick Build (Recommended)

Open your terminal in the src/CodeSnip directory and run the interactive script for your platform:

  • Windows: Run build.bat
  • Linux / macOS: Run ./build.sh (make sure it has execute permissions: chmod +x build.sh)

🛠️ Manual Build & Run

If you prefer using the standard .NET CLI inside the src/CodeSnip directory, use the following commands:

Run the application:

Create a Release Build:

Windows (x64)

Linux (x64)

dotnet build -c Release-Linux

macOS (ARM64)

dotnet build -c Release-Mac-ARM

After building, the complete application will be available in the bin/<configuration>/net10.0/<runtime> directory.


📜 License

This project is licensed under the MIT License.
See the LICENSE file for details.


Tags: snippet manager, code runner, Avalonia UI, cross-platform, C#, SQLite, AvaloniaEdit, syntax highlighting, Godbolt, xshd, developer tools, open source, code snippets, code execution, script runner, code playground