dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.16k stars 4.71k forks source link

Change corelib to resx, strongly typed resources, and split resources for \shared #7643

Closed danmoseley closed 9 months ago

danmoseley commented 7 years ago

We need to

@alexperovich this is just to track what we already discussed.

ghost commented 3 years ago

Tagging subscribers to 'linkable-framework': @eerhardt See info in area-owners.md if you want to be subscribed.

Issue Details
We need to - [x] Change from .txt to .resx - [x] Change to use SR.cs generated from .resx instead of `GetResourceString("..")` - [ ] Split the resx into two pieces, one in `\shared\` that contains every string used in at least one place in any code in `\shared\`, and another outside of `\shared\` that contains all the other strings. - [ ] Do the same split in CoreRT - [ ] Enabling syncing for .resx files if it isn't already @alexperovich this is just to track what we already discussed.
Author: danmosemsft
Assignees: -
Labels: `area-Infrastructure-coreclr`, `linkable-framework`, `up-for-grabs`
Milestone: Future
MichalStrehovsky commented 3 years ago

Bumping this to .NET 6 since this means that Mono CoreLib builds carry junk CoreCLR resource strings. #2151 made Mono just use the same RESX file as CoreCLR instead of doing a proper split.

akoeplinger commented 9 months ago

@MichalStrehovsky I took a stab at this but realized that since we run the trimmer during the libraries build we end up stripping away the unused resources (edit only the properties, not the embedded resources). Do you still think it's worth doing the .resx file split?

MichalStrehovsky commented 9 months ago

It feels like it would be better if illinker learns how to remove unused strings automatically than doing this at build time. "Strings that are only used on CoreCLR" is no different from "strings that are only used in code paths that were trimmed". We use trimming in all scenarios that care about size.

akoeplinger commented 9 months ago

@MichalStrehovsky ideally yes but it doesn't look like that will be happening soon: https://github.com/dotnet/linker/issues/2840

I realized that when testing my change I used a wasm app and that one sets UseSystemResourceKeys=true so we remove the embedded resource and the trimmer trims away the unused C# properties completely hence why the size didn't change.

Just splitting up the .resx files makes the mono SPC ~30kB smaller on osx-arm64, or ~10kB for coreclr SPC.

Given that all the size-constrained platforms like wasm/ios/android set UseSystemResourceKeys=true I'm not sure if that is worth it?

MichalStrehovsky commented 9 months ago

Just splitting up the .resx files makes the mono SPC ~30kB smaller on osx-arm64, or ~10kB for coreclr SPC.

Yeah, use cases that care about the 30 kB should all be setting UseSystemResourceKeys=true. Agreed it doesn't look worth it. Thank you for measuring it!

akoeplinger commented 9 months ago

Ok thanks, closing this issue then.