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 is a cross-platform port of the original CodeSnip (WPF) application to the UI framework Avalonia.

.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.

  • 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 included); unlimited via custom .xshd files
TextMateSharp Supported 60+ bundled grammars included in the TextMateSharp.Grammars library
User‑Provided Definitions Supported Unlimited — users can add custom XSHD manually

📦 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. The main project is located in the src/CodeSnip directory.

  1. Clone the repository:
    git clone https://github.com/mx7b7/codesnip-avalonia.git
  2. Navigate to the root directory:
  3. Run the application from your IDE or use the following command for a quick test:
    dotnet run --project src/CodeSnip

Creating a Self-Contained Release Package

You can create a portable, self-contained release package for your target platform using the dotnet publish command. Run these commands from the root of the repository.

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

Windows (x64)

dotnet publish src/CodeSnip -c Release --self-contained true

Linux (x64)

dotnet publish src/CodeSnip -c Release-Linux --self-contained true

macOS (ARM64)

dotnet publish src/CodeSnip -c Release-Mac-ARM --self-contained true

After publishing, the complete application will be available in the bin/<configuration>/net10/<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