@@ -972,7 +972,7 @@ public GameBuild(BuildName name)
972972 Contract . Assert ( buildFieldInfo != null ) ;
973973
974974 // Pick the last attribute.
975- var buildAttributes = buildFieldInfo . GetCustomAttributes < BuildAttribute > ( false ) . Last ( ) ;
975+ var buildAttributes = buildFieldInfo . GetCustomAttributes < BuildAttribute > ( false ) . LastOrDefault ( ) ;
976976 if ( buildAttributes != null )
977977 {
978978 Generation = buildAttributes . Generation ;
@@ -1048,6 +1048,9 @@ public GameBuild(UnrealPackage package)
10481048 Name = package . Summary . LicenseeVersion == 0
10491049 ? BuildName . Default
10501050 : BuildName . Unknown ;
1051+
1052+ DetermineGeneration ( package . Summary . Version ) ;
1053+
10511054 return ;
10521055 }
10531056
@@ -1060,28 +1063,14 @@ public GameBuild(UnrealPackage package)
10601063 OverrideLicenseeVersion = overrideAttribute . FixedLicenseeVersion ;
10611064 }
10621065
1063- if ( buildAttribute != null )
1066+ if ( buildAttribute is { Generation : BuildGeneration . Undefined } or null )
10641067 {
1065- if ( buildAttribute . Generation == BuildGeneration . Undefined )
1066- {
1067- uint version = OverrideVersion . GetValueOrDefault ( package . Summary . Version ) ;
1068- if ( package . Summary . UE4Version > 0 )
1069- {
1070- Generation = BuildGeneration . UE4 ;
1071- }
1072- else
1073- Generation = version switch
1074- {
1075- >= ( uint ) PackageObjectLegacyVersion . UE3 => BuildGeneration . UE3 ,
1076- >= ( uint ) PackageObjectLegacyVersion . PrimitiveCastTokenAdded => BuildGeneration . UE2 ,
1077- _ => BuildGeneration . UE1
1078- } ;
1079- }
1080- else
1081- {
1082- Generation = buildAttribute . Generation ;
1083- }
1084-
1068+ uint version = OverrideVersion . GetValueOrDefault ( package . Summary . Version ) ;
1069+ DetermineGeneration ( version ) ;
1070+ }
1071+ else
1072+ {
1073+ Generation = buildAttribute . Generation ;
10851074 Flags = buildAttribute . Flags ;
10861075 }
10871076
@@ -1091,6 +1080,25 @@ public GameBuild(UnrealPackage package)
10911080 // We cannot create the instance here, because the instance itself may be dependent on GameBuild.
10921081 EngineBranchType = engineBranchAttribute . EngineBranchType ;
10931082 }
1083+
1084+ return ;
1085+
1086+ void DetermineGeneration ( uint version )
1087+ {
1088+ if ( package . Summary . UE4Version > 0 )
1089+ {
1090+ Generation = BuildGeneration . UE4 ;
1091+ }
1092+ else
1093+ {
1094+ Generation = version switch
1095+ {
1096+ >= ( uint ) PackageObjectLegacyVersion . UE3 => BuildGeneration . UE3 ,
1097+ >= ( uint ) PackageObjectLegacyVersion . PrimitiveCastTokenAdded => BuildGeneration . UE2 ,
1098+ _ => BuildGeneration . UE1
1099+ } ;
1100+ }
1101+ }
10941102 }
10951103
10961104 private FieldInfo ? FindBuildInfo ( UnrealPackage linker , out BuildAttribute ? buildAttribute )
@@ -1408,7 +1416,10 @@ private void SetupBranch(UnrealPackage package)
14081416 package . Build . Generation ) ;
14091417
14101418 // The branch may override the generation. (Especially in unit-tests this is useful)
1411- package . Build . Generation = package . Branch . Generation ;
1419+ if ( package . Branch . Generation != BuildGeneration . Undefined )
1420+ {
1421+ package . Build . Generation = package . Branch . Generation ;
1422+ }
14121423 }
14131424 else if ( package . Summary . UE4Version > 0 )
14141425 {
0 commit comments