Current filter:
                                You should refresh the page.
                                  • Hi

                                    Let me preface this by saying that I'm in the process of teaching myself C# so my perceived error in CodeRush may well be an error in my own implementation of C# itself.  That being said;

                                    Simple WPF Project  (I would normally use DevExpresses own implementation of MVVM but as I said I'm teaching myself C# and I know this sort of thing used to work in CodeRush Clasic using VB.

                                    I have a simple BindableBase class that provides the base INotifyPropertyChanged implementation:

                                    [C#]
                                    using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; namespace Vtl_TrackerConfigurationManager.ViewModels { class BindableBase : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } } }

                                     I then create a new class and inherit from BindableBase.  Within that I Type ps Iinvoking the string property template.  What I end up with is the following, but I see no implementation of Property changed as I would have expected.  Is this a CodeRush for Roslyn issue or simply a mess up on my part (presumably in BindableBase)?

                                    [C#]
                                    using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Vtl_TrackerConfigurationManager.ViewModels { class VtlBaseViewModel : BindableBase { string propertyName; public string PropertyName { get { return propertyName; } set { propertyName = value; } } } }

                                     Dom

                                • Dom Sinclair 12.13.2016

                                  Just to add to this.  Lest my original implementation of The BindableBase class was incorrect I decided to replace that with the classic tried and tested Josh Smith implementation of a base class implementing INotifyPropertyChanged.  This I know (admittedly using a vb variant) used to have CodeRush property  templates expanding to implement this.

                                  My guess therefore is that there is some sort of regression bug and CR templates no longer do this as they did.  As I said earlier most times I would actually use your MVVM framework so this would be largely academic, but just at the moment it would be rather useful to have it working.

                                  Dom

                                • Alex B.G. (DevExpress) 12.13.2016

                                  Hi Dom,

                                  Thank you for the provided code snippets. They helped me reproduce the issue and understand its cause. I have noticed that the "ps" template expands as expected in the context of "VtBaseViewModel" if the "OnPropertyChanged" method has the following implementation:

                                  [C#]
                                  protected void OnPropertyChanged(string name) { var handler = PropertyChanged; if(handler != null) handler(this, new PropertyChangedEventArgs(name)); }

                                   I guess that the issue is associated with the presence of the following conditional access operation in your code:

                                  [C#]
                                  PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));

                                  It seems that the context of the "ps" template can't be satisfied because of this, so it can't support INotifyPropertyChanged in your case. We will fix this issue as soon as possible.

                                1 Solution

                                Creation Date Importance Sort by

                                Fixed: