Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added missing DebuggerDisplay #2347

Merged
merged 3 commits into from
Apr 28, 2021
Merged

Added missing DebuggerDisplay #2347

merged 3 commits into from
Apr 28, 2021

Conversation

papafe
Copy link
Contributor

@papafe papafe commented Apr 22, 2021

This PR adds DebuggerDisplay to some Realm types. In particular debugger display contains:

  • RealmObjectBase: IsValid
  • RealmValueType: Type - ToString() --> This can be useful to differentiate between different numerical types with similar string representation, for instance

Regarding the rest of the Realm types:

  • Collection types (Set, Dictionary, List, Result) and their superclass RealmCollectionBase don't have anything meaningful to display in my opinion. For the "proper" collection types (Set, Dictionary, List), the parameter Count was already in the DebuggerDisplay attribute, and that seems fine.
  • RealmInteger already prints the containing value in ToString(), and that also seems fine enough.

Fixes #2047

@nirinchev
Copy link
Member

I think we can be a bit more precise with these. Currently, this is what I see when I hover over a RealmObject - it's not particularly useful:

Screen Shot 2021-04-22 at 15 16 15

I think we can make it nicer by including the type of the object - perhaps by introducing a private property and using that for the debugger display? I was thinking of something like Person { Id = 123 }, IsValid = true. We can get the primary key property name from ObjectSchema.PrimaryKeyProperty and the primary key value from _metadata.Helper.TryGetPrimaryKeyValue(this).

For RealmValue, we're currently outputting the namespaced type, which is long and boring. I was thinking we could replace it with something like RealmValue, Type = String, Value = "abc" and for objects, just RealmValue, Person { Id = 123 }, IsValid = true.

@papafe
Copy link
Contributor Author

papafe commented Apr 23, 2021

I think it makes sense to add the primary key to the DebugDisplay for RealmObjectBase. I am not sure about adding the Type though, I think it would not be a useful information, as the majority of the time the developer would know already that. Besides, it's possible to see it in the "Locals" debug window.

Regarding RealmValue, I agree on adding Type = String, Value = "abc", but I don't think that adding the string RealmValue in front is useful, for the same reason as before. In this case, though, it definitely makes sense to print the object type.

@papafe
Copy link
Contributor Author

papafe commented Apr 23, 2021

I have added some improvements, we can probably discuss about them :)

@papafe papafe merged commit 7af6697 into master Apr 28, 2021
@papafe papafe deleted the fp/debugger-display branch April 28, 2021 05:25
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add [DebuggerDisplay] or a more meaningful ToString for Realm types
3 participants