LeXtudio.Metadata.Mutable — a small, reusable library for reading, mutating, and writing .NET assembly metadata and IL. This project consolidates mutable metadata/IL model code so tools like Obfuscar and other consumers can reuse a single, well-tested implementation.
- Purpose: Provide a mutable object model for metadata and method bodies plus
reader/writer implementations built on
System.Reflection.Metadata. - Primary project:
src/LeXtudio.Metadata.Mutable. - Supported TFMs:
net8.0(primary) andnet462(legacy compatibility).
- Mutable metadata and IL model (types, methods, fields, instructions).
MutableAssemblyReader/MutableAssemblyWriterfor PE/metadata read/write.- Designed for reuse across multiple tooling projects; lightweight compatibility
shims are provided in
Support. - Tests demonstrating round-trip behavior are included.
Add the NuGet package from nuget.org (preferred):
dotnet add <your-project>.csproj package LeXtudio.Metadata.Mutable
If you need to test locally before publishing, pack the library and add the local folder as a package source:
dotnet pack src/LeXtudio.Metadata.Mutable/LeXtudio.Metadata.Mutable.csproj -c Release
dotnet nuget add source "src\LeXtudio.Metadata.Mutable\bin\Release" -n local-pkgs
dotnet add <your-project>.csproj package LeXtudio.Metadata.Mutable --source local-pkgs
Build the library (example, net8.0):
dotnet build src/LeXtudio.Metadata.Mutable/LeXtudio.Metadata.Mutable.csproj -f net8.0
Run the tests:
dotnet test tests/LeXtudio.Metadata.Mutable.Tests/LeXtudio.Metadata.Mutable.Tests.csproj
- Reference the
LeXtudio.Metadata.Mutablepackage. Use the public API surface under theLeXtudio.Metadata.Mutablenamespace — for example the reader/writer classes (MutableAssemblyReader,MutableAssemblyWriter),MutableTypeSystem, andPersistedAssemblyBuilder. - Concrete usage examples are available in the test projects; see:
Design notes and rationale: docs/design.md
net8.0(primary)net462(legacy compatibility)
Note: Some tests exercise net9.0 features and are located under the
tests folder.
- Fork, implement changes in a feature branch, and open a pull request.
- Run the relevant tests locally (
dotnet test ...) and include tests for new behavior. - Keep changes focused and add documentation when you change public APIs.
This repository is licensed under the MIT License — see LICENSE.