jbruening / ugui-mvvm

Unity3D uGUI mvvm databinding via the standard IXChanged interfaces used in wpf (INotifyPropertyChanged, INotifyCollectionChanged, etc)
Other
214 stars 41 forks source link

DataContext suggestions show compiler generated classes in the dropdown #25

Closed davidwangms closed 5 years ago

davidwangms commented 5 years ago

The dropdown appears to be showing compiler generated classes as well, which may be confusing for the user, and also bloats up the suggestions box. These should be marked with CompilerGeneratedAttribute, so they can be filtered out from the results

image

ryantrem commented 5 years ago

Good callout. I think filtering on that attribute could be done here: PropertyPathSuggestionProvider.cs (line 158). @davidwangms - any interest in taking a stab at a fix? 🙂

davidwangms commented 5 years ago

Could be interesting, I'll take a stab at it next week if no one else is around to look into it, sure

AdamMitchell-ms commented 5 years ago

@davidwangms , you can probably do this by adding a Where clause to that line which checks for GeneratedCodeAttribute.

Something like this:

            .Where(p => p.GetCustomAttribute<GeneratedCodeAttribute>() == null);

Haven't tested this code.

AdamMitchell-ms commented 5 years ago

Just noticed that you already found another attribute. I'm not very familiar with the two, but I found this old blog post about them. https://blogs.msdn.microsoft.com/codeanalysis/2007/04/27/correct-usage-of-the-compilergeneratedattribute-and-the-generatedcodeattribute/

ryantrem commented 5 years ago

Sounds to me like we should consider filtering out properties with any of the following attributes: CompilerGeneratedAttribute GeneratedCodeAttribute DebuggerNonUserCodeAttribute EditorBrowsableAttribute (with EditorBrowsableState.Never)