Skip to content
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

Create diagnostic which will check that PXLocalizable static classes contain only string constants #433

Open
SENya1990 opened this issue Apr 18, 2022 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers static analysis Items related to static code analysis

Comments

@SENya1990
Copy link
Contributor

SENya1990 commented Apr 18, 2022

Internal number: ATR-590

Create diagnostic which will check that PXLocalizable static classes contain only string constants. The presence of constants of other type leads to an error during translations initialization in the static constructor of PXMessages class in platform which assumes that such class can contain only string constants. This results in all localized messages in assembly being not loaded by platform including other classes with PXLocalizable attribute.

Also is duplicated by another issue ATR-190:

As it has been reported in AC-117375: whenever a class that is decorated with PXLocalizableAttribute contains a non-string constant, the Collect Strings operation would fail with a System.InvalidCastException: 'Unable to cast object of type 'XXX' to type 'System.String'.'

To let developers know about such issues way in advance, a new diagnostic should be added in Acuminator to prevent declaration of non-string constants in a class that is decorated with PXLocalizableAttribute:

using PX.Common;

namespace ClientsFirst
{
    public static class CFConstants
    {
        ...

        #region ReleasableAircraft ZIP Fields
        [PXLocalizable()]
        public class EngineFields
        {
            public const int CODE       = 0;
            public const int MFR        = 1;
            public const int MODEL      = 2;
            public const int TYPE       = 3;
            public const int HORSEPOWER = 4;
            public const int THRUST     = 5;
        }

        [PXLocalizable()]
        public class MfrModelFields //a.k.a ACFTREFs
        {
            public const int CODE           = 0;
            public const int MFR            = 1;
            public const int MODEL          = 2;
            public const int TYPE_ACFT      = 3;
            public const int TYPE_ENG       = 4;
            public const int AC_CAT         = 5;
            public const int BUILD_CERT_IND = 6;
            public const int NO_ENG         = 7;
            public const int NO_SEATS       = 8;
            public const int AC_WEIGHT      = 9;
            public const int SPEED          = 10;
        }

        [PXLocalizable()]
        public class AircraftFields //a.k.a MASTER
        {
            public const int N_NUMBER         = 0;
            public const int SERIAL_NUMBER    = 1;
            public const int MFR_MDL_CODE     = 2;
            public const int ENG_MFR_MDL      = 3;
            public const int YEAR_MFR         = 4;
            public const int TYPE_REGISTRANT  = 5;
            public const int NAME             = 6;
            public const int STREET           = 7;
            public const int STREET2          = 8;
            public const int CITY             = 9;
            public const int STATE            = 10;
            public const int ZIP_CODE         = 11;
            public const int REGION           = 12;
            public const int COUNTY           = 13;
            public const int COUNTRY          = 14;
            public const int LAST_ACTION_DATE = 15;
            public const int CERT_ISSUE_DATE  = 16;
            public const int CERTIFICATION    = 17;
            public const int TYPE_AIRCRAFT    = 18;
            public const int TYPE_ENGINE      = 19;
            public const int STATUS_CODE      = 20;
            public const int MODE_S_CODE      = 21;
            public const int FRACT_OWNER      = 22;
            public const int AIR_WORTH_DATE   = 23;
            public const int OTHER_NAMES1     = 24;
            public const int OTHER_NAMES2     = 25;
            public const int OTHER_NAMES3     = 26;
            public const int OTHER_NAMES4     = 27;
            public const int OTHER_NAMES5     = 28;
            public const int EXPIRATION_DATE  = 29;
            public const int UNIQUE_ID        = 30;
            public const int KIT_MFR          = 31;
            public const int KIT_MODEL        = 32;
            public const int MODE_S_CODE_HEX  = 33;
        }
        #endregion
    }
}
@SENya1990 SENya1990 added enhancement New feature or request good first issue Good for newcomers static analysis Items related to static code analysis labels Apr 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers static analysis Items related to static code analysis
Projects
None yet
Development

No branches or pull requests

1 participant