update libs
This commit is contained in:
@@ -130,6 +130,6 @@ AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 11.4.4
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Icons/error.png
|
||||
uploadId: 712972
|
||||
uploadId: 724584
|
||||
|
||||
@@ -130,6 +130,6 @@ AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 11.4.4
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Icons/error_d.png
|
||||
uploadId: 712972
|
||||
uploadId: 724584
|
||||
|
||||
@@ -130,6 +130,6 @@ AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 11.4.4
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Icons/success.png
|
||||
uploadId: 712972
|
||||
uploadId: 724584
|
||||
|
||||
@@ -130,6 +130,6 @@ AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 11.4.4
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Icons/success_d.png
|
||||
uploadId: 712972
|
||||
uploadId: 724584
|
||||
|
||||
@@ -130,6 +130,6 @@ AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 11.4.4
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Icons/undefined.png
|
||||
uploadId: 712972
|
||||
uploadId: 724584
|
||||
|
||||
@@ -130,6 +130,6 @@ AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 11.4.4
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Icons/undefined_d.png
|
||||
uploadId: 712972
|
||||
uploadId: 724584
|
||||
|
||||
@@ -130,6 +130,6 @@ AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 11.4.4
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Icons/warning.png
|
||||
uploadId: 712972
|
||||
uploadId: 724584
|
||||
|
||||
@@ -130,6 +130,6 @@ AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 11.4.4
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Icons/warning_d.png
|
||||
uploadId: 712972
|
||||
uploadId: 724584
|
||||
|
||||
@@ -6,40 +6,47 @@ namespace AssetStoreTools.Validator.Categories
|
||||
internal class CategoryEvaluator
|
||||
{
|
||||
private string _category;
|
||||
|
||||
|
||||
public CategoryEvaluator(string category)
|
||||
{
|
||||
_category = category;
|
||||
if (string.IsNullOrEmpty(category))
|
||||
_category = string.Empty;
|
||||
else
|
||||
_category = category;
|
||||
}
|
||||
|
||||
public void SetCategory(string category)
|
||||
{
|
||||
_category = category;
|
||||
if (category == null)
|
||||
_category = string.Empty;
|
||||
else
|
||||
_category = category;
|
||||
}
|
||||
|
||||
public string GetCategory()
|
||||
{
|
||||
return _category;
|
||||
}
|
||||
|
||||
public TestResult.ResultStatus Evaluate(ValidationTest validation, bool slugify = false)
|
||||
|
||||
public TestResultStatus Evaluate(ValidationTest validation, bool slugify = false)
|
||||
{
|
||||
var result = validation.Result.Result;
|
||||
if (result != TestResult.ResultStatus.VariableSeverityIssue)
|
||||
var result = validation.Result.Status;
|
||||
if (result != TestResultStatus.VariableSeverityIssue)
|
||||
return result;
|
||||
|
||||
var category = _category;
|
||||
|
||||
|
||||
if (slugify)
|
||||
category = validation.Slugify(category);
|
||||
|
||||
return validation.CategoryInfo.EvaluateByFilter(category);
|
||||
}
|
||||
|
||||
// Used by ab-builder
|
||||
public TestResult.ResultStatus EvaluateAndSlugify(ValidationTest validation)
|
||||
|
||||
#if AB_BUILDER
|
||||
public TestResultStatus EvaluateAndSlugify(ValidationTest validation)
|
||||
{
|
||||
return Evaluate(validation, true);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,6 @@ AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 11.4.4
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Categories/CategoryEvaluator.cs
|
||||
uploadId: 712972
|
||||
uploadId: 724584
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace AssetStoreTools.Validator.Categories
|
||||
public bool AppliesToSubCategories = true;
|
||||
public string[] Filter = { "Tools", "Art" };
|
||||
|
||||
public TestResult.ResultStatus EvaluateByFilter(string category)
|
||||
public TestResultStatus EvaluateByFilter(string category)
|
||||
{
|
||||
if (AppliesToSubCategories)
|
||||
category = category.Split('/')[0];
|
||||
@@ -22,16 +22,16 @@ namespace AssetStoreTools.Validator.Categories
|
||||
if (IsInclusiveFilter)
|
||||
{
|
||||
if (isCategoryInFilter)
|
||||
return IsFailFilter ? TestResult.ResultStatus.Fail : TestResult.ResultStatus.Warning;
|
||||
return IsFailFilter ? TestResultStatus.Fail : TestResultStatus.Warning;
|
||||
else
|
||||
return IsFailFilter ? TestResult.ResultStatus.Warning : TestResult.ResultStatus.Fail;
|
||||
return IsFailFilter ? TestResultStatus.Warning : TestResultStatus.Fail;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isCategoryInFilter)
|
||||
return IsFailFilter ? TestResult.ResultStatus.Warning : TestResult.ResultStatus.Fail;
|
||||
return IsFailFilter ? TestResultStatus.Warning : TestResultStatus.Fail;
|
||||
else
|
||||
return IsFailFilter ? TestResult.ResultStatus.Fail : TestResult.ResultStatus.Warning;
|
||||
return IsFailFilter ? TestResultStatus.Fail : TestResultStatus.Warning;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,6 @@ AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 11.4.4
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Categories/ValidatorCategory.cs
|
||||
uploadId: 712972
|
||||
uploadId: 724584
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
using AssetStoreTools.Validator.Data;
|
||||
using AssetStoreTools.Validator.TestDefinitions;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace AssetStoreTools.Validator
|
||||
{
|
||||
internal class CurrentProjectValidator : ValidatorBase
|
||||
{
|
||||
private CurrentProjectValidationSettings _settings;
|
||||
|
||||
public CurrentProjectValidator(CurrentProjectValidationSettings settings) : base(settings)
|
||||
{
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
protected override void ValidateSettings()
|
||||
{
|
||||
if (_settings == null)
|
||||
throw new Exception("Validation Settings is null");
|
||||
|
||||
if (_settings.ValidationPaths == null
|
||||
|| _settings.ValidationPaths.Count == 0)
|
||||
throw new Exception("No validation paths were set");
|
||||
|
||||
switch (_settings.ValidationType)
|
||||
{
|
||||
case ValidationType.Generic:
|
||||
case ValidationType.UnityPackage:
|
||||
ValidateUnityPackageSettings();
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedException("Undefined validation type");
|
||||
}
|
||||
}
|
||||
|
||||
private void ValidateUnityPackageSettings()
|
||||
{
|
||||
var invalidPaths = string.Empty;
|
||||
foreach (var path in _settings.ValidationPaths)
|
||||
{
|
||||
if (!Directory.Exists(path))
|
||||
invalidPaths += $"\n{path}";
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(invalidPaths))
|
||||
throw new Exception("The following directories do not exist:" + invalidPaths);
|
||||
}
|
||||
|
||||
protected override ValidationResult GenerateValidationResult()
|
||||
{
|
||||
ITestConfig config;
|
||||
var applicableTests = GetApplicableTests(ValidationType.Generic);
|
||||
switch (_settings.ValidationType)
|
||||
{
|
||||
case ValidationType.Generic:
|
||||
config = new GenericTestConfig() { ValidationPaths = _settings.ValidationPaths.ToArray() };
|
||||
break;
|
||||
case ValidationType.UnityPackage:
|
||||
applicableTests.AddRange(GetApplicableTests(ValidationType.UnityPackage));
|
||||
config = new GenericTestConfig() { ValidationPaths = _settings.ValidationPaths.ToArray() };
|
||||
break;
|
||||
default:
|
||||
return new ValidationResult() { Status = ValidationStatus.Failed, Exception = new Exception("Undefined validation type") };
|
||||
}
|
||||
|
||||
var validationResult = RunTests(applicableTests, config);
|
||||
return validationResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f856d841ca50d7842b2850015d8b1f62
|
||||
guid: 3a6371dcfa8545c478545b4a43433599
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -13,6 +13,6 @@ AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 11.4.4
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/UI Elements/PathBoxElement.cs
|
||||
uploadId: 712972
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/CurrentProjectValidator.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,33 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace AssetStoreTools.Validator.Data
|
||||
{
|
||||
internal class CurrentProjectValidationSettings : ValidationSettings
|
||||
{
|
||||
public List<string> ValidationPaths;
|
||||
public ValidationType ValidationType;
|
||||
|
||||
public CurrentProjectValidationSettings()
|
||||
{
|
||||
Category = string.Empty;
|
||||
ValidationPaths = new List<string>();
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null || obj.GetType() != typeof(CurrentProjectValidationSettings))
|
||||
return false;
|
||||
|
||||
var other = (CurrentProjectValidationSettings)obj;
|
||||
return Category == other.Category
|
||||
&& ValidationType == other.ValidationType
|
||||
&& ValidationPaths.OrderBy(x => x).SequenceEqual(other.ValidationPaths.OrderBy(x => x));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 42aa5ee716f3fc340a5055b4c42a0b55
|
||||
guid: 9e4a4a4aa3f501847b1abb1e08505f9b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -13,6 +13,6 @@ AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 11.4.4
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Test Definitions/ValidationTestConfig.cs
|
||||
uploadId: 712972
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Data/CurrentProjectValidationSettings.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace AssetStoreTools.Validator.Data
|
||||
{
|
||||
internal class ExternalProjectValidationSettings : ValidationSettings
|
||||
{
|
||||
public string PackagePath;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f79c895f4bb099b4983dd20eef72a7bd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Data/ExternalProjectValidationSettings.cs
|
||||
uploadId: 724584
|
||||
@@ -1,75 +0,0 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AssetStoreTools.Validator.Data
|
||||
{
|
||||
internal interface IMessageAction
|
||||
{
|
||||
string ActionTooltip { get; }
|
||||
|
||||
void Execute();
|
||||
}
|
||||
|
||||
internal enum ClickActionType
|
||||
{
|
||||
None = 0,
|
||||
HighlightObject = 1,
|
||||
OpenAsset = 2
|
||||
}
|
||||
|
||||
internal class MessageActionHighlight : IMessageAction
|
||||
{
|
||||
private Object _objectToHighlight;
|
||||
|
||||
public GlobalObjectId GlobalObjectIdentifier { get; set; }
|
||||
public string ActionTooltip => "Click to highlight the associated object in Hierarchy/Project view";
|
||||
|
||||
public MessageActionHighlight(Object objectToHighlight)
|
||||
{
|
||||
this._objectToHighlight = objectToHighlight;
|
||||
GlobalObjectIdentifier = GlobalObjectId.GetGlobalObjectIdSlow(objectToHighlight);
|
||||
}
|
||||
|
||||
public MessageActionHighlight(string globalObjectId)
|
||||
{
|
||||
GlobalObjectId.TryParse(globalObjectId, out GlobalObjectId globalObjectIdentifier);
|
||||
GlobalObjectIdentifier = globalObjectIdentifier;
|
||||
}
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
if(_objectToHighlight == null)
|
||||
_objectToHighlight = GlobalObjectId.GlobalObjectIdentifierToObjectSlow(GlobalObjectIdentifier);
|
||||
|
||||
EditorGUIUtility.PingObject(_objectToHighlight);
|
||||
}
|
||||
}
|
||||
|
||||
internal class MessageActionOpenAsset : IMessageAction
|
||||
{
|
||||
private Object _objectToOpen;
|
||||
public int LineNumber { get; set; }
|
||||
|
||||
public GlobalObjectId GlobalObjectIdentifier { get; set; }
|
||||
public string ActionTooltip => "Click to open the associated asset";
|
||||
|
||||
public MessageActionOpenAsset(Object objectToOpen)
|
||||
{
|
||||
this._objectToOpen = objectToOpen;
|
||||
GlobalObjectIdentifier = GlobalObjectId.GetGlobalObjectIdSlow(objectToOpen);
|
||||
}
|
||||
|
||||
public MessageActionOpenAsset(string globalObjectId)
|
||||
{
|
||||
GlobalObjectId.TryParse(globalObjectId, out GlobalObjectId globalObjectIdentifier);
|
||||
GlobalObjectIdentifier = globalObjectIdentifier;
|
||||
}
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
if (_objectToOpen == null)
|
||||
_objectToOpen = GlobalObjectId.GlobalObjectIdentifierToObjectSlow(GlobalObjectIdentifier);
|
||||
AssetDatabase.OpenAsset(_objectToOpen, LineNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e19a46dc1cd08d14aa033e13df62587b
|
||||
guid: d51c5c866dcd449488caa10a40dd3301
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
@@ -0,0 +1,31 @@
|
||||
using Newtonsoft.Json;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AssetStoreTools.Validator.Data.MessageActions
|
||||
{
|
||||
internal class HighlightObjectAction : IMessageAction
|
||||
{
|
||||
public string Tooltip => "Click to highlight the associated object in Hierarchy/Project view";
|
||||
public Object Target => _target?.GetObject();
|
||||
|
||||
[JsonProperty]
|
||||
private TestResultObject _target;
|
||||
|
||||
public HighlightObjectAction() { }
|
||||
|
||||
public HighlightObjectAction(Object target)
|
||||
{
|
||||
_target = new TestResultObject(target);
|
||||
}
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
var targetObject = _target.GetObject();
|
||||
if (targetObject == null)
|
||||
return;
|
||||
|
||||
EditorGUIUtility.PingObject(targetObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: de24c0a7f8a22c142a224e6abd0ddc68
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Data/MessageActions/HighlightObjectAction.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,16 @@
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AssetStoreTools.Validator.Data.MessageActions
|
||||
{
|
||||
internal interface IMessageAction
|
||||
{
|
||||
[JsonIgnore]
|
||||
string Tooltip { get; }
|
||||
|
||||
[JsonIgnore]
|
||||
Object Target { get; }
|
||||
|
||||
void Execute();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f1636d7241abdf1498368f841aa818a2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Data/MessageActions/IMessageAction.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,38 @@
|
||||
using Newtonsoft.Json;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AssetStoreTools.Validator.Data.MessageActions
|
||||
{
|
||||
internal class OpenAssetAction : IMessageAction
|
||||
{
|
||||
public string Tooltip => "Click to open the associated asset";
|
||||
public Object Target => _target?.GetObject();
|
||||
|
||||
[JsonProperty]
|
||||
private TestResultObject _target;
|
||||
[JsonProperty]
|
||||
private int _lineNumber;
|
||||
|
||||
public OpenAssetAction() { }
|
||||
|
||||
public OpenAssetAction(Object target)
|
||||
{
|
||||
_target = new TestResultObject(target);
|
||||
}
|
||||
|
||||
public OpenAssetAction(Object target, int lineNumber) : this(target)
|
||||
{
|
||||
_lineNumber = lineNumber;
|
||||
}
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
var targetObject = _target.GetObject();
|
||||
if (targetObject == null)
|
||||
return;
|
||||
|
||||
AssetDatabase.OpenAsset(targetObject, _lineNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9fb4fec293bf73f4a8f870c535750613
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Data/MessageActions/OpenAssetAction.cs
|
||||
uploadId: 724584
|
||||
@@ -1,20 +1,23 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using Object = UnityEngine.Object;
|
||||
using AssetStoreTools.Validator.Data.MessageActions;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AssetStoreTools.Validator.Data
|
||||
{
|
||||
[Serializable]
|
||||
internal struct TestResult
|
||||
{
|
||||
public ResultStatus Result;
|
||||
public TestResultStatus Status;
|
||||
|
||||
[SerializeField, HideInInspector]
|
||||
private List<TestResultMessage> Messages;
|
||||
[JsonProperty]
|
||||
private List<TestResultMessage> _messages;
|
||||
|
||||
public int MessageCount => Messages?.Count ?? 0;
|
||||
[JsonIgnore]
|
||||
public int MessageCount => _messages != null ? _messages.Count : 0;
|
||||
|
||||
public TestResultMessage GetMessage(int index)
|
||||
{
|
||||
return _messages[index];
|
||||
}
|
||||
|
||||
public void AddMessage(string msg)
|
||||
{
|
||||
@@ -28,145 +31,21 @@ namespace AssetStoreTools.Validator.Data
|
||||
|
||||
public void AddMessage(string msg, IMessageAction clickAction, params UnityEngine.Object[] messageObjects)
|
||||
{
|
||||
if (Messages == null)
|
||||
Messages = new List<TestResultMessage>();
|
||||
if (_messages == null)
|
||||
_messages = new List<TestResultMessage>();
|
||||
|
||||
var message = new TestResultMessage(msg, clickAction);
|
||||
AddMessageObjects(messageObjects, message);
|
||||
Messages.Add(message);
|
||||
}
|
||||
_messages.Add(message);
|
||||
|
||||
private void AddMessageObjects(Object[] messageObjects, TestResultMessage message)
|
||||
{
|
||||
if (messageObjects == null)
|
||||
return;
|
||||
|
||||
|
||||
foreach (var obj in messageObjects)
|
||||
{
|
||||
#if AB_BUILDER
|
||||
string path = AssetDatabase.GetAssetPath(obj);
|
||||
message.AppendText($"\nAsset at: {path}");
|
||||
#else
|
||||
if (obj == null)
|
||||
continue;
|
||||
|
||||
message.AddMessageObject(obj);
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public TestResultMessage GetMessage(int index)
|
||||
{
|
||||
if (Messages == null || index >= Messages.Count)
|
||||
throw new InvalidOperationException();
|
||||
return Messages[index];
|
||||
}
|
||||
|
||||
public enum ResultStatus
|
||||
{
|
||||
Undefined = 0,
|
||||
Pass = 1,
|
||||
Fail = 2,
|
||||
Warning = 3,
|
||||
VariableSeverityIssue = 4
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
internal class TestResultMessage : ISerializationCallbackReceiver
|
||||
{
|
||||
[SerializeField, HideInInspector]
|
||||
private string Text;
|
||||
[SerializeField, HideInInspector]
|
||||
private List<string> MessageObjects;
|
||||
// Serialization
|
||||
[SerializeField, HideInInspector]
|
||||
private string SerializedClickAction;
|
||||
|
||||
private IMessageAction _clickAction;
|
||||
|
||||
public IMessageAction ClickAction => _clickAction;
|
||||
|
||||
public TestResultMessage() { }
|
||||
|
||||
public TestResultMessage(string text)
|
||||
{
|
||||
Text = text;
|
||||
}
|
||||
|
||||
public TestResultMessage(string text, IMessageAction clickAction) : this(text)
|
||||
{
|
||||
_clickAction = clickAction;
|
||||
}
|
||||
|
||||
public void AddMessageObject(Object obj)
|
||||
{
|
||||
if (MessageObjects == null)
|
||||
MessageObjects = new List<string>();
|
||||
var globalObjectId = GlobalObjectId.GetGlobalObjectIdSlow(obj).ToString();
|
||||
if (globalObjectId != "GlobalObjectId_V1-0-00000000000000000000000000000000-0-0")
|
||||
MessageObjects.Add(GlobalObjectId.GetGlobalObjectIdSlow(obj).ToString());
|
||||
else
|
||||
Text += $"\n{obj.name}";
|
||||
}
|
||||
|
||||
public Object[] GetMessageObjects()
|
||||
{
|
||||
if (MessageObjects == null)
|
||||
return Array.Empty<Object>();
|
||||
var objects = new Object[MessageObjects.Count];
|
||||
for (int i = 0; i < objects.Length; i++)
|
||||
{
|
||||
GlobalObjectId.TryParse(MessageObjects[i], out GlobalObjectId id);
|
||||
objects[i] = GlobalObjectId.GlobalObjectIdentifierToObjectSlow(id);
|
||||
}
|
||||
return objects;
|
||||
}
|
||||
|
||||
public void OnBeforeSerialize()
|
||||
{
|
||||
SerializedClickAction = ((int)ClickActionType.None).ToString();
|
||||
switch (_clickAction)
|
||||
{
|
||||
case MessageActionHighlight action:
|
||||
var objectId = action.GlobalObjectIdentifier.ToString();
|
||||
SerializedClickAction = $"{(int)ClickActionType.HighlightObject}|{objectId}";
|
||||
break;
|
||||
case MessageActionOpenAsset action:
|
||||
objectId = action.GlobalObjectIdentifier.ToString();
|
||||
SerializedClickAction = $"{(int)ClickActionType.OpenAsset}|{objectId}|{action.LineNumber}";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnAfterDeserialize()
|
||||
{
|
||||
string[] splitAction = SerializedClickAction.Split('|');
|
||||
bool parsed = Enum.TryParse(splitAction[0], out ClickActionType clickActionType);
|
||||
if (!parsed) return;
|
||||
|
||||
switch (clickActionType)
|
||||
{
|
||||
case ClickActionType.HighlightObject:
|
||||
_clickAction = new MessageActionHighlight(splitAction[1]);
|
||||
break;
|
||||
case ClickActionType.OpenAsset:
|
||||
_clickAction = new MessageActionOpenAsset(splitAction[1])
|
||||
{ LineNumber = Convert.ToInt32(splitAction[2]) };
|
||||
break;
|
||||
case ClickActionType.None:
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
public void AppendText(string value)
|
||||
{
|
||||
Text += value;
|
||||
}
|
||||
|
||||
public string GetText()
|
||||
{
|
||||
return Text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,6 @@ AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 11.4.4
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Data/TestResult.cs
|
||||
uploadId: 712972
|
||||
uploadId: 724584
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
using AssetStoreTools.Validator.Data.MessageActions;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace AssetStoreTools.Validator.Data
|
||||
{
|
||||
internal class TestResultMessage
|
||||
{
|
||||
[JsonIgnore]
|
||||
public int MessageObjectCount => _messageObjects.Count;
|
||||
|
||||
[JsonProperty]
|
||||
private string _text;
|
||||
[JsonProperty]
|
||||
private List<TestResultObject> _messageObjects;
|
||||
[JsonProperty]
|
||||
private IMessageAction _clickAction;
|
||||
|
||||
public TestResultMessage() { }
|
||||
|
||||
public TestResultMessage(string text)
|
||||
{
|
||||
_text = text;
|
||||
_messageObjects = new List<TestResultObject>();
|
||||
}
|
||||
|
||||
public TestResultMessage(string text, IMessageAction clickAction) : this(text)
|
||||
{
|
||||
_clickAction = clickAction;
|
||||
}
|
||||
|
||||
public string GetText()
|
||||
{
|
||||
return _text;
|
||||
}
|
||||
|
||||
public IMessageAction GetClickAction()
|
||||
{
|
||||
return _clickAction;
|
||||
}
|
||||
|
||||
public void AddMessageObject(Object obj)
|
||||
{
|
||||
_messageObjects.Add(new TestResultObject(obj));
|
||||
}
|
||||
|
||||
public TestResultObject GetMessageObject(int index)
|
||||
{
|
||||
return _messageObjects[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0761356c44140ca49917f93b42926471
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Data/TestResultMessage.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,35 @@
|
||||
using Newtonsoft.Json;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AssetStoreTools.Validator.Data
|
||||
{
|
||||
internal class TestResultObject
|
||||
{
|
||||
[JsonIgnore]
|
||||
private Object _object;
|
||||
[JsonProperty]
|
||||
private string _objectGlobalId;
|
||||
|
||||
public TestResultObject(Object obj)
|
||||
{
|
||||
_object = obj;
|
||||
_objectGlobalId = GlobalObjectId.GetGlobalObjectIdSlow(obj).ToString();
|
||||
}
|
||||
|
||||
public Object GetObject()
|
||||
{
|
||||
if (_object != null)
|
||||
return _object;
|
||||
|
||||
if (string.IsNullOrEmpty(_objectGlobalId))
|
||||
return null;
|
||||
|
||||
if (!GlobalObjectId.TryParse(_objectGlobalId, out var globalObject))
|
||||
return null;
|
||||
|
||||
_object = GlobalObjectId.GlobalObjectIdentifierToObjectSlow(globalObject);
|
||||
return _object;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: acce8e477b7fe2c4aa430ebdd65ea7d1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Data/TestResultObject.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace AssetStoreTools.Validator.Data
|
||||
{
|
||||
internal enum TestResultStatus
|
||||
{
|
||||
Undefined = 0,
|
||||
Pass = 1,
|
||||
Fail = 2,
|
||||
Warning = 3,
|
||||
VariableSeverityIssue = 4
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eef1ba0cf35f1304d8929e23b94e7c23
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Data/TestResultStatus.cs
|
||||
uploadId: 724584
|
||||
@@ -1,31 +1,24 @@
|
||||
using AssetStoreTools.Validator.TestDefinitions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AssetStoreTools.Validator.Data
|
||||
{
|
||||
internal enum ValidationStatus
|
||||
{
|
||||
NotRun,
|
||||
RanToCompletion,
|
||||
Failed,
|
||||
Cancelled
|
||||
}
|
||||
|
||||
internal class ValidationResult
|
||||
{
|
||||
public ValidationStatus Status;
|
||||
public List<AutomatedTest> AutomatedTests;
|
||||
public bool HadCompilationErrors;
|
||||
public string ProjectPath;
|
||||
public string Error;
|
||||
public List<AutomatedTest> Tests;
|
||||
public Exception Exception;
|
||||
|
||||
public ValidationResult()
|
||||
{
|
||||
Status = ValidationStatus.NotRun;
|
||||
AutomatedTests = new List<AutomatedTest>();
|
||||
HadCompilationErrors = false;
|
||||
ProjectPath = string.Empty;
|
||||
Error = string.Empty;
|
||||
Tests = new List<AutomatedTest>();
|
||||
Exception = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,6 @@ AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 11.4.4
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Data/ValidationResult.cs
|
||||
uploadId: 712972
|
||||
uploadId: 724584
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AssetStoreTools.Validator.Data
|
||||
{
|
||||
internal class ValidationSettings
|
||||
internal abstract class ValidationSettings
|
||||
{
|
||||
public List<string> ValidationPaths;
|
||||
public string Category;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dd3bbba60e92d4843a393874a9de9a63
|
||||
guid: 33e99d6b6e1e7ef4abd6cd2c0137741a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -13,6 +13,6 @@ AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 11.4.4
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Data/ValidationSettings.cs
|
||||
uploadId: 712972
|
||||
uploadId: 724584
|
||||
|
||||
@@ -1,170 +0,0 @@
|
||||
using AssetStoreTools.Utility;
|
||||
using AssetStoreTools.Utility.Json;
|
||||
using AssetStoreTools.Validator.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AssetStoreTools.Validator.Data
|
||||
{
|
||||
[Serializable]
|
||||
internal class ValidationStateData
|
||||
{
|
||||
public List<string> SerializedValidationPaths;
|
||||
public string SerializedCategory;
|
||||
public List<int> SerializedKeys;
|
||||
public List<TestResultData> SerializedValues;
|
||||
public bool HasCompilationErrors;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
internal class TestResultData
|
||||
{
|
||||
public TestResult Result;
|
||||
}
|
||||
|
||||
internal class ValidationState
|
||||
{
|
||||
public const string ValidationDataFilename = "AssetStoreValidationState.asset";
|
||||
public const string PersistentDataLocation = "Library";
|
||||
|
||||
public Dictionary<int, TestResultData> TestResults = new Dictionary<int, TestResultData>();
|
||||
public ValidationStateData ValidationStateData;
|
||||
public Action OnJsonSave;
|
||||
|
||||
private static ValidationState s_instance;
|
||||
public static ValidationState Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (s_instance == null)
|
||||
s_instance = new ValidationState();
|
||||
|
||||
s_instance.LoadJson();
|
||||
|
||||
return s_instance;
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadJson()
|
||||
{
|
||||
if (s_instance.TestResults.Count != 0)
|
||||
return;
|
||||
|
||||
var saveFile = $"{PersistentDataLocation}/{ValidationDataFilename}";
|
||||
|
||||
if (!File.Exists(saveFile))
|
||||
{
|
||||
s_instance.ValidationStateData = new ValidationStateData
|
||||
{
|
||||
SerializedValidationPaths = new List<string>() { "Assets" },
|
||||
SerializedCategory = ""
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
var fileContents = File.ReadAllText(saveFile);
|
||||
var data = JsonUtility.FromJson<ValidationStateData>(fileContents);
|
||||
if (data.SerializedValidationPaths.Count == 0)
|
||||
data.SerializedValidationPaths.Add("Assets");
|
||||
s_instance.ValidationStateData = data;
|
||||
|
||||
var implementedTests = ValidatorUtility.GetAutomatedTestCases();
|
||||
|
||||
for (var i = 0; i < s_instance.ValidationStateData.SerializedKeys.Count; i++)
|
||||
{
|
||||
// Skip any potential tests that were serialized, but are no longer implemented
|
||||
if (!implementedTests.Any(x => x.Id == s_instance.ValidationStateData.SerializedKeys[i]))
|
||||
continue;
|
||||
|
||||
s_instance.TestResults.Add(s_instance.ValidationStateData.SerializedKeys[i], s_instance.ValidationStateData.SerializedValues[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveJson()
|
||||
{
|
||||
var saveFile = $"{PersistentDataLocation}/{ValidationDataFilename}";
|
||||
|
||||
if (TestResults.Keys.Count == 0)
|
||||
return;
|
||||
|
||||
ValidationStateData.SerializedKeys = TestResults.Keys.ToList();
|
||||
ValidationStateData.SerializedValues = TestResults.Values.ToList();
|
||||
|
||||
var jsonString = JsonUtility.ToJson(ValidationStateData);
|
||||
|
||||
File.WriteAllText(saveFile, jsonString);
|
||||
|
||||
OnJsonSave?.Invoke();
|
||||
}
|
||||
|
||||
public static bool GetValidationSummaryJson(ValidationStateData data, out string validationSummaryJson)
|
||||
{
|
||||
validationSummaryJson = string.Empty;
|
||||
try
|
||||
{
|
||||
var json = JsonValue.NewDict();
|
||||
|
||||
// Construct compilation state
|
||||
json["has_compilation_errors"] = data.HasCompilationErrors;
|
||||
|
||||
// Construct validation paths
|
||||
var pathsList = JsonValue.NewList();
|
||||
foreach (var path in data.SerializedValidationPaths)
|
||||
pathsList.Add(path);
|
||||
json["validation_paths"] = pathsList;
|
||||
|
||||
// Construct validation results
|
||||
var resultsDict = JsonValue.NewDict();
|
||||
for (int i = 0; i < data.SerializedKeys.Count; i++)
|
||||
{
|
||||
var key = data.SerializedKeys[i].ToString();
|
||||
var value = JsonValue.NewDict();
|
||||
value["int"] = (int)data.SerializedValues[i].Result.Result;
|
||||
value["string"] = data.SerializedValues[i].Result.Result.ToString();
|
||||
|
||||
resultsDict[key] = value;
|
||||
}
|
||||
json["validation_results"] = resultsDict;
|
||||
validationSummaryJson = json.ToString();
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ASDebug.LogError($"Failed to parse a validation summary json:\n{e}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateTestContainer(int testId)
|
||||
{
|
||||
s_instance.TestResults.Add(testId, new TestResultData());
|
||||
}
|
||||
|
||||
public void ChangeResult(int index, TestResult result)
|
||||
{
|
||||
if (!s_instance.TestResults.ContainsKey(index))
|
||||
CreateTestContainer(index);
|
||||
|
||||
s_instance.TestResults[index].Result = result;
|
||||
}
|
||||
|
||||
public void SetCompilationState(bool hasCompilationErrors)
|
||||
{
|
||||
s_instance.ValidationStateData.HasCompilationErrors = hasCompilationErrors;
|
||||
}
|
||||
|
||||
public void SetValidationPaths(string[] paths)
|
||||
{
|
||||
s_instance.ValidationStateData.SerializedValidationPaths = paths.ToList();
|
||||
}
|
||||
|
||||
public void SetCategory(string category)
|
||||
{
|
||||
s_instance.ValidationStateData.SerializedCategory = category;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bbd993a57160414b93583792dbe5241e
|
||||
timeCreated: 1653399871
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 11.4.4
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Data/ValidationState.cs
|
||||
uploadId: 712972
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace AssetStoreTools.Validator.Data
|
||||
{
|
||||
internal enum ValidationStatus
|
||||
{
|
||||
NotRun,
|
||||
RanToCompletion,
|
||||
Failed,
|
||||
Cancelled
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a1f1e1e94faa6284f8d71804ba2bbd24
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Data/ValidationStatus.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace AssetStoreTools.Validator.Data
|
||||
{
|
||||
internal enum ValidationType
|
||||
{
|
||||
Generic = 0,
|
||||
UnityPackage = 1
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c6c8b1f23bf5c8841be44b13374e7baf
|
||||
guid: 079f8963464230145853d86eff935e04
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -13,6 +13,6 @@ AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 11.4.4
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Data/MessageActions.cs
|
||||
uploadId: 712972
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Data/ValidationType.cs
|
||||
uploadId: 724584
|
||||
@@ -1,144 +1,57 @@
|
||||
using AssetStoreTools.Utility;
|
||||
using AssetStoreTools.Validator.Categories;
|
||||
using AssetStoreTools.Utility;
|
||||
using AssetStoreTools.Validator.Data;
|
||||
using AssetStoreTools.Validator.TestDefinitions;
|
||||
using AssetStoreTools.Validator.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AssetStoreTools.Validator
|
||||
{
|
||||
internal class PackageValidator
|
||||
internal class ExternalProjectValidator : ValidatorBase
|
||||
{
|
||||
#if UNITY_EDITOR_OSX
|
||||
private static readonly string UnityPath = Path.Combine(EditorApplication.applicationPath, "Contents", "MacOS", "Unity");
|
||||
#else // Windows, Linux
|
||||
private static readonly string UnityPath = EditorApplication.applicationPath;
|
||||
#endif
|
||||
private ExternalProjectValidationSettings _settings;
|
||||
|
||||
private CategoryEvaluator _categoryEvaluator;
|
||||
|
||||
|
||||
public List<AutomatedTest> AutomatedTests { get; private set; }
|
||||
public string Category => _categoryEvaluator.GetCategory();
|
||||
|
||||
private static PackageValidator s_instance;
|
||||
public static PackageValidator Instance => s_instance ?? (s_instance = new PackageValidator());
|
||||
|
||||
private PackageValidator()
|
||||
public ExternalProjectValidator(ExternalProjectValidationSettings settings) : base(settings)
|
||||
{
|
||||
_categoryEvaluator = new CategoryEvaluator(ValidationState.Instance.ValidationStateData.SerializedCategory);
|
||||
CreateAutomatedTestCases();
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
private void CreateAutomatedTestCases()
|
||||
protected override void ValidateSettings()
|
||||
{
|
||||
var testData = ValidatorUtility.GetAutomatedTestCases(ValidatorUtility.SortType.Alphabetical);
|
||||
AutomatedTests = new List<AutomatedTest>();
|
||||
if (_settings == null)
|
||||
throw new Exception("Validation Settings is null");
|
||||
|
||||
foreach (var t in testData)
|
||||
{
|
||||
var test = new AutomatedTest(t);
|
||||
|
||||
if (!ValidationState.Instance.TestResults.ContainsKey(test.Id))
|
||||
ValidationState.Instance.CreateTestContainer(test.Id);
|
||||
else
|
||||
test.Result = ValidationState.Instance.TestResults[test.Id].Result;
|
||||
|
||||
AutomatedTests.Add(test);
|
||||
}
|
||||
if (string.IsNullOrEmpty(_settings.PackagePath)
|
||||
|| !File.Exists(_settings.PackagePath))
|
||||
throw new Exception("Package was not found");
|
||||
}
|
||||
|
||||
public static ValidationResult ValidatePackage(ValidationSettings settings)
|
||||
protected override ValidationResult GenerateValidationResult()
|
||||
{
|
||||
return Instance.RunAllTests(settings);
|
||||
}
|
||||
|
||||
public ValidationResult RunAllTests(ValidationSettings settings)
|
||||
{
|
||||
if (settings == null || settings.ValidationPaths == null || settings.ValidationPaths.Count == 0)
|
||||
return new ValidationResult() { Status = ValidationStatus.Failed, Error = "No validation paths were provided" };
|
||||
|
||||
var validationPaths = settings.ValidationPaths.ToArray();
|
||||
_categoryEvaluator.SetCategory(settings.Category);
|
||||
|
||||
var hasCompilationErrors = EditorUtility.scriptCompilationFailed;
|
||||
ValidationState.Instance.SetCompilationState(hasCompilationErrors);
|
||||
|
||||
ValidationState.Instance.SetValidationPaths(validationPaths);
|
||||
ValidationState.Instance.SetCategory(_categoryEvaluator.GetCategory());
|
||||
|
||||
for (int i = 0; i < AutomatedTests.Count; i++)
|
||||
{
|
||||
var test = AutomatedTests[i];
|
||||
|
||||
EditorUtility.DisplayProgressBar("Validating", $"Running validation: {i + 1} - {test.Title}", (float)i / AutomatedTests.Count);
|
||||
test.Run(new ValidationTestConfig() { ValidationPaths = validationPaths });
|
||||
|
||||
// Adjust result based on categories
|
||||
var updatedStatus = _categoryEvaluator.Evaluate(test);
|
||||
test.Result.Result = updatedStatus;
|
||||
|
||||
ValidationState.Instance.ChangeResult(test.Id, test.Result);
|
||||
#if AB_BUILDER
|
||||
EditorUtility.UnloadUnusedAssetsImmediate();
|
||||
#endif
|
||||
}
|
||||
|
||||
EditorUtility.UnloadUnusedAssetsImmediate();
|
||||
EditorUtility.ClearProgressBar();
|
||||
|
||||
ValidationState.Instance.SaveJson();
|
||||
|
||||
var projectPath = Application.dataPath.Substring(0, Application.dataPath.Length - "/Assets".Length);
|
||||
var result = new ValidationResult()
|
||||
{
|
||||
Status = ValidationStatus.RanToCompletion,
|
||||
ProjectPath = projectPath,
|
||||
AutomatedTests = AutomatedTests,
|
||||
HadCompilationErrors = hasCompilationErrors
|
||||
};
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static ValidationResult ValidatePreExportedPackage(ValidationSettings settings, bool interactiveMode)
|
||||
{
|
||||
var result = new ValidationResult();
|
||||
|
||||
if (settings == null || settings.ValidationPaths == null ||
|
||||
settings.ValidationPaths.Count != 1 || string.IsNullOrEmpty(settings.ValidationPaths[0]))
|
||||
{
|
||||
result.Status = ValidationStatus.Failed;
|
||||
result.Error = "A single package path must be provided";
|
||||
return result;
|
||||
}
|
||||
|
||||
bool interactiveMode = false;
|
||||
try
|
||||
{
|
||||
// Step 1 - prepare a temporary project
|
||||
result = PrepareTemporaryValidationProject(settings, result, interactiveMode);
|
||||
var result = PrepareTemporaryValidationProject(interactiveMode);
|
||||
|
||||
// If preparation was cancelled or setting up project failed - return immediately
|
||||
if (result.Status == ValidationStatus.Cancelled || result.Status == ValidationStatus.Failed)
|
||||
return result;
|
||||
|
||||
// Step 2 - load the temporary project and validate the package
|
||||
result = ValidateTemporaryValidationProject(settings, result, interactiveMode);
|
||||
result = ValidateTemporaryValidationProject(result, interactiveMode);
|
||||
|
||||
// Step 3 - copy validation results
|
||||
result = ParseValidationResult(result.ProjectPath);
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
result.Status = ValidationStatus.Failed;
|
||||
result.Error = e.Message;
|
||||
return result;
|
||||
return new ValidationResult() { Status = ValidationStatus.Failed, Exception = e };
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -146,12 +59,12 @@ namespace AssetStoreTools.Validator
|
||||
}
|
||||
}
|
||||
|
||||
private static ValidationResult PrepareTemporaryValidationProject(ValidationSettings settings, ValidationResult result, bool interactiveMode)
|
||||
private ValidationResult PrepareTemporaryValidationProject(bool interactiveMode)
|
||||
{
|
||||
EditorUtility.DisplayProgressBar("Validating...", "Preparing the validation project. This may take a while.", 0.3f);
|
||||
|
||||
var rootProjectPath = Application.dataPath.Substring(0, Application.dataPath.Length - "/Assets".Length);
|
||||
var tempProjectPath = Path.Combine(rootProjectPath, "Temp", GUID.Generate().ToString()).Replace("\\", "/");
|
||||
var result = new ValidationResult();
|
||||
var tempProjectPath = Path.Combine(Constants.RootProjectPath, "Temp", GUID.Generate().ToString()).Replace("\\", "/");
|
||||
result.ProjectPath = tempProjectPath;
|
||||
|
||||
if (!Directory.Exists(tempProjectPath))
|
||||
@@ -169,9 +82,10 @@ namespace AssetStoreTools.Validator
|
||||
// Create the temporary project
|
||||
var processInfo = new System.Diagnostics.ProcessStartInfo()
|
||||
{
|
||||
FileName = UnityPath,
|
||||
Arguments = $"-createProject \"{tempProjectPath}\" -logFile \"{logFilePath}\" -importpackage \"{Path.GetFullPath(settings.ValidationPaths[0])}\" -quit"
|
||||
FileName = Constants.UnityPath,
|
||||
Arguments = $"-createProject \"{tempProjectPath}\" -logFile \"{logFilePath}\" -importpackage \"{Path.GetFullPath(_settings.PackagePath)}\" -quit"
|
||||
};
|
||||
|
||||
if (!interactiveMode)
|
||||
processInfo.Arguments += " -batchmode";
|
||||
|
||||
@@ -200,7 +114,7 @@ namespace AssetStoreTools.Validator
|
||||
if (exitCode != 0)
|
||||
{
|
||||
result.Status = ValidationStatus.Failed;
|
||||
result.Error = $"Setting up the temporary project failed (exit code {exitCode})\n\nMore information can be found in the log file: {logFilePath}";
|
||||
result.Exception = new Exception($"Setting up the temporary project failed (exit code {exitCode})\n\nMore information can be found in the log file: {logFilePath}");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -210,15 +124,15 @@ namespace AssetStoreTools.Validator
|
||||
return result;
|
||||
}
|
||||
|
||||
private static ValidationResult ValidateTemporaryValidationProject(ValidationSettings settings, ValidationResult result, bool interactiveMode)
|
||||
private ValidationResult ValidateTemporaryValidationProject(ValidationResult result, bool interactiveMode)
|
||||
{
|
||||
EditorUtility.DisplayProgressBar("Validating...", "Performing validation...", 0.6f);
|
||||
|
||||
var logFilePath = $"{result.ProjectPath}/validation.log";
|
||||
var processInfo = new System.Diagnostics.ProcessStartInfo()
|
||||
{
|
||||
FileName = UnityPath,
|
||||
Arguments = $"-projectPath \"{result.ProjectPath}\" -logFile \"{logFilePath}\" -executeMethod AssetStoreTools.Validator.PackageValidator.ValidateProject -category \"{settings.Category}\""
|
||||
FileName = Constants.UnityPath,
|
||||
Arguments = $"-projectPath \"{result.ProjectPath}\" -logFile \"{logFilePath}\" -executeMethod AssetStoreTools.Validator.ExternalProjectValidator.ValidateProject -category \"{_settings.Category}\""
|
||||
};
|
||||
|
||||
if (!interactiveMode)
|
||||
@@ -235,7 +149,7 @@ namespace AssetStoreTools.Validator
|
||||
if (exitCode != 0)
|
||||
{
|
||||
result.Status = ValidationStatus.Failed;
|
||||
result.Error = $"Validating the temporary project failed (exit code {exitCode})\n\nMore information can be found in the log file: {logFilePath}";
|
||||
result.Exception = new Exception($"Validating the temporary project failed (exit code {exitCode})\n\nMore information can be found in the log file: {logFilePath}");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -244,7 +158,53 @@ namespace AssetStoreTools.Validator
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private ValidationResult ParseValidationResult(string externalProjectPath)
|
||||
{
|
||||
if (!CachingService.GetCachedValidatorStateData(externalProjectPath, out var validationStateData))
|
||||
throw new Exception("Could not find external project's validation results");
|
||||
|
||||
var cachedResult = validationStateData.GetResults();
|
||||
var cachedTestResults = cachedResult.GetResults();
|
||||
var tests = GetApplicableTests(ValidationType.Generic, ValidationType.UnityPackage);
|
||||
|
||||
foreach (var test in tests)
|
||||
{
|
||||
if (!cachedTestResults.Any(x => x.Key == test.Id))
|
||||
continue;
|
||||
|
||||
var matchingTest = cachedTestResults.First(x => x.Key == test.Id);
|
||||
test.Result = matchingTest.Value;
|
||||
}
|
||||
|
||||
var result = new ValidationResult()
|
||||
{
|
||||
Status = cachedResult.GetStatus(),
|
||||
HadCompilationErrors = cachedResult.GetHadCompilationErrors(),
|
||||
ProjectPath = cachedResult.GetProjectPath(),
|
||||
Tests = tests
|
||||
};
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void OpenExternalValidationProject(string projectPath)
|
||||
{
|
||||
var unityPath = Constants.UnityPath;
|
||||
var logFilePath = $"{projectPath}/editor.log";
|
||||
|
||||
var processInfo = new System.Diagnostics.ProcessStartInfo()
|
||||
{
|
||||
FileName = unityPath,
|
||||
Arguments = $"-projectPath \"{projectPath}\" -logFile \"{logFilePath}\" -executeMethod AssetStoreTools.AssetStoreTools.ShowAssetStoreToolsValidator"
|
||||
};
|
||||
|
||||
using (var process = System.Diagnostics.Process.Start(processInfo))
|
||||
{
|
||||
process.WaitForExit();
|
||||
}
|
||||
}
|
||||
|
||||
// Invoked via Command Line Arguments
|
||||
private static void ValidateProject()
|
||||
{
|
||||
@@ -270,14 +230,18 @@ namespace AssetStoreTools.Validator
|
||||
category = args[categoryIndex + 1];
|
||||
|
||||
// Run validation
|
||||
var validationSettings = new ValidationSettings()
|
||||
var validationSettings = new CurrentProjectValidationSettings()
|
||||
{
|
||||
Category = category,
|
||||
ValidationPaths = validationPaths,
|
||||
Category = category
|
||||
ValidationType = ValidationType.UnityPackage
|
||||
};
|
||||
Instance.RunAllTests(validationSettings);
|
||||
|
||||
AssetStoreTools.ShowAssetStoreToolsValidator();
|
||||
var validator = new CurrentProjectValidator(validationSettings);
|
||||
var result = validator.Validate();
|
||||
|
||||
// Display results
|
||||
AssetStoreTools.ShowAssetStoreToolsValidator(validationSettings, result);
|
||||
EditorUtility.DisplayDialog("Validation complete", "Package validation complete.\n\nTo resume work in the original project, close this Editor instance", "OK");
|
||||
}
|
||||
catch
|
||||
@@ -292,4 +256,4 @@ namespace AssetStoreTools.Validator
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2664bbca63a2444498f13beb7e4fa731
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/ExternalProjectValidator.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,11 @@
|
||||
using AssetStoreTools.Validator.Data;
|
||||
|
||||
namespace AssetStoreTools.Validator
|
||||
{
|
||||
internal interface IValidator
|
||||
{
|
||||
ValidationSettings Settings { get; }
|
||||
|
||||
ValidationResult Validate();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4fdc092edc6b5b049bdf5c59068cd3bf
|
||||
guid: d49e9393288e0ed418c546e57c4cb425
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -13,6 +13,6 @@ AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 11.4.4
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/AssetStoreValidator.cs
|
||||
uploadId: 712972
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/IValidator.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9315c4052243ab2488208604c11c53c7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0a52c1c4a2b7caa458af5b9a212b80a5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,55 @@
|
||||
using AssetStoreTools.Utility;
|
||||
using AssetStoreTools.Validator.UI.Data.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace AssetStoreTools.Validator.Services
|
||||
{
|
||||
internal class CachingService : ICachingService
|
||||
{
|
||||
public bool GetCachedValidatorStateData(out ValidatorStateData stateData)
|
||||
{
|
||||
return GetCachedValidatorStateData(Constants.RootProjectPath, out stateData);
|
||||
}
|
||||
|
||||
public bool GetCachedValidatorStateData(string projectPath, out ValidatorStateData stateData)
|
||||
{
|
||||
stateData = null;
|
||||
if (!CacheUtil.GetFileFromProjectPersistentCache(projectPath, Constants.Cache.ValidationResultFile, out var filePath))
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
var serializerSettings = new JsonSerializerSettings()
|
||||
{
|
||||
ContractResolver = ValidatorStateDataContractResolver.Instance,
|
||||
TypeNameHandling = TypeNameHandling.Auto,
|
||||
Converters = new List<JsonConverter>() { new StringEnumConverter() }
|
||||
};
|
||||
|
||||
stateData = JsonConvert.DeserializeObject<ValidatorStateData>(File.ReadAllText(filePath, Encoding.UTF8), serializerSettings);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void CacheValidatorStateData(ValidatorStateData stateData)
|
||||
{
|
||||
var serializerSettings = new JsonSerializerSettings()
|
||||
{
|
||||
ContractResolver = ValidatorStateDataContractResolver.Instance,
|
||||
Formatting = Formatting.Indented,
|
||||
TypeNameHandling = TypeNameHandling.Auto,
|
||||
Converters = new List<JsonConverter>() { new StringEnumConverter() }
|
||||
};
|
||||
|
||||
CacheUtil.CreateFileInPersistentCache(Constants.Cache.ValidationResultFile, JsonConvert.SerializeObject(stateData, serializerSettings), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b2d545f659acb4343bf485ffb20ecf72
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Services/CachingService/CachingService.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,11 @@
|
||||
using AssetStoreTools.Validator.UI.Data.Serialization;
|
||||
|
||||
namespace AssetStoreTools.Validator.Services
|
||||
{
|
||||
internal interface ICachingService : IValidatorService
|
||||
{
|
||||
void CacheValidatorStateData(ValidatorStateData stateData);
|
||||
bool GetCachedValidatorStateData(out ValidatorStateData stateData);
|
||||
bool GetCachedValidatorStateData(string projectPath, out ValidatorStateData stateData);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a8a3e36c133848447b043a91e709c63e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Services/CachingService/ICachingService.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,26 @@
|
||||
using Newtonsoft.Json.Serialization;
|
||||
|
||||
namespace AssetStoreTools.Previews.Services
|
||||
{
|
||||
internal class PreviewDatabaseContractResolver : DefaultContractResolver
|
||||
{
|
||||
private static PreviewDatabaseContractResolver _instance;
|
||||
public static PreviewDatabaseContractResolver Instance => _instance ?? (_instance = new PreviewDatabaseContractResolver());
|
||||
|
||||
private NamingStrategy _namingStrategy;
|
||||
|
||||
private PreviewDatabaseContractResolver()
|
||||
{
|
||||
_namingStrategy = new SnakeCaseNamingStrategy();
|
||||
}
|
||||
|
||||
protected override string ResolvePropertyName(string propertyName)
|
||||
{
|
||||
var resolvedName = _namingStrategy.GetPropertyName(propertyName, false);
|
||||
if (resolvedName.StartsWith("_"))
|
||||
return resolvedName.Substring(1);
|
||||
|
||||
return resolvedName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aee615e9aaf50fb4f989cd4698e8947e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Services/CachingService/PreviewDatabaseContractResolver.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,4 @@
|
||||
namespace AssetStoreTools.Validator.Services
|
||||
{
|
||||
internal interface IValidatorService { }
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 075953f4ab4a65d4fae6e891360df0d0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Services/IValidatorService.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 184dcfbfe1d21454fa8cf49f1c637871
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed0af5acc22551645ae4cb7d75bd1c36
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AssetStoreTools.Validator.Services.Validation
|
||||
{
|
||||
internal interface IAssetUtilityService : IValidatorService
|
||||
{
|
||||
IEnumerable<string> GetAssetPathsFromAssets(string[] searchPaths, AssetType type);
|
||||
IEnumerable<T> GetObjectsFromAssets<T>(string[] searchPaths, AssetType type) where T : Object;
|
||||
IEnumerable<Object> GetObjectsFromAssets(string[] searchPaths, AssetType type);
|
||||
string ObjectToAssetPath(Object obj);
|
||||
T AssetPathToObject<T>(string assetPath) where T : Object;
|
||||
Object AssetPathToObject(string assetPath);
|
||||
AssetImporter GetAssetImporter(string assetPath);
|
||||
AssetImporter GetAssetImporter(Object asset);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d28c5ea40f4c9954bae02804e416b898
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Services/Validation/Abstractions/IAssetUtilityService.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace AssetStoreTools.Validator.Services.Validation
|
||||
{
|
||||
internal interface IFileSignatureUtilityService : IValidatorService
|
||||
{
|
||||
ArchiveType GetArchiveType(string filePath);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 609c423482ecf8844a71166b4ef49cb6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Services/Validation/Abstractions/IFileSignatureUtilityService.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AssetStoreTools.Validator.Services.Validation
|
||||
{
|
||||
internal interface IMeshUtilityService : IValidatorService
|
||||
{
|
||||
IEnumerable<Mesh> GetCustomMeshesInObject(GameObject obj);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: acde6f9b97c9cac4b88a84aa9001a0fc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Services/Validation/Abstractions/IMeshUtilityService.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AssetStoreTools.Validator.Services.Validation
|
||||
{
|
||||
internal interface IModelUtilityService : IValidatorService
|
||||
{
|
||||
Dictionary<Object, List<LogEntry>> GetImportLogs(params Object[] models);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 91f6bacccdfecb84fb5ab0ba384353b4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Services/Validation/Abstractions/IModelUtilityService.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,13 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace AssetStoreTools.Validator.Services.Validation
|
||||
{
|
||||
internal interface ISceneUtilityService : IValidatorService
|
||||
{
|
||||
string CurrentScenePath { get; }
|
||||
|
||||
Scene OpenScene(string scenePath);
|
||||
GameObject[] GetRootGameObjects();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cf5ef331063e5aa4e95dfe3eadedf9af
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Services/Validation/Abstractions/ISceneUtilityService.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace AssetStoreTools.Validator.Services.Validation
|
||||
{
|
||||
internal interface IScriptUtilityService : IValidatorService
|
||||
{
|
||||
IReadOnlyDictionary<MonoScript, IList<(string Name, string Namespace)>> GetTypeNamespacesFromScriptAssets(IList<MonoScript> monoScripts);
|
||||
IReadOnlyDictionary<Object, IList<Type>> GetTypesFromAssemblies(IList<Object> assemblies);
|
||||
IReadOnlyDictionary<MonoScript, IList<Type>> GetTypesFromScriptAssets(IList<MonoScript> monoScripts);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e0a9f88d37222e4428853b6d3d00b1bd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Services/Validation/Abstractions/IScriptUtilityService.cs
|
||||
uploadId: 724584
|
||||
@@ -1,42 +1,18 @@
|
||||
using AssetStoreTools.Utility;
|
||||
using AssetStoreTools.Utility;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Compilation;
|
||||
using UnityEngine;
|
||||
using UnityObject = UnityEngine.Object;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace AssetStoreTools.Validator.TestMethods.Utility
|
||||
namespace AssetStoreTools.Validator.Services.Validation
|
||||
{
|
||||
internal enum AssetType
|
||||
internal class AssetUtilityService : IAssetUtilityService
|
||||
{
|
||||
All,
|
||||
Documentation,
|
||||
Executable,
|
||||
JPG,
|
||||
JavaScript,
|
||||
LossyAudio,
|
||||
Material,
|
||||
Mixamo,
|
||||
Model,
|
||||
MonoScript,
|
||||
NonLossyAudio,
|
||||
PrecompiledAssembly,
|
||||
Prefab,
|
||||
Scene,
|
||||
Shader,
|
||||
SpeedTree,
|
||||
Texture,
|
||||
UnityPackage,
|
||||
Video
|
||||
}
|
||||
|
||||
internal static class AssetUtility
|
||||
{
|
||||
public static IEnumerable<string> GetAssetPathsFromAssets(string[] searchPaths, AssetType type)
|
||||
public IEnumerable<string> GetAssetPathsFromAssets(string[] searchPaths, AssetType type)
|
||||
{
|
||||
string filter = string.Empty;
|
||||
string[] extensions = null;
|
||||
@@ -130,7 +106,7 @@ namespace AssetStoreTools.Validator.TestMethods.Utility
|
||||
return paths;
|
||||
}
|
||||
|
||||
public static IEnumerable<T> GetObjectsFromAssets<T>(string[] searchPaths, AssetType type) where T : UnityObject
|
||||
public IEnumerable<T> GetObjectsFromAssets<T>(string[] searchPaths, AssetType type) where T : Object
|
||||
{
|
||||
var paths = GetAssetPathsFromAssets(searchPaths, type);
|
||||
#if !AB_BUILDER
|
||||
@@ -141,12 +117,12 @@ namespace AssetStoreTools.Validator.TestMethods.Utility
|
||||
return objects;
|
||||
}
|
||||
|
||||
public static IEnumerable<UnityObject> GetObjectsFromAssets(string[] searchPaths, AssetType type)
|
||||
public IEnumerable<Object> GetObjectsFromAssets(string[] searchPaths, AssetType type)
|
||||
{
|
||||
return GetObjectsFromAssets<UnityObject>(searchPaths, type);
|
||||
return GetObjectsFromAssets<Object>(searchPaths, type);
|
||||
}
|
||||
|
||||
private static IEnumerable<string> GetPrecompiledAssemblies(string[] searchPaths)
|
||||
private IEnumerable<string> GetPrecompiledAssemblies(string[] searchPaths)
|
||||
{
|
||||
// Note - for packages, Compilation Pipeline returns full paths, as they appear on disk, not Asset Database
|
||||
var allDllPaths = CompilationPipeline.GetPrecompiledAssemblyPaths(CompilationPipeline.PrecompiledAssemblySources.UserAssembly);
|
||||
@@ -188,7 +164,7 @@ namespace AssetStoreTools.Validator.TestMethods.Utility
|
||||
return result;
|
||||
}
|
||||
|
||||
private static bool IsMixamoFbx(string fbxPath)
|
||||
private bool IsMixamoFbx(string fbxPath)
|
||||
{
|
||||
// Location of Mixamo Header, this is located in every mixamo fbx file exported
|
||||
//const int mixamoHeader = 0x4c0 + 2; // < this is the original location from A$ Tools, unsure if Mixamo file headers were changed since then
|
||||
@@ -212,105 +188,29 @@ namespace AssetStoreTools.Validator.TestMethods.Utility
|
||||
return result.Contains("Mixamo");
|
||||
}
|
||||
|
||||
public static string ObjectToAssetPath(UnityObject obj)
|
||||
public string ObjectToAssetPath(Object obj)
|
||||
{
|
||||
return AssetDatabase.GetAssetPath(obj);
|
||||
}
|
||||
|
||||
public static T AssetPathToObject<T>(string assetPath) where T : UnityObject
|
||||
public T AssetPathToObject<T>(string assetPath) where T : Object
|
||||
{
|
||||
return AssetDatabase.LoadAssetAtPath<T>(assetPath);
|
||||
}
|
||||
|
||||
public static UnityObject AssetPathToObject(string assetPath)
|
||||
public Object AssetPathToObject(string assetPath)
|
||||
{
|
||||
return AssetPathToObject<UnityObject>(assetPath);
|
||||
return AssetPathToObject<Object>(assetPath);
|
||||
}
|
||||
|
||||
public static AssetImporter GetAssetImporter(string assetPath)
|
||||
public AssetImporter GetAssetImporter(string assetPath)
|
||||
{
|
||||
return AssetImporter.GetAtPath(assetPath);
|
||||
}
|
||||
|
||||
public static AssetImporter GetAssetImporter(UnityObject asset)
|
||||
public AssetImporter GetAssetImporter(Object asset)
|
||||
{
|
||||
return GetAssetImporter(ObjectToAssetPath(asset));
|
||||
}
|
||||
}
|
||||
|
||||
internal class AssetEnumerator<T> : IEnumerator<T>, IEnumerable<T> where T : UnityObject
|
||||
{
|
||||
public const int Capacity = 32;
|
||||
|
||||
private Queue<string> _pathQueue;
|
||||
private Queue<T> _loadedAssetQueue;
|
||||
|
||||
private T _currentElement;
|
||||
|
||||
public AssetEnumerator(IEnumerable<string> paths)
|
||||
{
|
||||
_pathQueue = new Queue<string>(paths);
|
||||
_loadedAssetQueue = new Queue<T>();
|
||||
}
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
bool hasPathsButHasNoAssets = _pathQueue.Count != 0 && _loadedAssetQueue.Count == 0;
|
||||
if (hasPathsButHasNoAssets)
|
||||
{
|
||||
LoadMore();
|
||||
}
|
||||
|
||||
bool dequeued = false;
|
||||
if (_loadedAssetQueue.Count != 0)
|
||||
{
|
||||
_currentElement = _loadedAssetQueue.Dequeue();
|
||||
dequeued = true;
|
||||
}
|
||||
|
||||
return dequeued;
|
||||
}
|
||||
|
||||
private void LoadMore()
|
||||
{
|
||||
int limit = Capacity;
|
||||
while (limit > 0 && _pathQueue.Count != 0)
|
||||
{
|
||||
string path = _pathQueue.Dequeue();
|
||||
T asset = AssetDatabase.LoadAssetAtPath<T>(path);
|
||||
if (asset != null)
|
||||
{
|
||||
_loadedAssetQueue.Enqueue(asset);
|
||||
limit--;
|
||||
}
|
||||
}
|
||||
|
||||
// Unload other loose asset references
|
||||
EditorUtility.UnloadUnusedAssetsImmediate();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
throw new NotSupportedException("Asset Enumerator cannot be reset.");
|
||||
}
|
||||
|
||||
public T Current => _currentElement;
|
||||
|
||||
object IEnumerator.Current => Current;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// No need to dispose
|
||||
}
|
||||
|
||||
IEnumerator<T> IEnumerable<T>.GetEnumerator()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
public IEnumerator GetEnumerator()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9634968648d355c47b7cb12aead7abab
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Services/Validation/AssetUtilityService.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8dcc2f4da0b6cea4ab4733ebf32edab4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,19 @@
|
||||
namespace AssetStoreTools.Validator.Services.Validation
|
||||
{
|
||||
internal enum ArchiveType
|
||||
{
|
||||
None,
|
||||
TarGz,
|
||||
Zip,
|
||||
Rar,
|
||||
Tar,
|
||||
TarZip,
|
||||
Bz2,
|
||||
LZip,
|
||||
SevenZip,
|
||||
GZip,
|
||||
QuickZip,
|
||||
Xz,
|
||||
Wim
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4061cb7aed3883346a66494c23e2e77b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Services/Validation/Data/ArchiveType.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace AssetStoreTools.Validator.Services.Validation
|
||||
{
|
||||
internal class AssetEnumerator<T> : IEnumerator<T>, IEnumerable<T> where T : Object
|
||||
{
|
||||
public const int Capacity = 32;
|
||||
|
||||
private Queue<string> _pathQueue;
|
||||
private Queue<T> _loadedAssetQueue;
|
||||
|
||||
private T _currentElement;
|
||||
|
||||
public AssetEnumerator(IEnumerable<string> paths)
|
||||
{
|
||||
_pathQueue = new Queue<string>(paths);
|
||||
_loadedAssetQueue = new Queue<T>();
|
||||
}
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
bool hasPathsButHasNoAssets = _pathQueue.Count != 0 && _loadedAssetQueue.Count == 0;
|
||||
if (hasPathsButHasNoAssets)
|
||||
{
|
||||
LoadMore();
|
||||
}
|
||||
|
||||
bool dequeued = false;
|
||||
if (_loadedAssetQueue.Count != 0)
|
||||
{
|
||||
_currentElement = _loadedAssetQueue.Dequeue();
|
||||
dequeued = true;
|
||||
}
|
||||
|
||||
return dequeued;
|
||||
}
|
||||
|
||||
private void LoadMore()
|
||||
{
|
||||
int limit = Capacity;
|
||||
while (limit > 0 && _pathQueue.Count != 0)
|
||||
{
|
||||
string path = _pathQueue.Dequeue();
|
||||
T asset = AssetDatabase.LoadAssetAtPath<T>(path);
|
||||
if (asset != null)
|
||||
{
|
||||
_loadedAssetQueue.Enqueue(asset);
|
||||
limit--;
|
||||
}
|
||||
}
|
||||
|
||||
// Unload other loose asset references
|
||||
EditorUtility.UnloadUnusedAssetsImmediate();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
throw new NotSupportedException("Asset Enumerator cannot be reset.");
|
||||
}
|
||||
|
||||
public T Current => _currentElement;
|
||||
|
||||
object IEnumerator.Current => Current;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// No need to dispose
|
||||
}
|
||||
|
||||
IEnumerator<T> IEnumerable<T>.GetEnumerator()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
public IEnumerator GetEnumerator()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0859579889cc56f4aa26eb863a1487b9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Services/Validation/Data/AssetEnumerator.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,25 @@
|
||||
namespace AssetStoreTools.Validator.Services.Validation
|
||||
{
|
||||
internal enum AssetType
|
||||
{
|
||||
All,
|
||||
Documentation,
|
||||
Executable,
|
||||
JPG,
|
||||
JavaScript,
|
||||
LossyAudio,
|
||||
Material,
|
||||
Mixamo,
|
||||
Model,
|
||||
MonoScript,
|
||||
NonLossyAudio,
|
||||
PrecompiledAssembly,
|
||||
Prefab,
|
||||
Scene,
|
||||
Shader,
|
||||
SpeedTree,
|
||||
Texture,
|
||||
UnityPackage,
|
||||
Video
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b81d00d4ed0a7da4289d4d6248ef9d34
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Services/Validation/Data/AssetType.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,10 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace AssetStoreTools.Validator.Services.Validation
|
||||
{
|
||||
internal class LogEntry
|
||||
{
|
||||
public string Message;
|
||||
public LogType Severity;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a1e81104d6b0f4c449ee57503c3b6669
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Services/Validation/Data/LogEntry.cs
|
||||
uploadId: 724584
|
||||
@@ -1,14 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AssetStoreTools.Validator.TestMethods.Utility
|
||||
namespace AssetStoreTools.Validator.Services.Validation
|
||||
{
|
||||
/// <summary>
|
||||
/// Class for identifying file types by reading file signatures
|
||||
/// </summary>
|
||||
internal static class FileSignatureUtility
|
||||
internal class FileSignatureUtilityService : IFileSignatureUtilityService
|
||||
{
|
||||
private class FileSignature
|
||||
{
|
||||
@@ -22,23 +19,6 @@ namespace AssetStoreTools.Validator.TestMethods.Utility
|
||||
}
|
||||
}
|
||||
|
||||
public enum ArchiveType
|
||||
{
|
||||
None,
|
||||
TarGz,
|
||||
Zip,
|
||||
Rar,
|
||||
Tar,
|
||||
TarZip,
|
||||
Bz2,
|
||||
LZip,
|
||||
SevenZip,
|
||||
GZip,
|
||||
QuickZip,
|
||||
Xz,
|
||||
Wim
|
||||
}
|
||||
|
||||
private static readonly Dictionary<FileSignature, ArchiveType> ArchiveSignatures = new Dictionary<FileSignature, ArchiveType>
|
||||
{
|
||||
{ new FileSignature(new byte[] { 0x1f, 0x8b }, 0), ArchiveType.TarGz },
|
||||
@@ -61,7 +41,7 @@ namespace AssetStoreTools.Validator.TestMethods.Utility
|
||||
{ new FileSignature(new byte[] { 0x4D, 0x53, 0x57, 0x49, 0x4D, 0x00, 0x00, 0x00, 0xD0, 0x00, 0x00, 0x00, 0x00 }, 0), ArchiveType.Wim }
|
||||
};
|
||||
|
||||
public static ArchiveType GetArchiveType(string filePath)
|
||||
public ArchiveType GetArchiveType(string filePath)
|
||||
{
|
||||
if (!File.Exists(filePath))
|
||||
return ArchiveType.None;
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 695ed79ad88c3b44b8ae41b650ebe16c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Services/Validation/FileSignatureUtilityService.cs
|
||||
uploadId: 724584
|
||||
@@ -1,13 +1,13 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AssetStoreTools.Validator.TestMethods.Utility
|
||||
namespace AssetStoreTools.Validator.Services.Validation
|
||||
{
|
||||
internal static class MeshUtility
|
||||
internal class MeshUtilityService : IMeshUtilityService
|
||||
{
|
||||
public static IEnumerable<Mesh> GetCustomMeshesInObject(GameObject obj)
|
||||
public IEnumerable<Mesh> GetCustomMeshesInObject(GameObject obj)
|
||||
{
|
||||
var meshes = new List<Mesh>();
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 307f5dd7be983e246adbda52ac50ecf3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Services/Validation/MeshUtilityService.cs
|
||||
uploadId: 724584
|
||||
@@ -1,21 +1,21 @@
|
||||
#if !UNITY_2022_2_OR_NEWER
|
||||
using System;
|
||||
using System.Reflection;
|
||||
#endif
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
#if UNITY_2022_2_OR_NEWER
|
||||
using UnityEditor.AssetImporters;
|
||||
#endif
|
||||
using UnityEngine;
|
||||
using UnityObject = UnityEngine.Object;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace AssetStoreTools.Validator.TestMethods.Utility
|
||||
namespace AssetStoreTools.Validator.Services.Validation
|
||||
{
|
||||
internal static class ModelUtility
|
||||
internal class ModelUtilityService : IModelUtilityService
|
||||
{
|
||||
public class LogEntry
|
||||
{
|
||||
public string Message;
|
||||
public LogType Severity;
|
||||
}
|
||||
private IAssetUtilityService _assetUtility;
|
||||
|
||||
#if !UNITY_2022_2_OR_NEWER
|
||||
// Rig fields
|
||||
@@ -29,7 +29,12 @@ namespace AssetStoreTools.Validator.TestMethods.Utility
|
||||
private static Editor _modelImporterEditor = null;
|
||||
#endif
|
||||
|
||||
public static Dictionary<UnityObject, List<LogEntry>> GetImportLogs(params UnityObject[] models)
|
||||
public ModelUtilityService(IAssetUtilityService assetUtility)
|
||||
{
|
||||
_assetUtility = assetUtility;
|
||||
}
|
||||
|
||||
public Dictionary<Object, List<LogEntry>> GetImportLogs(params Object[] models)
|
||||
{
|
||||
#if UNITY_2022_2_OR_NEWER
|
||||
return GetImportLogsDefault(models);
|
||||
@@ -39,15 +44,15 @@ namespace AssetStoreTools.Validator.TestMethods.Utility
|
||||
}
|
||||
|
||||
#if UNITY_2022_2_OR_NEWER
|
||||
private static Dictionary<UnityObject, List<LogEntry>> GetImportLogsDefault(params UnityObject[] models)
|
||||
private Dictionary<Object, List<LogEntry>> GetImportLogsDefault(params Object[] models)
|
||||
{
|
||||
var modelsWithLogs = new Dictionary<UnityObject, List<LogEntry>>();
|
||||
var modelsWithLogs = new Dictionary<Object, List<LogEntry>>();
|
||||
|
||||
foreach (var model in models)
|
||||
{
|
||||
var modelLogs = new List<LogEntry>();
|
||||
|
||||
var importLog = AssetImporter.GetImportLog(AssetUtility.ObjectToAssetPath(model));
|
||||
var importLog = AssetImporter.GetImportLog(_assetUtility.ObjectToAssetPath(model));
|
||||
|
||||
if (importLog == null)
|
||||
continue;
|
||||
@@ -68,24 +73,23 @@ namespace AssetStoreTools.Validator.TestMethods.Utility
|
||||
#endif
|
||||
|
||||
#if !UNITY_2022_2_OR_NEWER
|
||||
|
||||
private static Dictionary<UnityObject, List<LogEntry>> GetImportLogsLegacy(params UnityObject[] models)
|
||||
private Dictionary<Object, List<LogEntry>> GetImportLogsLegacy(params Object[] models)
|
||||
{
|
||||
var modelsWithLogs = new Dictionary<UnityObject, List<LogEntry>>();
|
||||
var modelsWithLogs = new Dictionary<Object, List<LogEntry>>();
|
||||
|
||||
foreach (var model in models)
|
||||
{
|
||||
var modelLogs = new List<LogEntry>();
|
||||
|
||||
// Load the Model Importer
|
||||
var modelImporter = AssetUtility.GetAssetImporter(model) as ModelImporter;
|
||||
var modelImporter = _assetUtility.GetAssetImporter(model) as ModelImporter;
|
||||
|
||||
var editorAssembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(x => x.GetName().Name.Equals("UnityEditor"));
|
||||
|
||||
var modelImporterEditorType = editorAssembly.GetType("UnityEditor.ModelImporterEditor");
|
||||
|
||||
// Load its Model Importer Editor
|
||||
Editor.CreateCachedEditorWithContext(new UnityObject[] { modelImporter }, model, modelImporterEditorType, ref _modelImporterEditor);
|
||||
Editor.CreateCachedEditorWithContext(new Object[] { modelImporter }, model, modelImporterEditorType, ref _modelImporterEditor);
|
||||
|
||||
// Find the base type
|
||||
var modelImporterEditorTypeBase = _modelImporterEditor.GetType().BaseType;
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c50ca4c87e66f1b478279e5d1db4a08e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Services/Validation/ModelUtilityService.cs
|
||||
uploadId: 724584
|
||||
@@ -1,15 +1,15 @@
|
||||
using UnityEditor;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace AssetStoreTools.Validator.TestMethods.Utility
|
||||
{
|
||||
internal static class SceneUtility
|
||||
namespace AssetStoreTools.Validator.Services.Validation
|
||||
{
|
||||
internal class SceneUtilityService : ISceneUtilityService
|
||||
{
|
||||
public static string CurrentScenePath => SceneManager.GetActiveScene().path;
|
||||
public string CurrentScenePath => SceneManager.GetActiveScene().path;
|
||||
|
||||
public static Scene OpenScene(string scenePath)
|
||||
public Scene OpenScene(string scenePath)
|
||||
{
|
||||
EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo();
|
||||
if (string.IsNullOrEmpty(scenePath) || AssetDatabase.LoadAssetAtPath<SceneAsset>(scenePath) == null)
|
||||
@@ -18,7 +18,7 @@ namespace AssetStoreTools.Validator.TestMethods.Utility
|
||||
return EditorSceneManager.OpenScene(scenePath);
|
||||
}
|
||||
|
||||
public static GameObject[] GetRootGameObjects()
|
||||
public GameObject[] GetRootGameObjects()
|
||||
{
|
||||
return SceneManager.GetSceneByPath(CurrentScenePath).GetRootGameObjects();
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 53e8deb0ebfb7ea47956f3a859580cd4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Services/Validation/SceneUtilityService.cs
|
||||
uploadId: 724584
|
||||
@@ -3,17 +3,16 @@ using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEditor;
|
||||
using UnityObject = UnityEngine.Object;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace AssetStoreTools.Validator.TestMethods.Utility
|
||||
namespace AssetStoreTools.Validator.Services.Validation
|
||||
{
|
||||
internal static class ScriptUtility
|
||||
internal class ScriptUtilityService : IScriptUtilityService
|
||||
{
|
||||
private const int ScriptTimeoutMs = 10000;
|
||||
private const string IgnoredAssemblyCharacters = "!@#$%^*&()-+=[]{}\\|;:'\",.<>/?";
|
||||
@@ -25,12 +24,12 @@ namespace AssetStoreTools.Validator.TestMethods.Utility
|
||||
/// <returns>A dictionary mapping each script asset with a list of its types.
|
||||
/// The type tuple contains a name (e.g. <i>class MyClass</i>) and its namespace (e.g. <i>MyNamespace</i>)
|
||||
/// </returns>
|
||||
public static IReadOnlyDictionary<MonoScript, IList<(string Name, string Namespace)>> GetTypeNamespacesFromScriptAssets(IList<MonoScript> monoScripts)
|
||||
public IReadOnlyDictionary<MonoScript, IList<(string Name, string Namespace)>> GetTypeNamespacesFromScriptAssets(IList<MonoScript> monoScripts)
|
||||
{
|
||||
var typesAndNamespaces = new Dictionary<MonoScript, IList<(string Name, string Namespace)>>();
|
||||
var typeInfos = GetTypeInfosFromScriptAssets(monoScripts);
|
||||
|
||||
foreach(var kvp in typeInfos)
|
||||
foreach (var kvp in typeInfos)
|
||||
{
|
||||
var namespacesInScript = new List<(string Name, string Namespace)>();
|
||||
foreach (var typeInfo in kvp.Value)
|
||||
@@ -53,10 +52,10 @@ namespace AssetStoreTools.Validator.TestMethods.Utility
|
||||
/// </summary>
|
||||
/// <param name="assemblies"></param>
|
||||
/// <returns>A dictionary mapping each precompiled assembly asset with a list of <see cref="Type"> System.Type </see> objects.</returns>
|
||||
public static IReadOnlyDictionary<UnityObject, IList<Type>> GetTypesFromAssemblies(IList<UnityObject> assemblies)
|
||||
public IReadOnlyDictionary<Object, IList<Type>> GetTypesFromAssemblies(IList<Object> assemblies)
|
||||
{
|
||||
var dllPaths = assemblies.ToDictionary(t => AssetDatabase.GetAssetPath(t), t => t);
|
||||
var types = new ConcurrentDictionary<UnityObject, IList<Type>>();
|
||||
var types = new ConcurrentDictionary<Object, IList<Type>>();
|
||||
var failedDllPaths = new ConcurrentBag<string>();
|
||||
|
||||
var allAssemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||
@@ -89,7 +88,7 @@ namespace AssetStoreTools.Validator.TestMethods.Utility
|
||||
|
||||
// Types are sorted randomly due to parallelism, therefore need to be sorted before returning
|
||||
var sortedTypes = dllPaths.Where(x => types.ContainsKey(x.Value))
|
||||
.Select(x => new KeyValuePair<UnityObject, IList<Type>>(x.Value, types[x.Value]))
|
||||
.Select(x => new KeyValuePair<Object, IList<Type>>(x.Value, types[x.Value]))
|
||||
.ToDictionary(t => t.Key, t => t.Value);
|
||||
|
||||
return sortedTypes;
|
||||
@@ -100,7 +99,7 @@ namespace AssetStoreTools.Validator.TestMethods.Utility
|
||||
/// </summary>
|
||||
/// <param name="monoScripts"></param>
|
||||
/// <returns>A dictionary mapping each precompiled assembly asset with a list of <see cref="Type"> System.Type </see> objects.</returns>
|
||||
public static IReadOnlyDictionary<MonoScript, IList<Type>> GetTypesFromScriptAssets(IList<MonoScript> monoScripts)
|
||||
public IReadOnlyDictionary<MonoScript, IList<Type>> GetTypesFromScriptAssets(IList<MonoScript> monoScripts)
|
||||
{
|
||||
var realTypes = new Dictionary<MonoScript, IList<Type>>();
|
||||
var typeInfos = GetTypeInfosFromScriptAssets(monoScripts);
|
||||
@@ -134,7 +133,7 @@ namespace AssetStoreTools.Validator.TestMethods.Utility
|
||||
/// </summary>
|
||||
/// <param name="monoScripts"></param>
|
||||
/// <returns>A dictionary mapping each script asset with a list of <see cref="TypeInfo"> TypeInfo </see> objects. </returns>
|
||||
private static IReadOnlyDictionary<MonoScript, IList<ScriptParser.BlockInfo>> GetTypeInfosFromScriptAssets(IList<MonoScript> monoScripts)
|
||||
private IReadOnlyDictionary<MonoScript, IList<ScriptParser.BlockInfo>> GetTypeInfosFromScriptAssets(IList<MonoScript> monoScripts)
|
||||
{
|
||||
var types = new ConcurrentDictionary<MonoScript, IList<ScriptParser.BlockInfo>>();
|
||||
var monoScriptContents = new Dictionary<MonoScript, string>();
|
||||
@@ -351,14 +350,14 @@ namespace AssetStoreTools.Validator.TestMethods.Utility
|
||||
}
|
||||
}
|
||||
// Char code
|
||||
else if(sb[i] == '\'')
|
||||
else if (sb[i] == '\'')
|
||||
{
|
||||
for(int j = i + 1; j < sb.Length; j++)
|
||||
for (int j = i + 1; j < sb.Length; j++)
|
||||
{
|
||||
_token.ThrowIfCancellationRequested();
|
||||
if(sb[j] == '\'')
|
||||
if (sb[j] == '\'')
|
||||
{
|
||||
if(sb[j - 1] == '\\')
|
||||
if (sb[j - 1] == '\\')
|
||||
{
|
||||
int slashCount = 0;
|
||||
int k = j - 1;
|
||||
@@ -366,7 +365,7 @@ namespace AssetStoreTools.Validator.TestMethods.Utility
|
||||
slashCount++;
|
||||
if (slashCount % 2 != 0)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
removeRanges.Add(new Tuple<int, int>(i, j - i + 1));
|
||||
i = j;
|
||||
break;
|
||||
@@ -456,10 +455,10 @@ namespace AssetStoreTools.Validator.TestMethods.Utility
|
||||
else if (IsRegion(i))
|
||||
{
|
||||
i += "#region".Length;
|
||||
for(int j = i; j < sb.Length; j++)
|
||||
for (int j = i; j < sb.Length; j++)
|
||||
{
|
||||
_token.ThrowIfCancellationRequested();
|
||||
if(sb[j] == '\n')
|
||||
if (sb[j] == '\n')
|
||||
{
|
||||
removeRanges.Add(new Tuple<int, int>(i, j - i + 1));
|
||||
i = j;
|
||||
@@ -516,7 +515,7 @@ namespace AssetStoreTools.Validator.TestMethods.Utility
|
||||
currentActiveBlock = closestBlock;
|
||||
break;
|
||||
case var _ when closestBlock == nextIdentationDecrease:
|
||||
if(currentActiveBlock.TypeName != TypeName.Undefined)
|
||||
if (currentActiveBlock.TypeName != TypeName.Undefined)
|
||||
typeList.Add(currentActiveBlock.StartIndex, currentActiveBlock);
|
||||
currentActiveBlock = currentActiveBlock.ParentBlock;
|
||||
break;
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9db4298044e2add44bc3aa6ba898d7c3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Services/Validation/ScriptUtilityService.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,24 @@
|
||||
using AssetStoreTools.Utility;
|
||||
using AssetStoreTools.Validator.Services.Validation;
|
||||
|
||||
namespace AssetStoreTools.Validator.Services
|
||||
{
|
||||
internal class ValidatorServiceProvider : ServiceProvider<IValidatorService>
|
||||
{
|
||||
public static ValidatorServiceProvider Instance => _instance ?? (_instance = new ValidatorServiceProvider());
|
||||
private static ValidatorServiceProvider _instance;
|
||||
|
||||
private ValidatorServiceProvider() { }
|
||||
|
||||
protected override void RegisterServices()
|
||||
{
|
||||
Register<ICachingService, CachingService>();
|
||||
Register<IAssetUtilityService, AssetUtilityService>();
|
||||
Register<IFileSignatureUtilityService, FileSignatureUtilityService>();
|
||||
Register<IMeshUtilityService, MeshUtilityService>();
|
||||
Register<IModelUtilityService, ModelUtilityService>();
|
||||
Register<ISceneUtilityService, SceneUtilityService>();
|
||||
Register<IScriptUtilityService, ScriptUtilityService>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 47ac495c61171824abb2b72b1b7ef676
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Services/ValidatorServiceProvider.cs
|
||||
uploadId: 724584
|
||||
@@ -1,6 +1,9 @@
|
||||
using AssetStoreTools.Validator.Data;
|
||||
using AssetStoreTools.Validator.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AssetStoreTools.Validator.TestDefinitions
|
||||
@@ -9,39 +12,110 @@ namespace AssetStoreTools.Validator.TestDefinitions
|
||||
{
|
||||
public AutomatedTest(ValidationTestScriptableObject source) : base(source) { }
|
||||
|
||||
public override void Run(ValidationTestConfig config)
|
||||
public override void Run(ITestConfig config)
|
||||
{
|
||||
Type testClass;
|
||||
if (TestScript == null || (testClass = TestScript.GetClass()) == null)
|
||||
Type testClass = null;
|
||||
MethodInfo testMethod = null;
|
||||
|
||||
try
|
||||
{
|
||||
Debug.LogError($"Cannot run test {Title} - Test Script class was not found");
|
||||
ValidateTestMethod(ref testClass, ref testMethod);
|
||||
ValidateConfig(config);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError(e.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!testClass.GetInterfaces().Contains(typeof(ITestScript)))
|
||||
object testClassInstance;
|
||||
try
|
||||
{
|
||||
Debug.LogError($"Cannot run test {Title} - Test Script class is not derived from {nameof(ITestScript)}");
|
||||
return;
|
||||
testClassInstance = CreateInstance(testClass, config);
|
||||
}
|
||||
|
||||
var testMethod = testClass.GetMethod("Run");
|
||||
if (testMethod == null)
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"Cannot run test {Title} - Run() method was not found");
|
||||
Debug.LogError($"Could not create an instance of class {testClass}:\n{e}");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Result = (TestResult)testMethod.Invoke(Activator.CreateInstance(testClass), new[] { config });
|
||||
Result = (TestResult)testMethod.Invoke(testClassInstance, new object[0]);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
var result = new TestResult() { Result = TestResult.ResultStatus.Undefined };
|
||||
var result = new TestResult() { Status = TestResultStatus.Undefined };
|
||||
result.AddMessage("An exception was caught when running this test case. See Console for more details");
|
||||
Debug.LogError($"An exception was caught when running validation for test case '{Title}'\n{e.InnerException}");
|
||||
Debug.LogError($"An exception was caught when running validation for test case '{Title}'\n{e}");
|
||||
Result = result;
|
||||
}
|
||||
}
|
||||
|
||||
private void ValidateTestMethod(ref Type testClass, ref MethodInfo testMethod)
|
||||
{
|
||||
if (TestScript == null || (testClass = TestScript.GetClass()) == null)
|
||||
throw new Exception($"Cannot run test {Title} - Test Script class was not found");
|
||||
|
||||
var interfaces = testClass.GetInterfaces();
|
||||
if (!interfaces.Contains(typeof(ITestScript)))
|
||||
throw new Exception($"Cannot run test {Title} - Test Script class is not derived from {nameof(ITestScript)}");
|
||||
|
||||
testMethod = testClass.GetMethod("Run");
|
||||
if (testMethod == null)
|
||||
throw new Exception($"Cannot run test {Title} - Run() method was not found");
|
||||
}
|
||||
|
||||
private void ValidateConfig(ITestConfig config)
|
||||
{
|
||||
switch (ValidationType)
|
||||
{
|
||||
case ValidationType.Generic:
|
||||
case ValidationType.UnityPackage:
|
||||
if (config is GenericTestConfig)
|
||||
return;
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedException("Undefined validation type");
|
||||
}
|
||||
|
||||
throw new Exception("Config does not match the validation type");
|
||||
}
|
||||
|
||||
private object CreateInstance(Type testClass, ITestConfig testConfig)
|
||||
{
|
||||
var constructors = testClass.GetConstructors();
|
||||
if (constructors.Length != 1)
|
||||
throw new Exception($"Test class {testClass} should only contain a single constructor");
|
||||
|
||||
var constructor = constructors[0];
|
||||
var expectedParameters = constructor.GetParameters();
|
||||
var parametersToUse = new List<object>();
|
||||
foreach (var expectedParam in expectedParameters)
|
||||
{
|
||||
var paramType = expectedParam.ParameterType;
|
||||
|
||||
if (paramType == testConfig.GetType())
|
||||
{
|
||||
parametersToUse.Add(testConfig);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (typeof(IValidatorService).IsAssignableFrom(paramType))
|
||||
{
|
||||
var matchingService = ValidatorServiceProvider.Instance.GetService(paramType);
|
||||
if (matchingService == null)
|
||||
throw new Exception($"Service {paramType} is not registered and could not be retrieved");
|
||||
|
||||
parametersToUse.Add(matchingService);
|
||||
continue;
|
||||
}
|
||||
|
||||
throw new Exception($"Invalid parameter type: {paramType}");
|
||||
}
|
||||
|
||||
var instance = constructor.Invoke(parametersToUse.ToArray());
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,6 @@ AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 11.4.4
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Test Definitions/AutomatedTest.cs
|
||||
uploadId: 712972
|
||||
uploadId: 724584
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace AssetStoreTools.Validator.TestDefinitions
|
||||
{
|
||||
internal class GenericTestConfig : ITestConfig
|
||||
{
|
||||
public string[] ValidationPaths { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ba1ae4e7b45a6c84ca8ad0eb391bf95d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/Test Definitions/GenericTestConfig.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,4 @@
|
||||
namespace AssetStoreTools.Validator.TestDefinitions
|
||||
{
|
||||
internal interface ITestConfig { }
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user