Author Topic: EventDelegate.cs: "unintended reference comparison" warning  (Read 2701 times)

jchowdown

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 16
    • View Profile
EventDelegate.cs: "unintended reference comparison" warning
« on: December 11, 2013, 04:59:24 PM »
Hi All,

I'm getting this warning in EventDelegate.cs: http://screencast.com/t/lGEf0uyxF5q2

What's the recommended fix please? Should I just #pragma it out for now?

Thanks,
Jeff

rblanchet

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: EventDelegate.cs: "unintended reference comparison" warning
« Reply #1 on: December 11, 2013, 05:15:33 PM »
This exact diff may not be accurate anymore since I haven't updated NGUI in awhile but it gives you the gist of the change:

  1.  
  2. @@ -98,7 +98,7 @@ public class EventDelegate
  3.      {
  4.        Callback callback = obj as Callback;
  5.        if (callback.Equals(mCachedCallback)) return true;
  6. -      return (mTarget == callback.Target && string.Equals(mMethodName, GetMethodName(callback)));
  7. +      return (mTarget == (MonoBehaviour)callback.Target && string.Equals(mMethodName, GetMethodName(callback)));
  8.      }
  9.      
  10.      if (obj is EventDelegate)
  11. @@ -124,7 +124,7 @@ public class EventDelegate
  12.    Callback Get ()
  13.    {
  14.  #if REFLECTION_SUPPORT
  15. -    if (!mRawDelegate && (mCachedCallback == null || mCachedCallback.Target != mTarget || GetMethodName(mCachedCallback) != mMethodName))
  16. +    if (!mRawDelegate && (mCachedCallback == null || (MonoBehaviour)mCachedCallback.Target != mTarget || GetMethodName(mCachedCallback) != mMethodName))
  17.      {
  18.        if (mTarget != null && !string.IsNullOrEmpty(mMethodName))
  19.        {
  20.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: EventDelegate.cs: "unintended reference comparison" warning
« Reply #2 on: December 12, 2013, 01:09:00 AM »
Those warnings only show up when building in Visual Studio as I understand it (as they certainly don't show up in Unity).

In any case, I've addressed them already yesterday in the Pro repo.

jchowdown

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 16
    • View Profile
Re: EventDelegate.cs: "unintended reference comparison" warning
« Reply #3 on: December 12, 2013, 02:27:30 AM »
Those warnings only show up when building in Visual Studio as I understand it (as they certainly don't show up in Unity).

In any case, I've addressed them already yesterday in the Pro repo.

Thanks! Not that this is important since you've already addressed it, but I saw this in Unity on OS X.