-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RUC analyzer does not warn about delegate conversion #1912
Comments
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. |
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: delegate ConstructorInfo GimmeConstructor([DynamicallyAccessedMembers(Constructors)] Type theType); 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 |
E.g.
The text was updated successfully, but these errors were encountered: