Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Tools/CI/Recipes/MobileBaseRecipe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected string PrepareUtrExecutable(IJobBuilder job, SystemType systemType)
{
case SystemType.Android:
// For build jobs on Android, we still use the built-in UTR and the extra commands are not needed.
if (job.Name.Contains("BuildJobs"))
if (job.Name != null && job.Name.Contains("BuildJobs"))
break;
job.WithCommands(Settings.AndroidExtraCommands).WithAfterCommands(Settings.AndroidExtraAfterCommands);
job.WithCommands(UtrCommand.Download(systemType, "utr.bat"));
Expand Down
12 changes: 9 additions & 3 deletions Tools/CI/Recipes/Utilities/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,18 @@ public static TEnum GetEnumValue<TEnum>(string value) where TEnum : Enum
foreach (var field in type.GetFields())
{
var attribute = field.GetCustomAttribute<EnumMemberAttribute>();
if (attribute != null && attribute.Value == value)

// Ensure both the attribute and its value match
if (attribute?.Value == value)
{
return (TEnum)field.GetValue(null);
var val = field.GetValue(null);
if (val is TEnum result)
{
return result;
}
}
}

throw new ArgumentException($"No EnumMemberAttribute with value '{value}' found in enum '{type.Name}'.");
throw new ArgumentException($"Value '{value}' not found in {type.Name}.");
}
}
14 changes: 7 additions & 7 deletions Tools/CI/Settings/InputSystemSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,16 @@ void ReadMobileConfig()
}

MobileBuildPlatforms.Add(platform, new Platform(
new Agent(v["build"]["image"].ToString(),
Utilities.GetEnumValue<FlavorType>(v["build"]["flavor"].ToString()),
Utilities.GetEnumValue<ResourceType>(v["build"]["type"].ToString())),
new Agent(v?["build"]?["image"]?.ToString() ?? string.Empty,
Utilities.GetEnumValue<FlavorType>(v?["build"]?["flavor"]?.ToString() ?? string.Empty),
Utilities.GetEnumValue<ResourceType>(v?["build"]?["type"]?.ToString() ?? string.Empty)),
platform));

MobileTestPlatforms.Add(platform, new Platform(
new Agent(v["run"]["image"].ToString(),
Utilities.GetEnumValue<FlavorType>(v["run"]["flavor"].ToString()),
Utilities.GetEnumValue<ResourceType>(v["run"]["type"].ToString()),
v["run"]["model"]?.ToString()),
new Agent(v?["run"]?["image"]?.ToString() ?? string.Empty,
Utilities.GetEnumValue<FlavorType>(v?["run"]?["flavor"]?.ToString() ?? string.Empty),
Utilities.GetEnumValue<ResourceType>(v?["run"]?["type"]?.ToString() ?? string.Empty),
v?["run"]?["model"]?.ToString()),
platform));
}
}
Expand Down