Project Overview
What sharp-runtime is, its purpose, goals, and current status.
What is sharp-runtime?
sharp-runtime is a C++23 static library that reimplements a practical subset of
the .NET System.* namespace hierarchy. Its primary goal is to enable source-porting
of C#/XNA game code to C++ with minimal changes, while providing a clean and modern C++ implementation
that does not require the Common Language Runtime (CLR) or any managed runtime.
The public API closely mirrors .NET — class names, method signatures, and namespace structure all follow the .NET standard library conventions. The underlying C++ implementations use standard containers, RAII, and C++23 features.
Main Purpose
sharp-runtime provides building blocks so that ported C#/XNA code can compile and run as native C++ with minimal changes. These building blocks include:
- C#-like primitive type aliases (
intcs,bytecs,shortcs, etc.) - Exception hierarchy matching .NET (
System::Exception,System::ArgumentException, etc.) - Delegate and event mechanisms (
System::Action,System::EventHandler<T>) - String utilities (
System::Stringstatic helpers overstd::string) - Array helpers (
System::Arraystatic templates overstd::vector) - Generic collections (
List<T>,Dictionary<K,V>,HashSet<T>, etc.) - I/O subsystem (
System::IO::Stream,File,Directory, compression) - Threading primitives (
Thread,Mutex,CancellationToken,Timer) - Numerics (
Vector2,Vector3,Vector4,Matrix4x4,Quaternion) - Text processing (
StringBuilder,Encoding, JSON, XML)
Relationship to Other Projects
| Project | Relationship |
|---|---|
| CNA | C++ reimplementation of XNA 4.0. CNA is built on top of sharp-runtime. It depends on sharp-runtime for all System::* types, primitives, events, I/O, and threading. |
| mobile-eggbert | C++ port of a Windows Phone game. Uses sharp-runtime for intcs/bytecs types, StringBuilder, TimeSpan, EventArgs, Random, and property macros. |
| dotnet/runtime | Used as reference for API design only (MIT License). sharp-runtime's public API mirrors .NET class/method names. The C++ implementation is original work. |
Main Visible Features
- ~449 public header files covering the major System.* namespaces
- 3132 tests passing via GoogleTest
- Clean C++23 code with zero warnings on GCC/Clang
- Vendored dependencies: GoogleTest, nlohmann/json, tinyxml2, miniz
- SPDX license headers on every file (MIT + .NET Foundation attribution)
- Doxygen-compatible documentation comments with status notes
Supported Platforms
| Platform | Status | Notes |
|---|---|---|
| Linux | Done | Primary development and CI platform |
| macOS | Done | POSIX-compatible; same as Linux |
| Windows | Partial | Links ws2_32; POSIX-only subsystems need Win32 guards |
| Android | Partial | StoragePaths uses SDL3 when available; requires SDL3 from parent project |
| Emscripten | Stub | Compiles cleanly; some features throw PlatformNotSupportedException at runtime |
Important Dependencies
| Dependency | Location | Purpose |
|---|---|---|
| ZLIB | System (external) | Required; used by GZipStream/DeflateStream |
| GoogleTest | vendor/googletest/ | Test framework (git submodule) |
| nlohmann/json | vendor/nlohmann/json.hpp | System::Text::Json implementation |
| tinyxml2 | vendor/tinyxml2/ | System::Xml::XmlReader / XmlWriter |
| miniz | vendor/miniz/ | System::IO::Compression::ZipArchive |
Current Maturity / Status
As of the documentation date, sharp-runtime is in active development with approximately
91% header coverage and all planned subsystems implemented.
The project is described (in NEXT.md) as being in a phase where
"all planned subsystems implemented and tested (~96%+ header coverage)".
The status tracking system uses these values, written in Doxygen comments:
| Status | Meaning |
|---|---|
| Todo | Not implemented yet |
| Stub | Skeleton only — returns placeholder or throws |
| Partial | Partially implemented, may have known gaps |
| Implemented | Functionally complete |
| Verified | Validated against expected .NET behavior |
Design Philosophy
- Prefer clarity over completeness
- Avoid unnecessary complexity
- Keep APIs close to .NET where it makes sense
- Use modern C++ (RAII, strong typing, clear ownership)
- No LINQ — use
std::rangesin ported code instead - No GC — RAII and smart pointers replace garbage collection