Skip to content

Commit f0e8b87

Browse files
authored
Merge pull request #1070 from PlayEveryWare/fix/nullcheck-migration
Fix/nullcheck migration
2 parents 5ecb90d + 5b41120 commit f0e8b87

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

com.playeveryware.eos/Runtime/Core/Config/PlatformConfig.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,11 +416,11 @@ protected virtual void MigrateNonOverrideableConfigValues(EOSConfig overrideValu
416416
integratedPlatformManagementFlags |= mainNonOverrideableConfig.integratedPlatformManagementFlags;
417417

418418
ProductConfig productConfig = Get<ProductConfig>();
419-
string compDeploymentString = mainNonOverrideableConfig.deploymentID.ToLower();
419+
string compDeploymentString = mainNonOverrideableConfig.deploymentID?.ToLower();
420420

421421
foreach(Named<Deployment> dep in productConfig.Environments.Deployments)
422422
{
423-
if (!compDeploymentString.Equals(dep.Value.DeploymentId.ToString("N").ToLowerInvariant()))
423+
if (!string.IsNullOrEmpty(compDeploymentString) && !compDeploymentString.Equals(dep.Value.DeploymentId.ToString("N").ToLowerInvariant()))
424424
{
425425
continue;
426426
}

com.playeveryware.eos/Runtime/Core/Config/ProductConfig.cs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ private void MigrateProductNameVersionAndId(PreviousEOSConfig config)
141141
ProductName = config.productName;
142142
ProductVersion = config.productVersion;
143143

144-
if (!Guid.TryParse(config.productID, out ProductId))
144+
// Attempt to parse the productID, and log a message if it cannot be parsed
145+
// Do not log a message if the productID is empty, and could not possibly migrate
146+
if (!string.IsNullOrWhiteSpace(config.productID) && !Guid.TryParse(config.productID, out ProductId))
145147
{
146148
Debug.LogWarning("Could not parse product ID.");
147149
}
@@ -151,13 +153,24 @@ private void MigrateClientCredentials(PreviousEOSConfig config)
151153
{
152154
#if !EOS_DISABLE
153155
// Import the old config client stuff
154-
Clients.Add(new EOSClientCredentials(config.clientID, config.clientSecret,
155-
config.encryptionKey));
156+
// Some amount of these values should be provided, though encryptionKey is optional
157+
if (!string.IsNullOrWhiteSpace(config.clientID) && !string.IsNullOrWhiteSpace(config.clientSecret))
158+
{
159+
Clients.Add(new EOSClientCredentials(config.clientID, config.clientSecret,
160+
config.encryptionKey));
161+
}
156162
#endif
157163
}
158164

159165
private void MigrateSandboxAndDeployment(PreviousEOSConfig config)
160166
{
167+
// Check to see if the sandbox and deployment id were configured in the previous config
168+
if (string.IsNullOrWhiteSpace(config.sandboxID) || string.IsNullOrEmpty(config.deploymentID))
169+
{
170+
// One of them is empty, we can't possibly add this deployment
171+
return;
172+
}
173+
161174
// Import explicitly set sandbox and deployment
162175
SandboxId sandboxId = new()
163176
{
@@ -181,6 +194,13 @@ private void MigrateSandboxAndDeployment(PreviousEOSConfig config)
181194

182195
private void MigrateSandboxAndDeploymentOverrides(PreviousEOSConfig config)
183196
{
197+
// If the sandboxDeploymentOverrides didn't parse, they were likely missing
198+
// Only migrate values if they are present
199+
if (config.sandboxDeploymentOverrides == null)
200+
{
201+
return;
202+
}
203+
184204
// Import each of the overrides
185205
foreach (var overrideValues in config.sandboxDeploymentOverrides)
186206
{

com.playeveryware.eos/Runtime/Core/Utility/ConfigurationUtility.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public static EOSCreateOptions GetEOSCreateOptions()
7777
platformConfig.platformOptionsFlags.Unwrap();
7878
#endif
7979

80-
if (!platformConfig.clientCredentials.IsEncryptionKeyValid())
80+
if (platformConfig.clientCredentials == null || platformConfig.clientCredentials.IsEncryptionKeyValid() == false)
8181
{
8282
Debug.LogError("The encryption key used for the selected client credentials is invalid. Please see your platform configuration.");
8383
}
@@ -147,7 +147,7 @@ public static EOSInitializeOptions GetEOSInitializeOptions()
147147
// Set the product name, version, and override thread affinity
148148
initOptions.options.ProductName = productConfig.ProductName;
149149
initOptions.options.ProductVersion = productConfig.ProductVersion;
150-
initOptions.options.OverrideThreadAffinity = platformConfig.threadAffinity.Unwrap();
150+
initOptions.options.OverrideThreadAffinity = platformConfig.threadAffinity?.Unwrap();
151151

152152
initOptions.options.AllocateMemoryFunction = IntPtr.Zero;
153153
initOptions.options.ReallocateMemoryFunction = IntPtr.Zero;

0 commit comments

Comments
 (0)