Added initial version 0.1.0
This commit is contained in:
parent
6aa4cb8596
commit
416759c213
64 changed files with 2181 additions and 0 deletions
8
Runtime/Attributes.meta
Normal file
8
Runtime/Attributes.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b550bfeed6d6bb840972d41daa80bbd3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
29
Runtime/Attributes/RequiredAttribute.cs
Normal file
29
Runtime/Attributes/RequiredAttribute.cs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
using System;
|
||||
|
||||
namespace Module.ProjectValidator
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)]
|
||||
public sealed class RequiredAttribute : Attribute
|
||||
{
|
||||
private readonly EValidatorSeverity _severity;
|
||||
|
||||
public RequiredAttribute()
|
||||
{
|
||||
_severity = EValidatorSeverity.Error;
|
||||
}
|
||||
|
||||
public RequiredAttribute(EValidatorSeverity severity)
|
||||
{
|
||||
_severity = severity;
|
||||
}
|
||||
|
||||
public sealed class Validator : IAttributeValidator<RequiredAttribute>
|
||||
{
|
||||
public ValidatorResult Validate(RequiredAttribute attribute, object value)
|
||||
{
|
||||
var isValid = value is UnityEngine.Object obj ? obj != null : value != null;
|
||||
return isValid ? ValidatorResult.Valid : ValidatorResult.Create(attribute._severity, "Value is Null");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Runtime/Attributes/RequiredAttribute.cs.meta
Normal file
2
Runtime/Attributes/RequiredAttribute.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 752bd3df42129e14cadaf285192455f4
|
||||
3
Runtime/Enums.meta
Normal file
3
Runtime/Enums.meta
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 685f49487d6444309a65fbcd4ac1d9ea
|
||||
timeCreated: 1778923761
|
||||
11
Runtime/Enums/EValidatorSeverity.cs
Normal file
11
Runtime/Enums/EValidatorSeverity.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
namespace Module.ProjectValidator
|
||||
{
|
||||
public enum EValidatorSeverity
|
||||
{
|
||||
Valid,
|
||||
Warning,
|
||||
Error,
|
||||
|
||||
MaxSeverityLevel = Error
|
||||
}
|
||||
}
|
||||
3
Runtime/Enums/EValidatorSeverity.cs.meta
Normal file
3
Runtime/Enums/EValidatorSeverity.cs.meta
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cd13ba3b13bf430d991895f3f53092b5
|
||||
timeCreated: 1778923771
|
||||
3
Runtime/Interfaces.meta
Normal file
3
Runtime/Interfaces.meta
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: efe01ae1b17d4d859c2a5b16037b83ba
|
||||
timeCreated: 1778923730
|
||||
9
Runtime/Interfaces/IAttributeValidator.cs
Normal file
9
Runtime/Interfaces/IAttributeValidator.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
using System;
|
||||
|
||||
namespace Module.ProjectValidator
|
||||
{
|
||||
public interface IAttributeValidator<in T> where T : Attribute
|
||||
{
|
||||
ValidatorResult Validate(T attribute, object value);
|
||||
}
|
||||
}
|
||||
3
Runtime/Interfaces/IAttributeValidator.cs.meta
Normal file
3
Runtime/Interfaces/IAttributeValidator.cs.meta
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 745c26fe699143d795d498fe0621a619
|
||||
timeCreated: 1778923739
|
||||
14
Runtime/Module.ProjectValidator.asmdef
Normal file
14
Runtime/Module.ProjectValidator.asmdef
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"name": "Module.ProjectValidator",
|
||||
"rootNamespace": "Module.ProjectValidator",
|
||||
"references": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
7
Runtime/Module.ProjectValidator.asmdef.meta
Normal file
7
Runtime/Module.ProjectValidator.asmdef.meta
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4e594c19fac9b29429cbe6a99f0aa22a
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
11
Runtime/ValidatorResult.cs
Normal file
11
Runtime/ValidatorResult.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
namespace Module.ProjectValidator
|
||||
{
|
||||
public struct ValidatorResult
|
||||
{
|
||||
public EValidatorSeverity Severity;
|
||||
public string Message;
|
||||
|
||||
public static ValidatorResult Valid => new();
|
||||
public static ValidatorResult Create(EValidatorSeverity severity, string message) => new() { Severity = severity, Message = message };
|
||||
}
|
||||
}
|
||||
3
Runtime/ValidatorResult.cs.meta
Normal file
3
Runtime/ValidatorResult.cs.meta
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 60b975f740d64cb0ad90ded13fc75c4d
|
||||
timeCreated: 1778925534
|
||||
Loading…
Add table
Add a link
Reference in a new issue