[Mono-bugs] [Bug 676720] New: New Rule - Detect incorrect "magic" strings passed to INotifyPropertyChanged.PropertyChanged

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Mar 3 10:55:57 EST 2011



           Summary: New Rule - Detect incorrect "magic" strings passed to
    Classification: Mono
           Product: Mono: Tools
           Version: 2.10.x
          Platform: 64bit
        OS/Version: Other
            Status: NEW
          Severity: Enhancement
          Priority: P5 - None
         Component: Gendarme
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: ethan_j_brown at hotmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---

User-Agent:       Mozilla/5.0 (Windows; Windows NT 6.1) AppleWebKit/534.23
(KHTML, like Gecko) Chrome/11.0.686.1 Safari/534.23

There are many MVVM frameworks that provide an Expression<Func<>> style of
compile time validation when implementing INotifyPropertyChanged. (For
instance, Caliburn.Micro provides a base class that examines the expression and
returns the name of a property of the class to the PropertyChanged event as
expected by the framework --

However, passing a "magic" string is still pretty common when implementing
INotifyPropertyChanged yourself in WPF / Silverlight / Moonlight / WP7, and has
a lot better performance.  There are rumors that WPF5 will have some sort of
compiler support, but not sure if that will happen or not.

Here are the MSDN docs on INotifyPropertyChanged.PropertyChanged

I think it would be nice to have a rule that looks at calls made to the
PropertyChanged event to determine if the magic string being passed refers to
an actual property of the class or not.  If there is no matching property name
in the inheritance hierarchy, that would be considered a violation.

Reproducible: Always

Steps to Reproduce:

Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.

More information about the mono-bugs mailing list