Skip to content
This repository was archived by the owner on Sep 25, 2026. It is now read-only.

Simplify unknown binding flags handling and fix param names - #2426

Merged
vitek-karas merged 2 commits into
dotnet:feature/damAnalyzerfrom
vitek-karas:UnknownBindingFlagsSimple
Dec 9, 2021
Merged

vitek-karas merged 2 commits into
dotnet:feature/damAnalyzerfrom
vitek-karas:UnknownBindingFlagsSimple

Conversation

@vitek-karas

Copy link
Copy Markdown
Member

The helpers to translate binding flags to annotation already handle unsupported/unknown binding flags, so there's no need for the intrinsics to handle that yet again. Just simplifies the code.

Also fixed places where we lookup method parameters. If the lookup is done on a MethodReference the parameters typically don't have names. So instead do it on the MethodDefinition where they do have names and thus produce much better diagnostic messages.

The helpers to tanslate binding flags to annotation already handle unsupported/unknown binding flags, so there's no need for the intrinsics to handle that yet again. Just simplifies the code.

Also fixed places where we lookup method parameters. If the lookup is done on a MethodReference the parameters typically don't have names. So instead do it on the MethodDefinition where they do have names and thus produce much better diagnostic messages.
@vitek-karas vitek-karas self-assigned this Dec 7, 2021
Comment on lines +1089 to +1093
// Otherwise fall back to the bitfield requirements
var requiredMemberTypes = GetDynamicallyAccessedMemberTypesFromBindingFlagsForConstructors (bindingFlags);
// We can scope down the public constructors requirement if we know the number of parameters is 0
if (requiredMemberTypes == DynamicallyAccessedMemberTypes.PublicConstructors && ctorParameterCount == 0)
requiredMemberTypes = DynamicallyAccessedMemberTypes.PublicParameterlessConstructor;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We calculate always the requiredMemberTypes but, for most operations, we end up not using it and we just use the binding flags. I don't see the advantage of having it up here.

@tlakollo tlakollo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@vitek-karas
vitek-karas merged commit 5919fd8 into dotnet:feature/damAnalyzer Dec 9, 2021
@vitek-karas
vitek-karas deleted the UnknownBindingFlagsSimple branch December 9, 2021 16:34
agocke pushed a commit to dotnet/runtime that referenced this pull request Nov 16, 2022
…inker#2426)

The helpers to tanslate binding flags to annotation already handle unsupported/unknown binding flags, so there's no need for the intrinsics to handle that yet again. Just simplifies the code.

Also fixed places where we lookup method parameters. If the lookup is done on a MethodReference the parameters typically don't have names. So instead do it on the MethodDefinition where they do have names and thus produce much better diagnostic messages.

Commit migrated from dotnet/linker@5919fd8
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants