Skip to content

Commit 2d1677c

Browse files
FIX: Removing warnings from recipe files displaying on regenerating CI (#2319)
1 parent be2449e commit 2d1677c

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

Tools/CI/Recipes/MobileBaseRecipe.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ protected string PrepareUtrExecutable(IJobBuilder job, SystemType systemType)
5353
{
5454
case SystemType.Android:
5555
// For build jobs on Android, we still use the built-in UTR and the extra commands are not needed.
56-
if (job.Name.Contains("BuildJobs"))
56+
if (job.Name != null && job.Name.Contains("BuildJobs"))
5757
break;
5858
job.WithCommands(Settings.AndroidExtraCommands).WithAfterCommands(Settings.AndroidExtraAfterCommands);
5959
job.WithCommands(UtrCommand.Download(systemType, "utr.bat"));

Tools/CI/Recipes/Utilities/Utilities.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,18 @@ public static TEnum GetEnumValue<TEnum>(string value) where TEnum : Enum
5353
foreach (var field in type.GetFields())
5454
{
5555
var attribute = field.GetCustomAttribute<EnumMemberAttribute>();
56-
if (attribute != null && attribute.Value == value)
56+
57+
// Ensure both the attribute and its value match
58+
if (attribute?.Value == value)
5759
{
58-
return (TEnum)field.GetValue(null);
60+
var val = field.GetValue(null);
61+
if (val is TEnum result)
62+
{
63+
return result;
64+
}
5965
}
6066
}
6167

62-
throw new ArgumentException($"No EnumMemberAttribute with value '{value}' found in enum '{type.Name}'.");
68+
throw new ArgumentException($"Value '{value}' not found in {type.Name}.");
6369
}
6470
}

Tools/CI/Settings/InputSystemSettings.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,16 +157,16 @@ void ReadMobileConfig()
157157
}
158158

159159
MobileBuildPlatforms.Add(platform, new Platform(
160-
new Agent(v["build"]["image"].ToString(),
161-
Utilities.GetEnumValue<FlavorType>(v["build"]["flavor"].ToString()),
162-
Utilities.GetEnumValue<ResourceType>(v["build"]["type"].ToString())),
160+
new Agent(v?["build"]?["image"]?.ToString() ?? string.Empty,
161+
Utilities.GetEnumValue<FlavorType>(v?["build"]?["flavor"]?.ToString() ?? string.Empty),
162+
Utilities.GetEnumValue<ResourceType>(v?["build"]?["type"]?.ToString() ?? string.Empty)),
163163
platform));
164164

165165
MobileTestPlatforms.Add(platform, new Platform(
166-
new Agent(v["run"]["image"].ToString(),
167-
Utilities.GetEnumValue<FlavorType>(v["run"]["flavor"].ToString()),
168-
Utilities.GetEnumValue<ResourceType>(v["run"]["type"].ToString()),
169-
v["run"]["model"]?.ToString()),
166+
new Agent(v?["run"]?["image"]?.ToString() ?? string.Empty,
167+
Utilities.GetEnumValue<FlavorType>(v?["run"]?["flavor"]?.ToString() ?? string.Empty),
168+
Utilities.GetEnumValue<ResourceType>(v?["run"]?["type"]?.ToString() ?? string.Empty),
169+
v?["run"]?["model"]?.ToString()),
170170
platform));
171171
}
172172
}

0 commit comments

Comments
 (0)