-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Warn on method access in Requires analyzers #110086
base: main
Are you sure you want to change the base?
Conversation
The issue with calling Methods with requires is the the method itself, not the parameters. Warning on the entire invocation including the parameters can be confusing. Instead, we should warn just on the method access for Requires. DynamicallyAccessedMembers should still warn on the invocation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix LGTM but looks like there are some failures.
Not for this PR, but I'm wondering if it would be better for the DAM analyzer to warn on the specific parameter with a DAM mismatch, instead of the entire invocation.
It looks like this is causing new warnings because of interceptors. The methods in source cause warnings, but are intercepted to other methods that don't have warnings, and Roslyn must silence the existing warning. Changing the location to not include the entire call site must mess with the silencing. |
The previous failures were due to the Microsoft.Extensions.Configuration diagnostic suppressors. I've updated those to check MemberAccessExpressions in addition to the InvocationExpression as potential sources of IL2026. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM otherwise. Thanks!
The issue with calling Methods with requires is the the method itself, not the parameters. Warning on the entire invocation including the parameters can be confusing. Instead, we should warn just on the method access for Requires. DynamicallyAccessedMembers should still warn on the invocation.
Fixes #109823.