-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Enable trimming for data protection #41118
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
Conversation
DataProtection supports newing up types based on config strings e.g. https://github.com/dotnet/aspnetcore/blob/main/src/DataProtection/DataProtection/src/RegistryPolicyResolver.cs#L57-L60. This results in RequiresUnreferencedCode spreading virally in these APIs. Additionally, there are two call sites where the DataProtection APIs are invoked from interface implementations. The trimmer requires that interfaces are annotated the same way implementations are. In this case we are unable to modify the interface (they are |
/cc @JamesNK |
Why bot is adding community contributions to your PRs? |
Thanks @pranavkm. |
@HaoK can you please review this? Thanks! |
@JamesNK are you handling all of the trimming PRs? |
I will help. But I don't know the code and the common scenarios its used. To start with, thoughts on #41118 (comment)? Right now most of the API surface is generating trimmer warnings. |
|
||
internal static class TrimmerWarning | ||
{ | ||
public const string Message = "Data Protection may attempt to load types in a way that cannot be statically analyzed. Ensure all required types are preserved."; |
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.
I think we need to improve this error message. "Ensure all required types are preserved." is what they need to do, but it doesn't give any indication about how they do it.
The simplest way to provide more info is to link to a doc. I took a look at https://docs.microsoft.com/en-us/dotnet/core/deploying/trimming/trim-self-contained and there isn't any content about what to do here.
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.
We could add trimming specific guidance to the DataProtection docs. In theory, the average user wouldn't run in to trimming specific issues with this library - it's only when they start configuring providers via xml configs or the registry that it runs the risk of being trimmed away.
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.
I agree.
This doesn't need to block this PR. Trimming docs issue: #41229
No description provided.