Skip to content

Conversation

@jtschuster
Copy link
Member

Annotate all interfaces as fully preserved when an assembly in in library mode. This will keep all interfaces and all interface methods in library mode regardless of visibility or use.

Fixes #2881

Copy link
Member

@vitek-karas vitek-karas left a comment

Choose a reason for hiding this comment

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

Looks good - but @sbomer should take a look since he knows this better 😉

@MichalStrehovsky
Copy link
Member

Fixes #2881

To fix that issue, it would be sufficient to limit this to instance virtual methods (or even instance abstract, since COM doesn't work with default interface methods). But "all interface methods" will work too.

Annotations.SetPreserve (type, TypePreserve.All);
}
break;
default:
Copy link
Member

Choose a reason for hiding this comment

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

Writing down what we discussed:
I think for public interfaces we will hit the default case, and SetMembersPreserve (type, preserve) won't preserve all interface members. We should either consistently use TypePreserve.All for the interface members, or use the TypePreserveMembers to preserve only the specified interface members.

Copy link
Member

@sbomer sbomer left a comment

Choose a reason for hiding this comment

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

Thank you!

@jtschuster
Copy link
Member Author

For reference, this change adds 17280 bytes to the shared framework after trimming on Linux-x64-Release

81065987 on main
81083267 with the change

@jtschuster jtschuster merged commit e2b3a92 into dotnet:main Jul 12, 2022
agocke pushed a commit to dotnet/runtime that referenced this pull request Nov 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avoid trimming COM interfaces in library mode

4 participants