CNA Integration
How CNA uses sharp-runtime as its foundation layer.
README.md, CLAUDE.md,
plan.sqlite3/prompt.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 component set must be selected before it is added. Since CNA uses a broad runtime surface, an explicit complete-runtime integration is appropriate:
# In CNA's CMakeLists.txt (approximate):
cna_configure_vendored_sdl() # before Storage can be configured on Android
set(SHARP_RUNTIME_COMPONENTS All)
set(SHARP_RUNTIME_BUILD_TESTS OFF CACHE BOOL "" FORCE)
add_subdirectory(vendor/sharp-runtime)
target_link_libraries(CNA PRIVATE SharpRuntime::All)
The legacy SHARP_RUNTIME target still forwards to the complete runtime in this configuration, but new integrations should use SharpRuntime::All or direct component targets. The SDL3 target must exist first only when the Android storage component is selected.
Focused Consumers
A smaller application should request only direct requirements, for example Numerics, IO.Compression, and Text. Transitive component dependencies are resolved automatically; applications do not need to duplicate them.
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