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

Resolve ILLink warnings for System.Resources.ResourceManager #47778

Merged
13 commits merged into from
Feb 8, 2021

Conversation

joperezr
Copy link
Member

@joperezr joperezr commented Feb 2, 2021

cc: @eerhardt @marek-safar @vitek-karas @ericstj

fixes #45272
fixes #32862

Resolving remaining ILLinker warnings on System.Resources.ResourceManager.

This will introduce a feature switch System.Resources.AllowReflectionForNonPrimitiveObjects that can be set via AppContext which will control whether or not you can use ResourceManager to read/write non primitive types. By default, we are thinking of setting this switch to false when publishing a trimmed app, as it won't be safe as the trimmer won't be able to tell which types are present on the resources stream and need to be preserved. For published apps that manually specify this switch to true They should get a warning saying that some code paths might require unreferenced code, so that they make sure to keep the types they expect to use and then disable the warning if appropriate. The sdk PR setting this switch as default will come after this PR gets merged.

@ghost
Copy link

ghost commented Feb 2, 2021

Tagging subscribers to this area: @tarekgh, @buyaa-n, @krwq
See info in area-owners.md if you want to be subscribed.

Issue Details

cc: @eerhardt @marek-safar @vitek-karas @ericstj

fixes #45272
fixes #32862

Resolving remaining ILLinker warnings on System.Resources.ResourceManager.

This will introduce a feature switch System.Resources.AllowReflectionForNonPrimitiveObjects that can be set via AppContext which will control whether or not you can use ResourceManager to read/write non primitive types. By default, we are thinking of setting this switch to false when publishing a trimmed app, as it won't be safe as the trimmer won't be able to tell which types are present on the resources stream and need to be preserved. For published apps that manually specify this switch to true They should get a warning saying that some code paths might require unreferenced code, so that they make sure to keep the types they expect to use and then disable the warning if appropriate. The sdk PR setting this switch as default will come after this PR gets merged.

Author: joperezr
Assignees: -
Labels:

area-System.Resources

Milestone: -
#Resolved

@joperezr joperezr requested a review from ericstj February 2, 2021 20:52
@eerhardt eerhardt added the linkable-framework Issues associated with delivering a linker friendly framework label Feb 2, 2021
@ghost
Copy link

ghost commented Feb 2, 2021

Tagging subscribers to 'linkable-framework': @eerhardt, @vitek-karas, @LakshanF, @tannergooding, @sbomer
See info in area-owners.md if you want to be subscribed.

Issue Details

cc: @eerhardt @marek-safar @vitek-karas @ericstj

fixes #45272
fixes #32862

Resolving remaining ILLinker warnings on System.Resources.ResourceManager.

This will introduce a feature switch System.Resources.AllowReflectionForNonPrimitiveObjects that can be set via AppContext which will control whether or not you can use ResourceManager to read/write non primitive types. By default, we are thinking of setting this switch to false when publishing a trimmed app, as it won't be safe as the trimmer won't be able to tell which types are present on the resources stream and need to be preserved. For published apps that manually specify this switch to true They should get a warning saying that some code paths might require unreferenced code, so that they make sure to keep the types they expect to use and then disable the warning if appropriate. The sdk PR setting this switch as default will come after this PR gets merged.

Author: joperezr
Assignees: -
Labels:

area-System.Resources, linkable-framework

Milestone: -
#Resolved

Copy link
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

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

Thanks for tackling this @joperezr!

@eerhardt
Copy link
Member

eerhardt commented Feb 4, 2021

CustomType.resources is a binary file. Is it possible to use a .resx file instead? Maybe with a bitmap in it or something. That way we aren't committing binary files. #Resolved

@eerhardt
Copy link
Member

eerhardt commented Feb 4, 2021

        if (!_permitDeserialization)

We should be checking AllowCustomResourceTypes here as well. That way we can trim all the code below. #Resolved


Refers to: src/libraries/System.Private.CoreLib/src/System/Resources/ResourceReader.Core.cs:50 in 55fd1fc. [](commit_id = 55fd1fc, deletion_comment = False)

@dotnet dotnet deleted a comment Feb 5, 2021
@dotnet dotnet deleted a comment Feb 5, 2021
Copy link
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

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

Looks great to me. Thanks for the great work here, @joperezr.

I just had one minor nit about the ordering to allow a tiny more bit of code to be trimmed. But I believe this is ready to be merged.

@ghost
Copy link

ghost commented Feb 5, 2021

Hello @joperezr!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit 744f1ff into dotnet:master Feb 8, 2021
@joperezr joperezr deleted the ResourceManagerTrimSafe branch February 8, 2021 20:46
@marek-safar
Copy link
Contributor

@joperezr how is the "The sdk PR setting this switch as default will come after this PR gets merged." coming along?

@joperezr
Copy link
Member Author

It’s merged: dotnet/sdk#15702

sorry that I didn’t link it here before.

@ghost ghost locked as resolved and limited conversation to collaborators Mar 21, 2021
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Resources linkable-framework Issues associated with delivering a linker friendly framework
Projects
No open projects
8 participants