mirror of
https://github.com/DCFApixels/DragonECS-AutoInjections.git
synced 2025-09-18 05:04:35 +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.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using static DCFApixels.DragonECS.EcsThrowHalper;
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS
|
namespace DCFApixels.DragonECS
|
||||||
{
|
{
|
||||||
@ -51,8 +52,7 @@ namespace DCFApixels.DragonECS
|
|||||||
if (o.GetCustomAttribute<EcsInjectAttribute>() == null)
|
if (o.GetCustomAttribute<EcsInjectAttribute>() == null)
|
||||||
return false;
|
return false;
|
||||||
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||||
if (o.CanWrite == false)
|
if (o.CanWrite == false) Throw.PropertyIsCantWrite(o);
|
||||||
throw new EcsAutoInjectionException($"{o.Name} property is cant write");
|
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
@ -63,10 +63,8 @@ namespace DCFApixels.DragonECS
|
|||||||
if (o.GetCustomAttribute<EcsInjectAttribute>() == null)
|
if (o.GetCustomAttribute<EcsInjectAttribute>() == null)
|
||||||
return false;
|
return false;
|
||||||
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||||
if (o.IsGenericMethod)
|
if (o.IsGenericMethod) Throw.MethodIsGeneric(o);
|
||||||
throw new EcsAutoInjectionException($"{o.Name} method is Generic");
|
if (o.GetParameters().Length != 1) Throw.MethodArgumentsGreater1(o);
|
||||||
if (o.GetParameters().Length != 1)
|
|
||||||
throw new EcsAutoInjectionException($"{o.Name} method Arguments != 1");
|
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
|
@ -1,8 +1,30 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS
|
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]
|
[Serializable]
|
||||||
public class EcsAutoInjectionException : Exception
|
public class EcsAutoInjectionException : Exception
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user