Bug Report T522585
Visible to All Users

Templates - "Convert to Property with Change Notification" expansion uses an improper trigger for the PropertyChanged event

created 8 years ago

Hi

Is there an option to change the template for the function "Convert to Property with Change Notification"

The default setting:

int myProperty;
        public int MyProperty
        {
            get
            {
                return myProperty;
            }
            set
            {
                if (myProperty == value)
                    return;
                myProperty = value;
                RaisePropertyChanged(nameof(MyProperty));
            }
        }

But I use it every time with "OnPropertyChange();" but not with "RaisePropertyChanged(nameof(MyProperty));"

How can I change it?

Thanks
Michael

Show previous comments (1)
MD MD
Michael Draxler 8 years ago

    Hi Alexander

    In my base class there some OnPropertyChange methodes:
    for simple call PropertChanged Event (don't had to write the name of the propertiy)

    public void OnPropertyChanged([CallerMemberName]string propertyName = null)
            {
                OnPropertyChanged(propertyName, true); -> call main OnPropertyChange methode
            }

    For select, if the PropertyChange Event will call with Parameter "makeDirty"
    makeDirty tells if a class (i.e. addresses) had changes, and I had to Display to save it

    public void OnPropertyChanged(bool makeDirty, [CallerMemberName]string propertyName = null)
            {
                OnPropertyChanged(propertyName, makeDirty);
            }

    the main methode for setting all other important properties on OnPropertyChange

    public void OnPropertyChanged(string propertyName, bool makeDirty)
            {
                RaisePropertiesChanged(propertyName);
                if (_IsSuppressDirty)
                    return;
                if (makeDirty)
                {
                    IsDirty = true;
                    if (IsDirtyChanged != null)
                    {
                        var e = new EventArgsPropertyInListChanged()
                        {
                            PropertyName = propertyName,
                            ChangedItem = this
                        };
                        IsDirtyChanged(this, e);
                    }
                }
                //Validate();
            }

    As I wrote the CodeRush set the Notification to RaisePropertyChanged of the DevExpress.Mvvm Namespace

    I hope it is now clearer.

    I want to say CodeRush, do not use the "RaisePropertyChanged" from DevExpress.Mvvm Namespace, use my "OnPropertyChanged()" Methode

    Thanks
    Michael

    DevExpress Support Team 8 years ago

      Thank you for providing the code samples. We currently understand your case. Please give us some time to discuss the best way to support this functionality in our product. We will notify you.

      DevExpress Support Team 8 years ago

        Thank you for your patience. We have decided to improve logic CodeRush features that generate property change notification. So, they will automatically detect that the OnPropertyChanged method should be used in your case. We will notify you of our progress.

        Answers approved by DevExpress Support

        created 8 years ago

        We have fixed the issue described in this ticket and will include the fix in our next maintenance update. To apply this solution before the official update, request a hotfix by clicking the corresponding link for product versions you require.

        Note: Hotfixes may be unavailable for beta versions and updates that are about to be released.

          Show previous comments (2)
          DevExpress Support Team 8 years ago

            Hi Michael,

            We have made necessary changes to completely support your case and prepared a special build:

            DevExpress.CodeRush.Roslyn-17.1.6.17215.vsix
            DevExpress.CodeRush.Roslyn-17.1.6.17215.exe

            Please install this build and let us know whether template expansions work as you require.

            MD MD
            Michael Draxler 8 years ago

              I installed Version 17.1.7.
              Thank works fine for me !!!

              br
              Michael

              DevExpress Support Team 8 years ago

                You are welcome, Michael. We are happy to hear that this build solved the issue.

                Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

                Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.