CNA Integration
How CNA uses sharp-runtime as its foundation layer.
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
| Feature | Usage in CNA |
|---|---|
Primitive types (intcs, bytecs) | Used throughout for type-safe C# int/byte equivalents |
System::EventHandler<T>, EventArgs | XNA events (Activated, Deactivated, Exiting, etc.) |
System::Math, System::MathF | Game math operations |
System::Numerics::Vector2/3/4 | Positions, sizes, velocities in game logic |
System::Numerics::Matrix4x4 | Transform matrices for rendering |
System::Numerics::Quaternion | 3D rotations |
System::IO::Stream (and subclasses) | Content loading (XNB files) |
System::IO::Compression::DeflateStream | XNB content decompression (XNB-compatible) |
System::IO::IsolatedStorage | Save game data |
System::Collections::Generic::* | Throughout game data structures |
System::Threading | Background content loading, async operations |
System::IDisposable | Audio, graphics resource lifecycle |
System::TimeSpan | Game timing |
System::DateTimeOffset | Sensor API |
| Prop.hpp macros | XNA properties (Width, Height, IsFullScreen, etc.) |
Runtime Boundaries
The conceptual boundary between sharp-runtime and CNA:
- sharp-runtime provides:
System::*types, primitives, collections, I/O, threading, math, serialization - CNA provides: Game-specific types (SpriteBatch, Texture2D, GraphicsDevice, GamePad, Keyboard, Audio, etc.)
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:
intcs,bytecstype aliasesSystem::Text::StringBuilderSystem::TimeSpanSystem::EventArgsSystem::Random- Prop.hpp macros