CNA Integration

How CNA uses sharp-runtime as its foundation layer.

ℹ Source of this documentation
This page is based on information visible from sharp-runtime's README.md, CLAUDE.md, DOTNET_PORTING_PLAN.md, and NEXT.md. The CNA source code is not part of this repository. Some details about the exact CNA build integration may need verification from the CNA repository.

What is CNA?

CNA is a C++ reimplementation of the XNA 4.0 game framework. XNA was Microsoft's game development framework (2006–2013), written in C# and targeting Xbox 360, Windows, and Windows Phone.

CNA ports the XNA API to C++, targeting modern platforms (Linux, Windows, macOS, Android, Web). It uses sharp-runtime as its foundational system library — providing the System::* types that the original XNA/C# code depends on.

Dependency Relationship

CNA (C++ XNA 4.0 port)
  └── depends on sharp-runtime
        └── uses System::* types
              ├── SharpRuntime::intcs, bytecs, etc.
              ├── System::EventArgs, EventHandler<T>
              ├── System::Math, MathF
              ├── System::Numerics::Vector2/3/4
              ├── System::Numerics::Matrix4x4, Quaternion
              ├── System::IO::Stream, FileStream
              ├── System::IO::Compression (GZip, Deflate for XNB)
              ├── System::IO::IsolatedStorage
              ├── System::Collections::Generic::List/Dictionary
              ├── System::Text::StringBuilder
              ├── System::Threading::Thread, CancellationToken
              ├── System::TimeSpan, DateTime, DateTimeOffset
              └── ... (nearly all System::* types)

CMake Integration

CNA adds sharp-runtime as a CMake subdirectory. The correct order is:

# In CNA's CMakeLists.txt (approximate):
cna_configure_vendored_sdl()  # must be done BEFORE sharp-runtime is added
add_subdirectory(vendor/sharp-runtime)
target_link_libraries(CNA PRIVATE SHARP_RUNTIME)

The SDL3 target must exist before sharp-runtime is added because Android builds of StoragePaths.cpp require SDL3 headers.

Key sharp-runtime Features Used by CNA

FeatureUsage in CNA
Primitive types (intcs, bytecs)Used throughout for type-safe C# int/byte equivalents
System::EventHandler<T>, EventArgsXNA events (Activated, Deactivated, Exiting, etc.)
System::Math, System::MathFGame math operations
System::Numerics::Vector2/3/4Positions, sizes, velocities in game logic
System::Numerics::Matrix4x4Transform matrices for rendering
System::Numerics::Quaternion3D rotations
System::IO::Stream (and subclasses)Content loading (XNB files)
System::IO::Compression::DeflateStreamXNB content decompression (XNB-compatible)
System::IO::IsolatedStorageSave game data
System::Collections::Generic::*Throughout game data structures
System::ThreadingBackground content loading, async operations
System::IDisposableAudio, graphics resource lifecycle
System::TimeSpanGame timing
System::DateTimeOffsetSensor API
Prop.hpp macrosXNA properties (Width, Height, IsFullScreen, etc.)

Runtime Boundaries

The conceptual boundary between sharp-runtime and CNA:

If a new feature belongs in the System.* namespace and mirrors .NET, it should go in sharp-runtime. If it is XNA-specific (Microsoft.Xna.*), it belongs in CNA.

mobile-eggbert Integration

mobile-eggbert is a C++ port of a Windows Phone SpeedyBlupi game. It uses a subset of sharp-runtime:

Needs verification
The exact CMake configuration, SDL3 integration point, and full list of sharp-runtime types used by CNA should be verified from the CNA repository. The information above is derived from sharp-runtime's own documentation files.