-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Use Strings resx file for the exception messages within System.Text.Encodings.Web #30510
Comments
And maybe most importantly, (c) for size we could choose to have the linker (e.g. when linking a whole app) strip out all of the resx contents; that's harder to do when the string is directly embedded in the code because it's harder to determine with 100% fidelity that the string isn't being used for something functional. |
Anyone notice any more resx debt? My assumption had been that there isn't any. |
Ok, so a little debt for if we decide to support localization (let's not discuss that in this issue as it's already discussed elsewhere and there is no plan at this point..) |
In this case the exception provides the message. Ideally would use nameof though. |
Can I go ahead with other projects, or it should be separate issue? |
Feel free to fix other instances (you don't have to wait to file a separate issue). However, I would fix that in a separate PR. |
See dotnet/corefx#39900 (comment)
We currently inline the exception message strings when throwing in System.Text.Encodings.Web.
We should be adding these to a Strings.resx file and use
SR.X
to access them.Even though we're not currently localizing exception strings on .NET Core, being in the Strings.resx file does mean that a) there aren't two different copies that get out of sync if the message gets tweaked and b) we could localize if desired.
Look at other projects for examples. E.g:
https://github.com/dotnet/corefx/blob/c6f5ceedea28edf01ae7d3e13c02935669dad434/src/System.Text.Json/src/Resources/Strings.resx#L138-L140
https://github.com/dotnet/corefx/blob/47c35fe385c18d5f0a4ceacea381f790db472ba2/src/System.Text.Json/src/System/Text/Json/ThrowHelper.cs#L443-L446
https://github.com/dotnet/corefx/blob/82408cd90f4d4573d502e8df2ca437b35e6a37f7/src/System.Text.Json/src/System/Text/Json/Reader/JsonReaderHelper.Unescaping.cs#L209
The use of the "ThrowHelper" pattern isn't necessary here (applied on case-by-case basis where performance concerns were higher than code readability).
Another example:
https://github.com/dotnet/corefx/blob/82408cd90f4d4573d502e8df2ca437b35e6a37f7/src/System.Private.Xml/src/Resources/Strings.resx#L134-L136
https://github.com/dotnet/corefx/blob/e5d38a54cf21f6427ae4fe99c3841c8067139e75/src/System.Private.Xml/src/System/Xml/Xslt/XslCompiledTransform.cs#L475-L485
cc @GrabYourPitchforks
The text was updated successfully, but these errors were encountered: