Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by B16B0SS · Nov 04, 2015 at 08:25 PM · errorvisual studiomono

Does Mono evaluate equality of objects differently then MS .NET

Hello.

I have a generic container that has a past and present value stored as objects.

The container currently has bool types. Past and present are both true.

 object a = past;
 object b = present
 
 bool same = a == b;

in the Visual Studio debugger I see the following in the watch window

 a -> shows true
 b -> shows true
 
 a == b -> shows true
 same =-> shows false

However, if I use .Equals instead of equality I get

 a  -> shows true
 b  -> shows true
 
 a == b -> shows true
 same  -> shows true

So my question is:

Is there a very critical difference between the Mono and MS Runtime? Is there a bug in the watch window of the VS debugger?

alt text

Thanks!

pasted-image-at-2015-11-04-03-39-pm.png (214.2 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by fafase · Nov 05, 2015 at 08:31 AM

When you run

  a == b

this performs a reference check since you have object type, regardless the content.

When you use Equals, you test the content of the object.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image B16B0SS · Nov 05, 2015 at 08:35 AM 0
Share

Right, but why does a == b show true in the inspector and false when executed through the runtime. Do you think this is a bug within Visual Studio? (See screenshot)

This came about me debugging a 3rd party package named uFrame, and I unrolled the equality check for testing. Until then I had no idea that LastValue and ObjectValue were objects. So the watch window reporting something different than the code was very confusing.

avatar image fafase · Nov 05, 2015 at 08:40 AM 0
Share

If you performs an if statement, do you get the wrong behaviour?

It would look like the expression is reporting the wrong type of check. It seems to show the content test ins$$anonymous$$d of the object reference test.

There has been some reports on VS debugger showing wrong. $$anonymous$$aybe you are one fo those as well.

avatar image B16B0SS · Nov 05, 2015 at 08:42 AM 0
Share

Where would you like me to perform the if statement?

The result of this call is used in an if statement, and its what you described (a != b).

I should add that the code used to be

 return property.PastValue != property.ObjectValue

and it would always return false as expected (once I knew PastValue and ObjectValue were objects

I'll file a VS bug. Thanks so much for your time

avatar image B16B0SS · Nov 05, 2015 at 08:44 AM 0
Share

I should add that the code used to be

 return property.PastValue != property.ObjectValue

and it would always return false as expected (once I knew PastValue and ObjectValue were objects

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Unable to import items from package manager - Unable to get local issuer certificate 0 Answers

Internal Compiler Error 3 Answers

Visual Studio error for referenced scripts 2 Answers

How to make .shader open in Mono Develop, but C# still open in Visual Studio 0 Answers

,VS2017 cannot find Metadata file "Unity.TextMeshPro.Tests.dll" 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges