[Bug]: Mark ReactiveObject IObservable properties with DisplayAttribute for Winforms
Micha-kun opened this issue · comments
Describe the bug 🐞
When binding a model class into databinding controls like DevExpress ones in WinForms, because it does not implement DisplayAttribute from System.Component.DataAnnotations with Order set to -1, automatically is binding those IObservable properties from ReactiveObject and you manually need to remove them every time you bind new objects. Actually those properties are implementing two attributes: IgnoreDataMember and JsonIgnore.
Properties are:
- Changing
- Changed
- ThrownExceptions
Step to reproduce
- Create a form and include a Grid control
- Bind to that control a BindingSource mapping to the class that implements ReactiveObject class
- Bind data to that BindingSource
- Start the app and see that grid control is showing by default those properties because they're not implementing DisplayAttribute
Reproduction repository
No response
Expected behavior
When those properties are fixed, by default should ignore those properties for databinding.
Screenshots 🖼️
IDE
Visual Studio 2022, Visual Studio 2019, Visual Studio 2017
Operating system
Windows
Version
No response
Device
No response
ReactiveUI Version
No response
Additional information ℹ️
I don't know if other frameworks like WPF are affected with this behavior.
This is the DevExpress documentation around the use of Data Annotations attributes:
Is there an attribute for the annotations that makes the property grid not generate for that property. Doing a quick hunt
Browsable(false) by the looks. Wouldn't that be more suitable?
Hmmm there are other properties on DisplayAttribute that prevents to generate the column:
[Display(Order = -1)] hides the column but [Display(AutoGenerateField = false)] prevents the column automatic generation and [Display(AutoGenerateFilter = false)] prevents the column to be used on filters.
So, the correct attribute usage should be [Browsable(false), Display(Order = -1, AutoGenerateField = false, AutoGenerateFilter = false)]
anyway open to having these attributes on the class mentioned providing it can be handled by all platforms etc.
Happy to take a PR if you like and we can get it in the next release?
BTW I suspect for other platforms like WPF it'll be a good thing. WPF doesn't come with a native property grid, but almost all I know of work like the winforms one and obey those properties. Eg I suspect the problem you're having would be a issue even with the native winforms propertygrid not just the devexpress ones.
Ok! I'm going to make a PR :)
It worked! YESSS!
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.