1
0
mirror of https://github.com/maxartz15/Validator.git synced 2025-06-25 19:16:06 +02:00

Base validator

SceneValidator & AssetValidator of objects that implement IValidatable.
This commit is contained in:
max
2021-12-27 00:52:50 +01:00
parent 071e15c2be
commit 4b9b5a8c1d
38 changed files with 762 additions and 129 deletions

9
Runtime/IValidatable.cs Normal file
View File

@ -0,0 +1,9 @@
namespace Validator
{
public interface IValidatable
{
#if UNITY_EDITOR
public void Validate(Report report);
#endif
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9745876369d865247b2bae9393491734
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

60
Runtime/Report.cs Normal file
View File

@ -0,0 +1,60 @@
using System.Collections.Generic;
using UnityEngine;
namespace Validator
{
public enum WarningType
{
Info,
Warning,
Error,
}
public class Report
{
public struct ReportMessage
{
public Object Target => target;
public WarningType WarningType => warningType;
public string Category => category;
public string Message => message;
public string Solution => solution;
private readonly Object target;
private readonly WarningType warningType;
private readonly string category;
private readonly string message;
private readonly string solution;
public ReportMessage(Object target, WarningType warningLevel, string category, string message, string solution)
{
this.target = target;
this.warningType = warningLevel;
this.category = category;
this.message = message;
this.solution = solution;
}
}
public string Name => name;
public IList<ReportMessage> Reports => reports.AsReadOnly();
private readonly string name;
private readonly List<ReportMessage> reports = new List<ReportMessage>();
public Report(string name)
{
this.name = name;
}
public void Log(ReportMessage report)
{
reports.Add(report);
}
public void Log(Object target, WarningType warningType, string category, string message, string solution)
{
Log(new ReportMessage(target, warningType, category, message, solution));
}
}
}

11
Runtime/Report.cs.meta Normal file
View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d39518e0aab78db47adc586ce678d8a9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
namespace Validator
{
public static partial class ReportCategories
{
public const string Art = "Art";
public const string Design = "Design";
public const string Code = "Code";
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d2016a6a28d54304ea9cd64801c4f0b9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,5 +0,0 @@
using UnityEngine;
namespace COMPANYNAME.PACKAGENAME
{
}

View File

@ -1,5 +1,6 @@
{
"name": "COMPANYNAME.PACKAGENAME",
"name": "VertexColor.Validator",
"rootNamespace": "Validator",
"references": [],
"includePlatforms": [],
"excludePlatforms": [],
@ -8,5 +9,6 @@
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": []
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 334c4fbff44e0f9439f29f9d8e0ce6e9
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: