DirectNAot 1.7.1

dotnet add package DirectNAot --version 1.7.1
                    
NuGet\Install-Package DirectNAot -Version 1.7.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DirectNAot" Version="1.7.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DirectNAot" Version="1.7.1" />
                    
Directory.Packages.props
<PackageReference Include="DirectNAot" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DirectNAot --version 1.7.1
                    
#r "nuget: DirectNAot, 1.7.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DirectNAot@1.7.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DirectNAot&version=1.7.1
                    
Install as a Cake Addin
#tool nuget:?package=DirectNAot&version=1.7.1
                    
Install as a Cake Tool

DirectN AOT

This is an AOT-friendly version of DirectN, with no reference to it. It's only for .NET 10 and beyond, it won't work with older versions nor with .NET Framework. It's aimed at 64-bit targets (x64 and ARM64). x86 works too, except for about fifty structures that the Win32 metadata lays out differently on x86, and that are generated for 64-bit only.

Don't forget to check the DirectN.Extensions nuget, a set of utilities that are not mandatory, but super useful for programming with DirectN (and COM and interop in general).

Generated, not written

Almost none of the source files here are written by hand. The interop code is generated from the official Win32 metadata, so it's a mechanical projection of the native API, not somebody's interpretation of it. That is the main reason it can be maintained for a very long time:

  • over 9,000 source files are generated, against about a hundred hand-written ones. Every interface, structure, enum, constant and function is in the first group.
  • by size, about 90% is generated. The rest is mostly not really code but pure definitions, constants mainly, so there is almost nothing to maintain there.
  • a new Windows SDK, or a fix in the metadata, means running the generator again, not rewriting code. What the metadata gets wrong is patched in the generator itself, in DirectN.InteropBuilder.Cli (Patches.json, etc.), so the result stays generated. The flip side is that a change in the metadata can introduce source breaking changes for the code that uses DirectN.
  • the generated code has no author's coding style to keep consistent, so it doesn't drift, and nobody has to remember how it was written.
  • the hand-written part is small and kept apart, it only adds what is missing from the metadata, a few types and some helper members on generated structures.

The key points that drive how code is generated and built:

  • the goal for DirectN is to create built-in interop code for modern media and graphics Windows technologies only, cross-platform is not a target. That's DirectX 9 to 12, Direct2D, DXGI, Media Foundation, WIC, Direct Composition, Direct Write, WASAPI, XPS, and their dependencies.
  • modern code exclusively based on source-generated LibraryImport and source-generated ComWrappers.
  • how it works and how it's made is completely driven by the ComWrappers source generator and by AOT requirements, trimming and disabled runtime marshalling.
  • DirectN is AOT-friendly.
  • unsafe usage is as limited as possible.
  • raw pointers (like ISomething*) are not publicly exposed, only interface types (like ISomething), or nint depending on the situation. object as the out parameter type for untyped (native void**) COM interfaces was considered, but nint is more universal, including for authoring scenarios (implementing COM interfaces in .NET).
  • all ComObject instances are created using ComWrappers' "unique instance" marshalling, CreateObjectFlags.UniqueInstance and UniqueComInterfaceMarshaller<>, as we want to control when objects are released.
  • doing interop is inherently unsafe, but we want to keep a .NET-like programming whenever possible. The generated code serves a similar purpose to the CsWin32 project, but the final generated code and the net result (how we use it as a caller) are quite different.

See the main README for the samples and for the DirectN.Extensions conventions.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages (9)

Showing the top 5 NuGet packages that depend on DirectNAot:

Package Downloads
DirectNAot.Extensions

Extensions code for DirectNAOT package: Com utilities, Extension methods, Windows utilities, DXC utilities, etc.

WebView2Aot

AOT-Compatible Windows WebView2 interop Code for .NET Core without any dependency on Winforms, WPF, WinUI, or other UI frameworks.

ShellN

AOT compatible, low level .NET bindings for the Windows Shell (COM interfaces, PIDLs, related Win32 APIs), built on DirectN. The friendly, object oriented API is in ShellN.Extensions.

ShellN.Extensions

A friendly, AOT compatible thin managed layer over some of the Windows Shell namespace APIs, on top of ShellN. Browse and operate the shell as objects with ShellItem, ShellFolder and KnownFolder, invoke the real context menu, read property stores, and watch for shell changes.

AOTrino

Electron-like desktop apps on .NET AOT + WebView2, single-exe, Windows x86/x64/ARM64, front-end-framework-agnostic (React/Fluent layers optional).

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on DirectNAot:

Repository Stars
aelyo-softworks/AOTrino
Electron-like desktop apps on .NET AOT + WebView2, single-exe, Windows (x64/x86/ARM64), front-end-framework-agnostic (React/Fluent UI layers optional).
Version Downloads Last Updated
1.7.1 123 10/20/2026
1.7.0 2,649 9/23/2026
1.6.9 200 9/21/2026
1.6.8 143 9/20/2026
1.6.7 176 9/14/2026
1.6.6 887 8/27/2026
1.6.5 514 7/20/2026
1.6.4 316 7/2/2026
1.6.3 233 6/9/2026
1.6.1 137,393 4/26/2026
1.5.2 423 2/20/2026
1.5.1 237 1/4/2026
1.4.1 1,761 11/11/2025
1.4.0 630 9/17/2025
1.3.2 880 7/28/2025
1.3.1 868 5/15/2025
Loading failed