[linker] Remove Foundation member attributes#26257
Conversation
Remove Foundation.RequiredMemberAttribute and Foundation.OptionalMemberAttribute instances through the platform assembly's embedded ILLink descriptor. Add linked-output metadata coverage that keeps the BCL RequiredMemberAttribute as an exact-name control. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 64f1816e-0169-4a01-9ab2-f482fb13fc87
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
🔥 [CI Build #a349132] Test results 🔥Test results❌ Tests failed on VSTS: test results 1 tests crashed, 1 tests failed, 198 tests passed. Failures❌ windows tests1 tests failed, 2 tests passed.Failed tests
Html Report (VSDrops) Download ❌ xcframework tests🔥 Failed catastrophically on VSTS: test results - xcframework (no summary found). Html Report (VSDrops) Download Successes✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
There was a problem hiding this comment.
Pull request overview
Removes Foundation.RequiredMemberAttribute and Foundation.OptionalMemberAttribute custom-attribute instances during trimming by extending the platform assembly’s embedded ILLink descriptor, and adds a linked-output unit test to ensure those Foundation attributes are stripped while the compiler’s System.Runtime.CompilerServices.RequiredMemberAttribute remains.
Changes:
- Updated the embedded linker descriptor to remove instances of the two Foundation “member” attributes.
- Added a small iOS test app that applies
[Foundation.RequiredMember]/[Foundation.OptionalMember]and also uses a C#requiredproperty. - Added a
PublishTrimmedTestthat builds the app with full linking and uses Cecil to verify expected attribute removal/preservation in the linked outputs.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/dotnet/UnitTests/PublishTrimmedTest.cs | Adds a new trim/link validation test that inspects linked assemblies for removed/preserved attribute instances. |
| tests/dotnet/LinkerAttributesTestApp/LinkerAttributesTestApp.csproj | Introduces a minimal iOS test project used by the new trimming test. |
| tests/dotnet/LinkerAttributesTestApp/AppDelegate.cs | Adds code that emits both Foundation member attributes and the compiler-required-member attribute for verification post-link. |
| src/ILLink.LinkAttributes.xml.in | Extends the embedded ILLink descriptor to remove instances of Foundation.OptionalMemberAttribute and Foundation.RequiredMemberAttribute. |
Remove
Foundation.RequiredMemberAttributeandFoundation.OptionalMemberAttributeinstances unconditionally using the platform assembly's embedded ILLink descriptor.Add linked-output metadata coverage that verifies both Foundation attributes are removed while
System.Runtime.CompilerServices.RequiredMemberAttributeremains unaffected.🤖 Pull request created by Copilot