Repository navigation
Add NativeAOT support to Microsoft.FileFormats - #6103
Open
max-charlamb wants to merge 3 commits into
Open
max-charlamb wants to merge 3 commits into
max-charlamb wants to merge 3 commits into
Conversation
Register built-in and custom binary layouts with statically preserved types. Retain annotated legacy discovery, add typed arrays and pointers, and document compatibility changes and native verification. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d3a2bca0-4757-4577-b682-c03acab64110
Compare registered custom models with legacy reflection layouts across endian, pointer-size, conditional-field, mixed-dependency and array cases. Reuse expected-value checks in the NativeAOT harness. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d3a2bca0-4757-4577-b682-c03acab64110
Restore legacy generic array-type semantics and expose typed allocation through GetArrayLayoutForElement<T>. Add compatibility regressions, advance FileFormats to the 1.1 series, and replace the general instructions with a breaking-change migration notice. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d3a2bca0-4757-4577-b682-c03acab64110
max-charlamb
marked this pull request as ready for review
October 9, 2026 14:27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add NativeAOT support to Microsoft.FileFormats while retaining the existing binary models, layout calculations, and legacy reflection-discovery APIs.
Breaking change: custom TStruct discovery on built-in readers
The only intentional parsing-behavior break is narrowly scoped: readers created by the built-in format parsers, and managers configured with the built-in format helpers, no longer automatically discover arbitrary user-defined
TStructmodels. Built-in structures remain registered and normal format parsing is unchanged.For example, callers reading their own structure through
PEFile.RelativeVirtualAddressReaderor a reader returned byPDBFile.GetStream()must now register it before reading:Without a registration or discovery provider, that custom read throws
LayoutException. Untrimmed managed callers can opt back into legacy discovery withreader.LayoutManager.AddTStructTypes()(andAddPointerTypes()when needed), supplying any required conditional-field defines.The default
Reader(IAddressSpace, bool)constructor still supports automatic reflection discovery. It is not affected by this change. A public GitHub search found no confirmed consumer relying on custom-model discovery through the affected built-in readers; private and unindexed usage cannot be ruled out.The existing generic
GetArrayLayout<T>(count)retains its original array-type semantics, includingGetArrayLayout<byte[]>(count). The newGetArrayLayoutForElement<T>(count)is additive.Existing .NET Framework and .NET Standard package targets remain available.
See the breaking-change notice for details. Separately, legacy APIs now carry AOT/trimming annotations; consumers enabling those analyzers may receive new diagnostics, but ordinary managed discovery remains available.
Local validation
Native execution was validated on Windows x64. Other host platforms and real big-endian Mach-O parsing are not claimed.