{"id":13496794,"url":"https://github.com/tristanlabelle/swift-dotnetmetadata","last_synced_at":"2025-08-24T06:15:05.082Z","repository":{"id":174502202,"uuid":"637601832","full_name":"tristanlabelle/swift-dotnetmetadata","owner":"tristanlabelle","description":"A Swift library for reading .NET metadata files, including WinMD files.","archived":false,"fork":false,"pushed_at":"2024-03-24T12:06:40.000Z","size":569,"stargazers_count":13,"open_issues_count":7,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-25T12:43:35.320Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tristanlabelle.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"License.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-08T02:39:04.000Z","updated_at":"2024-06-30T08:09:23.066Z","dependencies_parsed_at":"2023-12-22T12:49:42.664Z","dependency_job_id":"c68a9765-8189-4b47-9cbf-09727554842f","html_url":"https://github.com/tristanlabelle/swift-dotnetmetadata","commit_stats":null,"previous_names":["tristanlabelle/swift-dotnetmd"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tristanlabelle%2Fswift-dotnetmetadata","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tristanlabelle%2Fswift-dotnetmetadata/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tristanlabelle%2Fswift-dotnetmetadata/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tristanlabelle%2Fswift-dotnetmetadata/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tristanlabelle","download_url":"https://codeload.github.com/tristanlabelle/swift-dotnetmetadata/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233773723,"owners_count":18728071,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T19:01:59.963Z","updated_at":"2025-01-13T18:01:51.500Z","avatar_url":"https://github.com/tristanlabelle.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"# DotNetMetadata\n\nA Swift library for reading and inspecting .NET metadata, including WinMD files, following the [ECMA-335, Common Language Infrastructure (CLI)](https://www.ecma-international.org/publications-and-standards/standards/ecma-335/) standard. Parsing IL is currently out of scope, but not off the table in the future.\n\n![Build and Test workflow](https://github.com/tristanlabelle/swift-dotnetmetadata/actions/workflows/build-and-test.yml/badge.svg?branch=main)\n\n## Example\n\n```swift\nimport DotNetMetadata\n\nlet context = AssemblyLoadContext()\nlet assembly = try context.load(path: #\"C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\mscorlib.dll\"#)\nlet typeDefinition = assembly.resolveTypeDefinition(fullName: \"System.IDisposable\")!\nprint(\"interface \\(typeDefinition.name) {\")\nfor method in typeDefinition.methods {\n    print(\"  void \\(method.name)()\")\n}\nprint(\"}\")\n```\n\n`Package.swift`:\n\n```swift\n// swift-tools-version: 5.8\nimport PackageDescription\n\nlet package = Package(\n    name: \"MyPackage\",\n    dependencies: [\n        .package(url: \"https://github.com/tristanlabelle/swift-dotnetmetadata\", branch: \"main\")\n    ],\n    targets: [\n        .executableTarget(name: \"MyTarget\", dependencies: [\n            .product(name: \"DotNetMetadata\", package: \"swift-dotnetmetadata\")\n        ])\n    ]\n)\n```\n\n## Building\nPrerequisites:\n\n- Windows 10 or above (building on other platforms should be possible but is untested)\n- A Swift toolchain, version 5.8 or above\n  - `winget install --id Swift.Toolchain`\n- Visual Studio (any edition) with the Desktop C++ Workload\n  - `winget install --id Microsoft.VisualStudio.2022.Community --override \"--quiet --add Microsoft.VisualStudio.Workload.NativeDesktop\"`\n- A Windows SDK\n  - Comes with Visual Studio, or use `winget install --id Microsoft.WindowsSDK.10.0.22000`\n- CMake and ninja\n  - Comes with Visual Studio, or use `winget install --id Kitware.CMake` and `winget install --id Ninja-build.Ninja`\n\n### In Visual Studio Code\nOpen Visual Studio Code from a `x64 Native Tools Command Prompt for VS 2022` and use standard IDE commands for building (\u003ckbd\u003ectrl\u003c/kbd\u003e+\u003ckbd\u003eshift\u003c/kbd\u003e+\u003ckbd\u003eB\u003c/kbd\u003e).\n\n### From the command line\nThis project builds with both the Swift Package Manager (SPM) and CMake. SPM supports running tests, but requires a helper script because it cannot integrate all build steps.\n\n1. Open a `x64 Native Tools Command Prompt for VS 2022`\n2. Refer to the [Build and Test workflow](.github/workflows/build-and-test.yml) for build commands\n\n## Architecture\n\nThe library consists in two layered modules:\n\n- `DotNetMetadata` (logical layer): Provides an object model for .NET concepts of assemblies, types and members, including resolution of cross-assembly references, similar to the `System.Reflection` APIs.\n- `DotNetMetadataFormat` (physical layer): Implements low-level decoding of the .NET portable executable file format and provides a strongly-typed view of the metadata tables, heaps and signatures.\n\nThe logical layer can represent a mock `mscorlib` assembly and its core types to support inspecting `.winmd` files, which reference an unresolvable `mscorlib, Version=255.255.255.255`.\n\n### Error Handling\n\nThe code currently makes liberal use of `!` and `fatalError`, making it unsuitable for some production scenarios. The plan is to progressively transition to throwing errors as needed, and the expectation is that most of the logical layer API will be marked `throws`, to fail at a fine granularity in the presence of a few pieces of malformed data.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftristanlabelle%2Fswift-dotnetmetadata","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftristanlabelle%2Fswift-dotnetmetadata","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftristanlabelle%2Fswift-dotnetmetadata/lists"}