Until now, an XNA 4.0 game written in C# had three places to run: the original XNA 4.0 on Windows, FNA, and MonoGame.
Now it has a fourth: CNA.NET.
CNA.NET is the C# binding for CNA. It lets an XNA 4.0 C# game run on CNA without changing the game's source code.
This article explains what CNA.NET is, how it works, and what already runs on it.
What CNA.NET is
CNA is a C++ reimplementation of the XNA 4.0 programming model. CNA.NET (repository cna-dotnet) puts a C# API on top of it.
The important part is what CNA.NET is not.
It is not a C# game engine. It contains no renderer, no audio mixer, no content loader and no input system of its own.
It is a thin C# layer over the CNA C API. Every call a game makes goes through that C API into the C++ CNA core, where the real work is done.
C# XNA 4.0 game the game's own sources, unchanged
↓
CNA.XnaCompat the Microsoft.Xna.Framework API, as C#
↓
CNA.Framework CNA's own C# API, owns the native resources
↓
CNA.Interop P/Invoke declarations, internal
↓
CNA C API the stable C boundary of CNA
↓
CNA C++ core renderers, audio, input, content, networking
The game is still a C# program. It runs on .NET 8 or newer. It references Microsoft.Xna.Framework, Microsoft.Xna.Framework.Graphics, Microsoft.Xna.Framework.Input and the other XNA namespaces exactly as it did in 2010.
But the GraphicsDevice it draws with, the SpriteBatch, the ContentManager, the SoundEffect and the GamePad are the ones implemented in C++ in CNA.
CNA.NET is one of the language bindings built on the CNA C API. It is the most complete one.
Source compatibility, measured
The goal of CNA.NET is source compatibility with XNA 4.0.
That is not a slogan. It is measured.
A verifier compares CNA.NET's public API with the real XNA 4.0 reference assemblies, type by type and signature by signature. The current result for the selected XNA 4.0 Windows runtime profile:
- 256 of 256 public types
- 0 differences
- 0 CNA types leaking into XNA signatures
- an empty allowlist
The GamerServices, Avatar and Net profile adds another 75 of 75 types with 0 differences.
The managed layer is verified against the native side as well: 1,419 native imports, all resolving, with the layout of 1,137 native and managed values checked and 0 mismatches. CNA.NET accepts exactly one reviewed CNA C API generation at a time; today it is 0.46.0.
The official Microsoft samples
The first proof is the XNA Game Studio 4.0 sample collection from Microsoft, in the