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

Add feature switch to disable custom .resources reader support (UserResourceSet) #45272

Closed
marek-safar opened this issue Nov 27, 2020 · 2 comments · Fixed by #47778
Closed

Add feature switch to disable custom .resources reader support (UserResourceSet) #45272

marek-safar opened this issue Nov 27, 2020 · 2 comments · Fixed by #47778
Assignees
Labels
area-System.Resources enhancement Product code improvement that does NOT require public API changes/additions linkable-framework Issues associated with delivering a linker friendly framework size-reduction Issues impacting final app size primary for size sensitive workloads
Milestone

Comments

@marek-safar
Copy link
Contributor

Support for external custom resource-set types seems to be very advanced and possibly never used feature in practice. It makes trimming very complicated and brings large unnecessary dependencies as well as opens doors for potential security problems. The idea would be to add a new feature switch to block setting mediator.UserResourceSet and validate that .resources files require only System.Resources.RuntimeResourceSet and System.Resources.ResourceReader which I suspect all netcore apps use anyway.

Effectively replacing CreateResourceSet with

internal static RuntimeResourceSet CreateResourceSet(Stream store)
{
	// TODO: +Do checking for resource header versions
	return new RuntimeResourceSet(store, permitDeserialization: true);
}

This would have two effects

  1. Removing all resources related warnings from illinker because of linker unsafe behaviour
  2. Large size savings in refactored code due to fewer dependencies

The feature switch would also help with size trimming work a lot because it would allow propagating the information that we are dealing with RuntimeResourceSet only everywhere. In practice removing, for example, all code in ResourceReader which handles non-_ums code paths (including Unicode encoding dependency, etc).

@eerhardt @vitek-karas

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-System.Resources untriaged New issue has not been triaged by the area owner labels Nov 27, 2020
@ghost
Copy link

ghost commented Nov 27, 2020

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

Issue Details

Support for external custom resource-set types seems to be very advanced and possibly never used feature in practice. It makes trimming very complicated and brings large unnecessary dependencies as well as opens doors for potential security problems. The idea would be to add a new feature switch to block setting mediator.UserResourceSet and validate that .resources files require only System.Resources.RuntimeResourceSet and System.Resources.ResourceReader which I suspect all netcore apps use anyway.

Effectively replacing CreateResourceSet with

internal static RuntimeResourceSet CreateResourceSet(Stream store)
{
	// TODO: +Do checking for resource header versions
	return new RuntimeResourceSet(store, permitDeserialization: true);
}

This would have two effects

  1. Removing all resources related warnings from illinker because of linker unsafe behaviour
  2. Large size savings in refactored code due to fewer dependencies

The feature switch would also help with size trimming work a lot because it would allow propagating the information that we are dealing with RuntimeResourceSet only everywhere. In practice removing, for example, all code in ResourceReader which handles non-_ums code paths (including Unicode encoding dependency, etc).

@eerhardt @vitek-karas

Author: marek-safar
Assignees: -
Labels:

area-System.Resources, untriaged

Milestone: -

@marek-safar marek-safar added the linkable-framework Issues associated with delivering a linker friendly framework label Nov 27, 2020
@tarekgh tarekgh added enhancement Product code improvement that does NOT require public API changes/additions and removed untriaged New issue has not been triaged by the area owner labels Nov 28, 2020
@tarekgh tarekgh added this to the 6.0.0 milestone Nov 28, 2020
@eerhardt
Copy link
Member

My thinking along these lines was that we would have one big feature switch for System.Resources to disable all the linker-unsafe code in ResourceManager identified in #32862 (sans the BinaryFormatter code, since we already have that).

Basically something like System.Resources.AllowCustomResourceTypes which could be set to false to remove all the code and throw if it encounters a custom type in the stream.


Support for external custom resource-set types seems to be very advanced and possibly never used feature in practice.

I see that dotnet/winforms has a custom ResourceSet type - https://github.com/dotnet/winforms/blob/master/src/System.Windows.Forms/src/System/Resources/ResXResourceSet.cs. Would this affect that at all?

cc @ericstj

@marek-safar marek-safar added size-reduction Issues impacting final app size primary for size sensitive workloads linkable-framework Issues associated with delivering a linker friendly framework and removed linkable-framework Issues associated with delivering a linker friendly framework labels Dec 9, 2020
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Feb 2, 2021
@ghost ghost closed this as completed in #47778 Feb 8, 2021
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Feb 8, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Mar 10, 2021
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Resources enhancement Product code improvement that does NOT require public API changes/additions linkable-framework Issues associated with delivering a linker friendly framework size-reduction Issues impacting final app size primary for size sensitive workloads
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

5 participants