Opt out of UseSystemResourceKeys for ComponentModel.DataAnnotations#42274
Opt out of UseSystemResourceKeys for ComponentModel.DataAnnotations#42274eerhardt merged 1 commit intodotnet:masterfrom
Conversation
|
Tagging subscribers to this area: @ajcvickers |
src/libraries/System.ComponentModel.Annotations/src/System.ComponentModel.Annotations.csproj
Outdated
Show resolved
Hide resolved
jeffhandley
left a comment
There was a problem hiding this comment.
I don't know the options for the approaches, but I like the concept.
|
Don't block on me for this; happy to go with what those in the know deem best. |
Since many resource strings in ComponentModel.DataAnnotations contain messages that will be shown to end-users, we generate the "default value" string into the SR code. When a trimmed app strips the system resources, these strings will be used instead of the resource keys. Fix dotnet#42257
|
Talking it over with @ericstj and @tarekgh, we thought of the following options to fix this issue:
I've decided to take option (3) above and have updated this PR for it. The increase in size of the System.ComponentModel.Annotations assembly in the Windows x64 shared framework goes from 152 KB to 163 KB on my machine, which isn't significant. If we really think we need to save those 11 KB, we can look at enabling this only for the |
|
@ajcvickers @marek-safar - any thoughts/opinions here? I am going to propose we backport this change into 5.0. |
|
@ajcvickers I really don't have enough context on how this all works to have any useful thoughts. |
|
@eerhardt I don't know what exactly GenerateResxSourceIncludeDefaultValues does but it sounds like a sensible compromise. I don't think we should target only |
It causes our internal static partial class SR
{
internal static string @EmailAddressAttribute_Invalid => GetResourceString(
"EmailAddressAttribute_Invalid");to now be: internal static partial class SR
{
internal static string @EmailAddressAttribute_Invalid => GetResourceString(
"EmailAddressAttribute_Invalid",
@"The {0} field is not a valid e-mail address.");Which means the resource string is now hard-coded in the C# file. This string gets passed in as the "defaultString" in this method: runtime/src/libraries/Common/src/System/SR.cs Lines 27 to 32 in 9c47254 Which means that when
👍 , agreed. Thanks for the input. |
|
/backport to release/5.0-rc2 |
|
Started backporting to release/5.0-rc2: https://github.com/dotnet/runtime/actions/runs/267713992 |
Since many resource strings in ComponentModel.DataAnnotations contain messages that will be shown to end-users, we shouldn't be trimming these resources.
Fix #42257
/cc @pranavkm