mirror of
https://github.com/DCFApixels/DragonECS-AutoInjections.git
synced 2025-09-17 12:24:34 +08:00
update exceptions
This commit is contained in:
parent
3a88805a8c
commit
ab83f0fdc7
@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using static DCFApixels.DragonECS.EcsThrowHalper;
|
||||
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
@ -51,8 +52,7 @@ namespace DCFApixels.DragonECS
|
||||
if (o.GetCustomAttribute<EcsInjectAttribute>() == null)
|
||||
return false;
|
||||
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||
if (o.CanWrite == false)
|
||||
throw new EcsAutoInjectionException($"{o.Name} property is cant write");
|
||||
if (o.CanWrite == false) Throw.PropertyIsCantWrite(o);
|
||||
#endif
|
||||
return true;
|
||||
})
|
||||
@ -63,10 +63,8 @@ namespace DCFApixels.DragonECS
|
||||
if (o.GetCustomAttribute<EcsInjectAttribute>() == null)
|
||||
return false;
|
||||
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||
if (o.IsGenericMethod)
|
||||
throw new EcsAutoInjectionException($"{o.Name} method is Generic");
|
||||
if (o.GetParameters().Length != 1)
|
||||
throw new EcsAutoInjectionException($"{o.Name} method Arguments != 1");
|
||||
if (o.IsGenericMethod) Throw.MethodIsGeneric(o);
|
||||
if (o.GetParameters().Length != 1) Throw.MethodArgumentsGreater1(o);
|
||||
#endif
|
||||
return true;
|
||||
})
|
||||
|
@ -1,8 +1,30 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
public static class EcsThrowHalper_AutoInjections
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
internal static void PropertyIsCantWrite(this EcsThrowHalper _, MemberInfo obj)
|
||||
{
|
||||
throw new EcsAutoInjectionException($"{obj.Name} property is cant write");
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
internal static void MethodIsGeneric(this EcsThrowHalper _, MemberInfo obj)
|
||||
{
|
||||
throw new EcsAutoInjectionException($"{obj.Name} method is Generic");
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
internal static void MethodArgumentsGreater1(this EcsThrowHalper _, MemberInfo obj)
|
||||
{
|
||||
//method X has arguments greater than 1.
|
||||
throw new EcsAutoInjectionException($"{obj.Name} method Arguments != 1");
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class EcsAutoInjectionException : Exception
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user