From 12ca06416a2cac738e6a19ed490c11906a076f50 Mon Sep 17 00:00:00 2001 From: sebas77 Date: Sat, 18 Feb 2017 13:31:40 +0000 Subject: [PATCH] FIX UWP (.net) compatibility --- ECS/EnginesRoot.cs | 12 +++++++++++- Utilities/WeakActionStruct.cs | 19 +------------------ 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/ECS/EnginesRoot.cs b/ECS/EnginesRoot.cs index ab30b18..0f1867a 100644 --- a/ECS/EnginesRoot.cs +++ b/ECS/EnginesRoot.cs @@ -8,6 +8,9 @@ using WeakReference = Svelto.DataStructures.WeakReference listener) { ObjectRef = GCHandle.Alloc(listener.Target, GCHandleType.Weak); + #if !NETFX_CORE Method = listener.Method; - - if (Method.DeclaringType.GetCustomAttributes(typeof(CompilerGeneratedAttribute), false).Length != 0) - throw new ArgumentException("Cannot create weak event to anonymous method with closure."); #else Method = listener.GetMethodInfo(); - - if (CustomAttributeExtensions.IsDefined(Method, typeof(CompilerGeneratedAttribute), false) == false) - throw new ArgumentException("Cannot create weak event to anonymous method with closure."); #endif } @@ -58,14 +53,8 @@ namespace BetterWeakEvents ObjectRef = GCHandle.Alloc(listener.Target, GCHandleType.Weak); #if !NETFX_CORE Method = listener.Method; - - if (Method.DeclaringType.GetCustomAttributes(typeof(CompilerGeneratedAttribute), false).Length != 0) - throw new ArgumentException("Cannot create weak event to anonymous method with closure."); #else Method = listener.GetMethodInfo(); - - if (CustomAttributeExtensions.IsDefined(Method, typeof(CompilerGeneratedAttribute), false) == false) - throw new ArgumentException("Cannot create weak event to anonymous method with closure."); #endif } @@ -102,14 +91,8 @@ namespace BetterWeakEvents ObjectRef = GCHandle.Alloc(listener.Target, GCHandleType.Weak); #if !NETFX_CORE Method = listener.Method; - - if (Method.DeclaringType.GetCustomAttributes(typeof(CompilerGeneratedAttribute), false).Length != 0) - throw new ArgumentException("Cannot create weak event to anonymous method with closure."); #else Method = listener.GetMethodInfo(); - - if (CustomAttributeExtensions.IsDefined(Method, typeof(CompilerGeneratedAttribute), false) == false) - throw new ArgumentException("Cannot create weak event to anonymous method with closure."); #endif }