Skip to content

Use internal metadata interfaces in CoreCLR - #134875

Merged
davidwrighton merged 4 commits into
dotnet:mainfrom
davidwrighton:metadata-internal-interfaces-wasm
Oct 1, 2026
Merged

davidwrighton merged 4 commits into
dotnet:mainfrom
davidwrighton:metadata-internal-interfaces-wasm

Conversation

@davidwrighton

@davidwrighton davidwrighton commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Summary

  • migrate Reflection.Emit metadata operations from the legacy public import and emit interfaces to IMDInternalImport and IMDInternalEmit
  • retain internal metadata interfaces directly in dynamic PEAssembly instances and keep public VM bridges only in profiler-enabled builds
  • omit the legacy public import, emit, tables, and metadata-info interfaces from runtime RegMeta builds without profiler support while retaining them for profiler, DAC, DBI, and portable-PDB targets
  • omit metadata persistence, dynamic metadata snapshots, pre-save processing, and stream serialization from WebAssembly runtime metadata while preserving writable Reflection.Emit metadata
  • reduce MDTOKENMAP to the sparse source-token movement map needed by desktop persistence and remove unused metadata lookup helpers
  • return E_NOTIMPL from the CoreCLR copies of internal APIs used only by ILAsm or ILDasm while retaining their implementations in the portable-PDB tool flavor
  • compile the no-op symbol-reader importer only when FEATURE_ISYM_READER is enabled

WebAssembly size

Measured with ./build.sh -os browser -c Release -subset clr+libs against a clean worktree at bae5a8d2f1913c45bd474fdbecb17d572e235a4c.

Artifact Baseline Current Change
dotnet.native.wasm 4,714,654 bytes 4,612,862 bytes -101,792 bytes (-2.16%)
dotnet.native.wasm (gzip -9) 1,784,275 bytes 1,749,185 bytes -35,090 bytes (-1.97%)
corerun.wasm 4,542,104 bytes 4,440,392 bytes -101,712 bytes (-2.24%)
corerun.wasm (gzip -9) 1,742,265 bytes 1,706,092 bytes -36,173 bytes (-2.08%)

The final Emscripten symbol map contains no public IMetaDataTables, IMetaDataTables2, or IMetaDataInfo implementation; metadata persistence implementation; removed MDTOKENMAP modes or lookup helpers; or full CoreCLR implementation of the two tool-only APIs. Required interface slots remain as nine-byte E_NOTIMPL stubs.

Testing

  • ./build.sh clr+libs+host — passed with 0 warnings and 0 errors
  • ./build.sh -os browser -c Release -subset clr+libs — passed with 0 warnings and 0 errors
  • ./dotnet.sh build src/libraries/System.Reflection.Emit/tests/System.Reflection.Emit.Tests.csproj -t:Test -p:TargetArchitecture=x64 -p:Configuration=Debug — 2,640 passed, 0 failed, 0 skipped

Note

This pull request description was generated with GitHub Copilot.

Avoid legacy public metadata import and emit interfaces when profiler support is disabled, and migrate Reflection.Emit to the internal metadata surface.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 5 pipeline(s).
11 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke
See info in area-owners.md if you want to be subscribed.

Comment thread src/coreclr/vm/peassembly.h Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread src/coreclr/md/compiler/emit.cpp
Comment thread src/coreclr/md/compiler/helper.cpp Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@davidwrighton
davidwrighton marked this pull request as ready for review September 30, 2026 22:16
Comment thread src/coreclr/md/heaps/blobheap.h
Comment thread src/coreclr/md/inc/stgpool.h
Comment thread src/coreclr/md/inc/stgpool.h
Comment thread src/coreclr/md/inc/stgpool.h
Comment thread src/coreclr/inc/metadata.h
Comment thread src/coreclr/md/enc/mdinternalrw.cpp
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@davidwrighton

Copy link
Copy Markdown
Member Author

/ba-g failing tests are known, and fixed while this PR was open, so the failures are expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants