Introducing DotNetMD, a .NET/WinMD metadata reader in Swift

DotNetMD: A Swift library for reading and inspecting .NET metadata, including WinMD files, following the ECMA-335, Common Language Infrastructure (CLI) standard.

I work at The Browser Company supporting Swift on Windows for the Arc web browser. We have an internal code generator for Swift bindings to WinRT APIs on Windows based off the cppwinrt project in C++, which makes it a bit difficult to work with. For the last two months, I've been working on reimplementing it in Swift in my free time, starting with this library to read WinMD files.

The library has two layers:

  • A higher layer that exposes .NET concepts, classes, members, etc., similar to System.Reflection.
  • A lower layer that reads metadata tables, similar to swift-winmd but using memory-mapping and loading things lazily.

At this point, it can enumerate most .NET entities and has tests against .NET 4.5's mscorlib.dll as well as Windows.winmd. I'm just starting on the WinRT projection in a separate SwiftWinRT project, and that will guide implementing future features in DotNetMD.

This is also my first larger personal project written in Swift!


Interesting. Do you have any comparison against Something other than completeness as I know that I've not had time to complete the full details of this, but it did get far enough along to be able to do some interesting work.

The metadata tables layer of DotNetMD is very similar in functionality to Swift/WinMD, with a different implementation approach and a couple more bits like parsing signature blobs. DotNetMD also adds a reflection-like layer on top that makes it easier to consume, for example with APIs like method.params[0].type, which require quite a lot of code at the metadata layer (parsing signature blobs, resolving type references, etc).