Bug Report T731365
Visible to All Users

Refactoring – The “Convert to Auto-implemented Property” refactoring creates incorrect code with the deprecated OnPropertyChanged method call in the property setter

created 6 years ago

It creates this code

C#
bool showPriceMultiple; public bool ShowPriceMultiple { get { return showPriceMultiple; } set { if (showPriceMultiple == value) return; showPriceMultiple = value; OnPropertyChanged(); } }

I wanted something closer to this code

C#
bool showPriceMultiple; public bool ShowPriceMultiple { get => showPriceMultiple; set => SetProperty(ref showPriceMultiple, value); }

I think it may be because it found a deprecated OnPropertyChanged method in the base class

Comments (3)
DevExpress Support Team 6 years ago

    Hello,
    Would you please provide more details about the MVVM framework you are using? I need an example of the OnPropertyChanged implementation in the base class and implementation of the SetProperty method. Our engine analyzes implementation of the INotifyPropertyChanged interface and selects the most appropriate method to raise the PropertyChanged event.

      I am using Prism BindableBase.

      DevExpress Support Team 6 years ago

        Thank you for the clarification.
        For now, our engine does not support cases with the SetProperty method. We need to put special info of the most used MVVM frameworks into our code for such cases. We understand that the SetProperty usage is the recommended practice. We will take implementation of this into account while discussing our future plans.
        At the same time, I completely agree that calling the deprecated OnPropertyChanged method is not the best solution in this case. We will correct the behavior of this refactoring so it uses RaisePropertyChanged in this situation.

        Answers approved by DevExpress Support

        created 6 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.

          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.