Repository navigation
[tools] Fix IL2009 warning for generic types in linker XML descriptors - #25415
Conversation
When a method has generic parameter types (like 'T' in Callback), the linker XML descriptor can't resolve the generic parameter name in the method signature. Use the method 'name' attribute instead of 'signature' for such methods, which matches by name and avoids the IL2009 warning. Fixes this warning, which shows up in MAUI's tests (and our own too, just not in a place where we were validating warnings): > warning IL2009: Could not find method 'System.Void Activated(T)' on type 'UIKit.UIGestureRecognizer.Callback`1' Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the dotnet-linker’s generated XML root descriptor output to avoid IL2009 warnings when preserving methods whose signatures contain generic parameter names (for NativeAOT/ILC scenarios where such signatures can’t be resolved).
Changes:
- Track
MethodDefinitionalongside the “conditional” flag for preserved methods so XML emission can choose betweensignaturevsname. - Emit
instead ofwhen the method’s signature contains generic parameters, avoiding IL2009.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Add a test that builds monotouch-test with NativeAOT and verifies no IL2009 warnings are emitted. Also assert IL2026 warnings are still present so we're notified if they go away. Fix HasGenericParameterInSignature to use ContainsGenericParameter instead of checking for direct GenericParameter types, which handles nested generic parameters (e.g. Action, T[], ref T, Nullable ). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The NativeAOT monotouch-test build doesn't produce IL2026 warnings, so remove that assertion. The IL2009 check is sufficient to verify the fix. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Assert the exact set of warnings for the NativeAOT monotouch-test build using the existing AssertWarnings/ExpectedBuildMessage pattern. This ensures we're notified if any warnings are fixed or new ones appear. All platforms currently produce the same set of warnings. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
✅ [PR Build #cf3c7ab] Build passed (Detect API changes) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #cf3c7ab] Build passed (Build packages) ✅Pipeline on Agent |
✅ 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 |
✅ [PR Build #cf3c7ab] Build passed (Build macOS tests) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build #cf3c7ab] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 175 tests passed 🎉 Tests counts✅ cecil: All 1 tests passed. ( macOS tests✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
…nker XML descriptors (#25477) When a method has generic parameter types (like 'T' in Callback), the linker XML descriptor can't resolve the generic parameter name in the method signature. Use the method 'name' attribute instead of 'signature' for such methods, which matches by name and avoids the IL2009 warning. Fixes this warning, which shows up in MAUI's tests (and our own too, just not in a place where we were validating warnings): > warning IL2009: Could not find method 'System.Void Activated(T)' on type 'UIKit.UIGestureRecognizer.Callback`1' --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Backport of #25415. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When a method has generic parameter types (like 'T' in Callback),
the linker XML descriptor can't resolve the generic parameter name in
the method signature. Use the method 'name' attribute instead of
'signature' for such methods, which matches by name and avoids the
IL2009 warning.
Fixes this warning, which shows up in MAUI's tests (and our own too, just not
in a place where we were validating warnings):