This document describes the PX1052 diagnostic.
Code | Short Description | Type | Code Fix |
---|---|---|---|
PX1052 | Plain text strings cannot be used in the methods of the LocalizeFormat family. |
Error | Unavailable |
The methods of the LocalizeFormat
family of the PX.Data.PXLocalizer
and PX.Data.PXMessages
classes must have a formatted string argument. Plain text strings cannot be used as the arguments of these methods.
To fix the issue, you do one of the following:
- Change the plain text string to a formatted string.
- Replace the method of the
LocalizeFormat
family with a method that does not have a formatted string argument.
[PXLocalizable]
public static class Messages
{
public const string StringToFormat= "The username cannot contain commas.";
}
PX.Data.PXLocalizer.LocalizeFormat(Messages.StringToFormat, parameter); // The first PX1052 error is displayed for this line.
PX.Data.PXMessages.LocalizeFormat(Messages.StringToFormat, parameter); // The second PX1052 error is displayed for this line.
PX.Data.PXMessages.LocalizeFormat(Messages.StringToFormat, out prefix, parameter); // The third PX1052 error is displayed for this line.
PX.Data.PXMessages.LocalizeFormatNoPrefix(Messages.StringToFormat, parameter); // The fourth PX1052 error is displayed for this line.
PX.Data.PXMessages.LocalizeFormatNoPrefixNLA(Messages.StringToFormat, parameter); // The fifth PX1052 error is displayed for this line.
[PXLocalizable]
public static class Messages
{
public const string StringToFormat= "The {0} username cannot contain commas.";
}
PX.Data.PXLocalizer.LocalizeFormat(Messages.StringToFormat, parameter);
PX.Data.PXMessages.LocalizeFormat(Messages.StringToFormat, parameter);
PX.Data.PXMessages.LocalizeFormat(Messages.StringToFormat, out prefix, parameter);
PX.Data.PXMessages.LocalizeFormatNoPrefix(Messages.StringToFormat, parameter);
PX.Data.PXMessages.LocalizeFormatNoPrefixNLA(Messages.StringToFormat, parameter);