Project Overview

What sharp-runtime is, its purpose, goals, and current status.

What is sharp-runtime?

sharp-runtime is a C++23 component 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.

⚠ Not a full .NET runtime
sharp-runtime does not implement the CLR, JIT compilation, garbage collection, reflection metadata, or full .NET standard compatibility. It is a pragmatic subset designed for practical use in native C++ game projects.

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:

Component-Based Integration

The public API remains familiar, while the build is now divided into 40 independently selectable physical components. A project can request a narrow surface such as Text.Json or Net.WebSockets; CMake enables its public dependency closure automatically.

set(SHARP_RUNTIME_COMPONENTS Text.Json)
set(SHARP_RUNTIME_BUILD_TESTS OFF CACHE BOOL "" FORCE)
add_subdirectory(sharp-runtime)
target_link_libraries(MyApp PRIVATE SharpRuntime::Text.Json)

SharpRuntime::All remains available for projects that need the complete runtime. Existing broad integration through SHARP_RUNTIME is retained when the complete runtime is selected.

Relationship to Other Projects

ProjectRelationship
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

Supported Platforms

PlatformStatusNotes
LinuxDonePrimary development and CI platform
macOSDonePOSIX-compatible; same as Linux
WindowsPartialLinks ws2_32; POSIX-only subsystems need Win32 guards
AndroidPartialStoragePaths uses SDL3 when available; requires SDL3 from parent project
EmscriptenStubCompiles cleanly; some features throw PlatformNotSupportedException at runtime

Important Dependencies

DependencyLocationPurpose
ZLIBSystem (external)Used privately by IO.Compression only when selected
GoogleTestvendor/googletest/Test framework (git submodule)
nlohmann/jsonvendor/nlohmann/json.hppSystem::Text::Json implementation
tinyxml2vendor/tinyxml2/Owned by Xml; exposed because XML headers use its types
minizvendor/miniz/Owned privately by IO.Compression.Zip

Current Maturity / Status

sharp-runtime is in active development with 983 public headers organized into 40 physical modules. The build keeps module boundaries explicit while preserving existing public namespaces and broad compatibility targets. Porting continues type-by-type driven by CNA and mobile-eggbert dependency analysis.

The status tracking system uses these values, written in Doxygen comments:

StatusMeaning
TodoNot implemented yet
StubSkeleton only — returns placeholder or throws
PartialPartially implemented, may have known gaps
ImplementedFunctionally complete
VerifiedValidated against expected .NET behavior

Design Philosophy