Skip to content
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

[release/6.0.2xx] Propagate Interfaces annotation through Type.BaseType #2476

Merged
merged 2 commits into from
Jan 7, 2022

Conversation

vitek-karas
Copy link
Member

The Interfaces annotation makes sure the type has all interfaces, meaning GetInterfaces reflection call will work on it. That means that all interfaces of the base type are also preserved, so the Interfaces annotation should be propagated to the base type as well.

Fixes #2473.

The Interfaces annotation makes sure the type has all interfaces, meaning `GetInterfaces` reflection call will work on it. That means that all interfaces of the base type are also preserved, so the `Interfaces` annotation should be propagated to the base type as well.
@@ -1294,6 +1294,9 @@ public override bool HandleCall (MethodBody callingMethodBody, MethodReference c

if (dynamicallyAccessedMemberNode.DynamicallyAccessedMemberTypes.HasFlag (DynamicallyAccessedMemberTypes.PublicProperties))
propagatedMemberTypes |= DynamicallyAccessedMemberTypes.PublicProperties;

if (dynamicallyAccessedMemberNode.DynamicallyAccessedMemberTypes.HasFlag (DynamicallyAccessedMemberTypes.Interfaces))
propagatedMemberTypes |= DynamicallyAccessedMemberTypes.Interfaces;
Copy link
Member

Choose a reason for hiding this comment

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

Consider creating a mask here and &'ing, instead of checking each flag individually.

Copy link
Member

Choose a reason for hiding this comment

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

Also, whether inclusion of exclusion is preferred, i.e. if we forget to update this, would we prefer to propagate more or less?

@agocke agocke merged commit 5b33e3a into dotnet:release/6.0.2xx Jan 7, 2022
@vitek-karas vitek-karas deleted the BaseTypeInterfaces branch January 7, 2022 10:51
agocke pushed a commit to dotnet/runtime that referenced this pull request Nov 16, 2022
…pe (dotnet/linker#2476)

The Interfaces annotation makes sure the type has all interfaces, meaning `GetInterfaces` reflection call will work on it. That means that all interfaces of the base type are also preserved, so the `Interfaces` annotation should be propagated to the base type as well.

Commit migrated from dotnet/linker@5b33e3a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants