Repository navigation
Trim the documentation file with the assembly - #5
Merged
Merged
Conversation
Where a project writes an XML documentation file, the entries for the types and members the linker removed are taken out of it. A source-only package compiled into a library documents its own members into that file: Verify.xml for net48 is 817 KB, of which 256 KB is left, and Verify.NUnit.xml goes from 596 KB to 18 KB. A new linker step, RemovedDocumentation, runs after the output is written and lists the documentation names of everything in the input assembly that is not in the output, reading both files with System.Reflection.Metadata. The task removes the entries with those names and nothing else, so a name spelled differently from the compiler's leaves its entry in place and cannot remove the entry of a member that is still there. What stays is never parsed and written again: the task only leaves bytes out. Squash_TrimDocumentation set to false leaves the file alone. Squash012 warns when the file is not XML the task can follow; the assembly is trimmed all the same. Each build writes removed-documentation.txt and keeps the compiler's file in the in folder. The Documented fixture has a member of every shape a documentation name can take, each with a summary that says whether the trim is expected to keep it.
CI builds the solution, and a project referenced from outside it is built in its default configuration: the fixture came out as Debug, where the tests look for Release.
This was referenced Oct 8, 2026
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.
Where a project writes an XML documentation file, the entries for the types and members the linker removed are now taken out of it. On by default;
Squash_TrimDocumentationset tofalseleaves the file alone.A source-only package compiled into a library documents its own members into that file, so the file can end up larger than the assembly beside it. Run over copies of Verify's build output:
Verify.xmlnet48Verify.xmlnet10.0Verify.NUnit.xmlnet48Verify.NUnit.xmlnet10.0How
RemovedDocumentation, runs after the output is written. It lists the documentation names of everything in the assembly underin/that is not in the one underout/, reading both withSystem.Reflection.Metadata.For a user
Squash_TrimDocumentation, defaulttrue.Squash012, a warning when the file is not XML the task can follow. The assembly is trimmed all the same and the file is left as it was.removed-documentation.txtbesideremoved.txt, and keeps the compiler's file in theinfolder.Tests
Documentedfixture with a member of every shape a documentation name can take. Each summary saysKept.orRemoved., and the trimmed file is held to that on all three frameworks.binand in the packed nupkg is trimmed, a repeat build leaves it alone, and turning the setting off compiles again and leaves the compiler's file.Not covered
+OutputStep:, so it depends on the linker having a step of that name; the canary workflow will show whether it does.