Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

No more schema copying #953

Merged
merged 16 commits into from
May 29, 2019
2 changes: 1 addition & 1 deletion workers/unity/Assets/Plugins.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using UnityEngine;

Expand Down Expand Up @@ -55,26 +54,32 @@ internal List<string> Validate()
errors.Add($"{GdkToolsConfigurationWindow.DescriptorOutputDirLabel} cannot be empty.");
}

var emptySchemaSourceDir = false;
foreach (var schemaSourceDir in SchemaSourceDirs)
for (var i = 0; i < SchemaSourceDirs.Count; i++)
{
var schemaSourceDir = SchemaSourceDirs[i];

if (!string.IsNullOrEmpty(schemaSourceDir))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invert the if condition and continue if its null or empty:

if (string.IsNullOrEmpty(schemaSourceDir))
{
	errors.Add(...);
	continue;
}

try 
{
	...
}

...

{
var fullSchemaSourceDirPath = Path.Combine(UnityProjectRoot, schemaSourceDir);
string fullSchemaSourceDirPath;
try
{
fullSchemaSourceDirPath = Path.Combine(UnityProjectRoot, schemaSourceDir);
}
catch (ArgumentException)
{
errors.Add($"Schema path [{i}] contains one or more invalid characters.");
continue;
}

if (!Directory.Exists(fullSchemaSourceDirPath))
paulbalaji marked this conversation as resolved.
Show resolved Hide resolved
{
errors.Add($"{fullSchemaSourceDirPath} cannot be found.");
}

continue;
}

emptySchemaSourceDir = true;
}

if (emptySchemaSourceDir)
{
errors.Add($"Cannot have any empty entry in {GdkToolsConfigurationWindow.SchemaSourceDirsLabel}.");
else
{
errors.Add($"Schema path [{i}] is empty. You must provide a valid path.");
}
}

if (!string.IsNullOrEmpty(RuntimeIp) && !IPAddress.TryParse(RuntimeIp, out _))
Expand Down