Metal.NET 1.4.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Metal.NET --version 1.4.2
                    
NuGet\Install-Package Metal.NET -Version 1.4.2
                    
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="Metal.NET" Version="1.4.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Metal.NET" Version="1.4.2" />
                    
Directory.Packages.props
<PackageReference Include="Metal.NET" />
                    
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 Metal.NET --version 1.4.2
                    
#r "nuget: Metal.NET, 1.4.2"
                    
#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 Metal.NET@1.4.2
                    
#: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=Metal.NET&version=1.4.2
                    
Install as a Cake Addin
#tool nuget:?package=Metal.NET&version=1.4.2
                    
Install as a Cake Tool

Metal.NET

NuGet Version License: MIT

C# bindings for Apple's Metal graphics API, auto-generated from metal-cpp headers.

Installation

dotnet add package Metal.NET

Requirements: .NET 10+, macOS 15+

Quick Start

using Metal.NET;

MTLDevice device = MTLDevice.CreateSystemDefaultDevice();

using MTLCommandQueue queue = device.NewCommandQueue();

using MTLLibrary library = device.NewDefaultLibrary();

Memory Management

Every NativeObject wrapper has a NativeObjectOwnership that controls its lifetime:

Ownership Dispose() releases Finalizer releases Usage
Borrowed Property getters, objectAtIndex:
Owned Method return values, out NSError
Managed Objects created via parameterless constructor (AllocInit)
// Managed – finalizer will release if not disposed
var desc = new MTLTextureDescriptor();

// Owned – caller is responsible for disposal
using MTLLibrary library = device.NewDefaultLibrary();

// Borrowed – do not dispose
MTLDevice device = commandQueue.Device;

Project Structure

Metal.NET.slnx
├── Metal.NET/                          ← Runtime library
│   ├── Common/                         ← Hand-written interop core
│   │   ├── NativeObject.cs             ← Base class for all ObjC wrappers
│   │   ├── NativeBlock.cs              ← Base class for ObjC block wrappers
│   │   ├── ObjectiveC.cs               ← Auto-generated objc_msgSend overloads
│   │   └── ...
│   ├── Foundation/                     ← Hand-written NS* wrappers
│   ├── Metal/                          ← Auto-generated Metal API (231 files)
│   │   ├── MTLDelegates.cs             ← Auto-generated block handler classes
│   │   └── ...
│   ├── MetalFX/                        ← Auto-generated MetalFX API (18 files)
│   └── QuartzCore/                     ← Auto-generated QuartzCore API (2 files)
│
└── Metal.NET.Generator/                ← Code generator
    ├── CppParser.cs                    ← Parses metal-cpp headers
    ├── CSharpEmitter.cs                ← Emits C# source files
    ├── TypeMapper.cs                   ← C++ → C# type mapping
    └── metal-cpp/                      ← Upstream metal-cpp headers

Updating Bindings

  1. Replace Metal.NET.Generator/metal-cpp/ with the latest metal-cpp archive.

  2. Run the generator and verify:

    dotnet run --project Metal.NET.Generator
    dotnet build Metal.NET
    

Disclaimer

This library was built with AI assistance. It has undergone preliminary testing but has not been exhaustively validated in production scenarios. Please test thoroughly before production use.

Alternatives

License

MIT License · "Metal" is a trademark of Apple Inc. · See THIRD-PARTY-NOTICES.md.

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 (1)

Showing the top 1 NuGet packages that depend on Metal.NET:

Package Downloads
Zenith.NET.Metal

Zenith.NET is a modern, cross-platform graphics and compute library for .NET. It provides a unified GPU programming interface supporting DirectX12, Metal, and Vulkan backends.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.3.0 152 3/31/2026
2.2.1 101 3/29/2026
2.2.0 90 3/20/2026
2.1.0 92 3/18/2026
2.0.1 89 3/17/2026
2.0.0 95 3/17/2026
1.4.2 99 3/13/2026
1.4.1 94 3/13/2026
1.4.0 102 3/11/2026
1.3.1 99 3/5/2026
1.3.0 90 3/5/2026
1.2.0 94 3/3/2026
1.1.0 94 2/25/2026
1.0.9 88 2/25/2026
1.0.8 89 2/25/2026
1.0.7 92 2/25/2026
1.0.6 92 2/25/2026
1.0.5 93 2/24/2026
1.0.4 91 2/24/2026
1.0.3 89 2/21/2026
Loading failed