-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Fix SR.Format argument count mismatches in resource strings #123855
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
| </data> | ||
| <data name="Argument_AddingDuplicate" xml:space="preserve"> | ||
| <value>An item with the same key has already been added.</value> | ||
| <value>An item with the same key has already been added. Key: {0}</value> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This message is used both without SR.Format and with SR.Format.
Rename the instance used with SR.Format to Argument_AddingDuplicateWithKey to align with CoreLib?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added Argument_AddingDuplicateWithKey resource and updated the code to use it in 6b72117.
| </data> | ||
| <data name="Arg_RegKeyNotFound" xml:space="preserve"> | ||
| <value>The specified registry key does not exist.</value> | ||
| <value>The specified registry key does not exist. Error: {0}.</value> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error code is not useful in this message. It is always going to be ERROR_FILE_NOT_FOUND
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted the change in 6b72117.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Please delete the unnecessary SR.Format for Arg_RegKeyNotFound message instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the unnecessary SR.Format wrapper in 35ec760.
| <data name="Serialization_InvalidReference" xml:space="preserve"> | ||
| <value>Invalid member reference.</value> | ||
| </data> | ||
| <data name="Serialization_InvalidTypeName" xml:space="preserve"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used with both with and without SR.Format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted the change in 6b72117.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Delete unnecessary SR.Format with this resource string.
Also, this resource string in rc\libraries\System.Resources.Extensions\src\Resources\Strings.resx looks unused. Can it be deleted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the unnecessary SR.Format from TypeNameHelpers.cs and deleted the unused Serialization_InvalidTypeName resource from System.Resources.Extensions in 699331d.
|
@copilot address all feedback. Also do a full build and run all tests, there are test failures. And double check every changed string to ensure that all uses of it agree on the number of parameters, reverting the change to that string of there's any discrepancy. |
…, add Argument_AddingDuplicateWithKey Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
…ution resources Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Addressed all feedback in e4f0a30:
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
@copilot Delete the unnecessary SR.Format for these error messages |
…lete unused resource Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
…ceholders Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
Removed the unnecessary SR.Format wrappers for ServerNotAReplica, net_quic_timeout_use_gt_zero, Argument_CustomCultureCannotBePassedByNumber, XmlInternalError (4 usages), and ZeroDepthAtEnd in 611f4f2. |
Description
Analyzed all
SR.Formatcalls and compared the number of arguments passed against the placeholder indices in corresponding resource strings. Fixed resource strings across multiple files where they disagreed, after verifying that all usages of each string are consistent.Resource String Fixes
Updated format strings to include placeholders for arguments that were being passed but not used (only for strings where all usages consistently use SR.Format):
Argument_AddingDuplicateWithKeyresource (aligning with CoreLib pattern) and updatedLowLevelDictionary.csto use itKeyedServiceAnyKeyUsedToResolveService- added{0}and{1}for service typesInvalidMetadataValue- added type nameConfig_client_config_too_many_configsections_elements- added tag nameArgumentOutOfRange_ConsoleWindowSize_Size- added max valueDataColumns_Add4,DataColumn_ExpressionAndConstraint,ADP_UpdateRequiresSourceTableNameOleDb_PropertyBadOption,OleDb_PropertyBadColumn,OleDb_PropertyNotAvailableLogAlreadyExistsAsSource- added machine nameUnableToImpersonateCredentials- added error codeCentralDirectoryInvalid- added exceptionAbstractElementNotSupported,InvalidReturnTypeOnGetSchemaMethodSch_InvalidDateTimeOption,XmlIllegalAttributeFlagsArray,XmlInvalidArrayLength,XmlInvalidNullCast- fixed placeholder indicesCspParameter_invalid- added parameter nameCode Fixes
Removed unnecessary
SR.Formatwrappers and redundant arguments where the resource string doesn't use placeholders:XmlArrayItemAmbiguousTypescall inXmlReflectionImporter.cs(duplicated first argument)Arg_RegKeyNotFoundinRegistrySecurity.cs- removed SR.Format (error code is alwaysERROR_FILE_NOT_FOUND)Serialization_InvalidTypeNameinTypeNameHelpers.cs- removed SR.FormatServerNotAReplicainADAMInstance.cs- removed SR.Formatnet_quic_timeout_use_gt_zeroinThrowHelper.cs(System.Net.Quic) - removed SR.Format and unusedpropertyNameparameterArgument_CustomCultureCannotBePassedByNumberinRegionInfo.cs- removed SR.FormatXmlInternalErrorinReflectionXmlSerializationReader.csandReflectionXmlSerializationWriter.cs- removed SR.Format (4 usages)ZeroDepthAtEndinThrowHelper.cs(System.Text.Json) - removed SR.FormatCleanup
Serialization_InvalidTypeNameresource fromSystem.Resources.Extensions/src/Resources/Strings.resxNot Changed
The following resources have conflicting call sites with different argument counts, so they were not modified:
ConvertToException,XmlGetSchemaMethodReturnType,CannotLoadMemberTypeOriginal prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.