Description

FNativeClassHeaderGenerator::ExportEnum produces this behavior.
If an enum has “MAX” somewhere in the array, it removes last element.

I tested my code to fix the issue.

// code placeholder
bool UEnum::ContainsExistingMax() const
 {
 #if 1 // testcode
     const int32 LastElementIndex = Names.Num()-1;
     if (GetIndexByName(*GenerateFullEnumName(TEXT("MAX")), EGetByNameFlags::CaseSensitive) == LastElementIndex )
     {
         return true;
     }
 
     FName MaxEnumItem = *GenerateFullEnumName(*(GenerateEnumPrefix() + TEXT("_MAX")));
     if (GetIndexByName(MaxEnumItem, EGetByNameFlags::CaseSensitive) == LastElementIndex )
     {
         return true;
     }
 #else
     if (GetIndexByName(*GenerateFullEnumName(TEXT("MAX")), EGetByNameFlags::CaseSensitive) != INDEX_NONE )
     {
         return true;
     }
 
     FName MaxEnumItem = *GenerateFullEnumName(*(GenerateEnumPrefix() + TEXT("_MAX")));
     if (GetIndexByName(MaxEnumItem, EGetByNameFlags::CaseSensitive) != != INDEX_NONE )
     {
         return true;
     }
 #endif
     return false;
 }
 

The "Get number of entries" returns 4 in above example.

Steps to Reproduce

for example define enum with following code

 UENUM(BlueprintType)
 enum class EMaxTest2 : uint8
 {
     A,
     B,
     MAX,
     C
  };

UHT removes last element "C".
"Get number of entries" node returns 3.

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-82048 in the post.

0
Login to Vote

Won't Fix
CreatedOct 18, 2019
ResolvedAug 27, 2021
UpdatedAug 27, 2021
View Jira Issue