Skip to content

Latest commit

 

History

History
55 lines (42 loc) · 2.73 KB

PX1052.md

File metadata and controls

55 lines (42 loc) · 2.73 KB

PX1052

This document describes the PX1052 diagnostic.

Summary

Code Short Description Type Code Fix
PX1052 Plain text strings cannot be used in the methods of the LocalizeFormat family. Error Unavailable

Diagnostic Description

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.

Example of Incorrect Code

[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.

Example of Possible Code Fix

[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);

Related Articles