update libs
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9e4a4a4aa3f501847b1abb1e08505f9b
|
||||
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/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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d51c5c866dcd449488caa10a40dd3301
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user