Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Consider adding DebuggerDisplayAttribute to classes #466

Closed
Mrnikbobjeff opened this issue Aug 10, 2018 · 5 comments
Closed

Consider adding DebuggerDisplayAttribute to classes #466

Mrnikbobjeff opened this issue Aug 10, 2018 · 5 comments
Labels
ready-to-implement Feature approved, specs written, and ready to implement. up-for-grabs Implementation from community can be started.

Comments

@Mrnikbobjeff
Copy link
Contributor

Description

We should consider adding the DebuggerDisplayAttirbute to classes which can be inspected for debugging. This should ease debugging experience as more information is available easily without navigating in the debugger.
https://docs.microsoft.com/en-us/dotnet/framework/debug-trace-profile/enhancing-debugging-with-the-debugger-display-attributes
XF also uses this for types like Thickness. we should also inspect which types could benefit.

@mattleibow
Copy link
Contributor

I had a look at what this would mean, and it will require a slightly more careful implementation. We could add attributes to most types, but is this really needed?

We could probably follow the rest of .NET conventions, such as making the structs and other simple types override the ToString() method. These could include the AccelerometerData (and other sensor objects).

For the debugger attribute, we need to remember that this will get evaluated multiple times and we do not want to sacrifice any performance just to get a pretty picture. We can do this selectively, but at the same time be consistent and helpful. We can do BatteryChangedEventArgs and make that helpful, but I don't see any other event args in the .NET Framework with this attribute.

I think if we can maybe suggest particular types that need to be more debugger friendly, and then address that type directly and access if the similar/related types also need attributes.

Here are some more docs: https://docs.microsoft.com/en-us/visualstudio/debugger/using-the-debuggerdisplay-attribute

@jamesmontemagno
Copy link
Collaborator

I agree here with Matthew as if there is a specific reason and type that needs this then I could justify the additional work, but I don't see any benefit today.

@Mrnikbobjeff
Copy link
Contributor Author

Mrnikbobjeff commented Aug 16, 2018

I was specifically looking at the structs for which I would like to not have them expand in the debugger to see all values of the underlying quaternion/float3 etc. I did not take a look at the .net framework source, but it is used thoroughly in Xamarin Forms. While overriding ToString is preferable, the static classes with properties could be enhanced with this a bit. A joint approach with ToString and the Attribute would probably be the best. What we would also need to consider is that enum values are currently bugged in the c# expression evaluator, which in turn limits the scope of classes where we can add this attribute.

@jamesmontemagno
Copy link
Collaborator

Seems like we want to override ToString on any struct or class to display information. I don't think any additional DebuggerDisplayAttribute would add anything here.

@jamesmontemagno jamesmontemagno added ready-to-implement Feature approved, specs written, and ready to implement. up-for-grabs Implementation from community can be started. labels Sep 6, 2018
@jamesmontemagno
Copy link
Collaborator

Closing as we are now overriding ToString where necessary.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
ready-to-implement Feature approved, specs written, and ready to implement. up-for-grabs Implementation from community can be started.
Projects
None yet
Development

No branches or pull requests

3 participants