You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 25, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 25, 2026. It is now read-only.
RUC analyzer does not warn about delegate conversion #1912
Dupe of #1764? "We should probably extend this to delegates pointing to such methods (although that one has a natural extension - we could require the delegate invoke method itself to be annotated same as the target)."
Yeah, they're maybe dups -- this bug was specific to the analyzer, but if the linker is missing similar analysis it makes sense to do both together.
My suggestion is simpler as well-- warn at the point of delegate conversion, instead of Invoke, so we don't have to do alias tracking for delegate instances. From what I've seen it's often not a worse experience anyway because users often want to see the origination of the problem instead of the final invocation.
My suggestion is simpler as well-- warn at the point of delegate conversion, instead of Invoke
Yup, this is also what I want linker to do. The comment about invoke method is just that we could potentially allow delegate conversion if the delegate itself has matching annotations. So for example:
Could be used to construct a delegate pointing to an annotated method. The annotations at the delegate use site naturally fall out.
Unfortunately, it doesn't look like C# allows placing attributes on the Invoke method itself, so the natural extension for RequiresUnreferencedCode doesn't look possible. But it could work at least for the flow annotations if we have the need.
While reviewing the tests and adding some more for RAF I realized that both Linker and Analyzer already have support for this so I will close this PR and add lazy tests in #2113
Activity
MichalStrehovsky commentedon Mar 23, 2021
Dupe of #1764? "We should probably extend this to delegates pointing to such methods (although that one has a natural extension - we could require the delegate invoke method itself to be annotated same as the target)."
agocke commentedon Mar 23, 2021
Yeah, they're maybe dups -- this bug was specific to the analyzer, but if the linker is missing similar analysis it makes sense to do both together.
My suggestion is simpler as well-- warn at the point of delegate conversion, instead of Invoke, so we don't have to do alias tracking for delegate instances. From what I've seen it's often not a worse experience anyway because users often want to see the origination of the problem instead of the final invocation.
MichalStrehovsky commentedon Mar 23, 2021
Yup, this is also what I want linker to do. The comment about invoke method is just that we could potentially allow delegate conversion if the delegate itself has matching annotations. So for example:
Could be used to construct a delegate pointing to an annotated method. The annotations at the delegate use site naturally fall out.
Unfortunately, it doesn't look like C# allows placing attributes on the Invoke method itself, so the natural extension for RequiresUnreferencedCode doesn't look possible. But it could work at least for the flow annotations if we have the need.
tlakollo commentedon Jul 1, 2021
While reviewing the tests and adding some more for RAF I realized that both Linker and Analyzer already have support for this so I will close this PR and add lazy tests in #2113