Bug Report T1225399
Visible to All Users

Implement IEquatable - code provider does not respect the naming convention defined for parameters

created a year ago

Steps to reproduce:

  1. Naming convention for parameters is _PascalCase
  2. Start with the code:
Visual Basic
Imports System.ComponentModel Public Class Class3 Implements INotifyPropertyChanged Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged Protected Sub NotifyPropertyChanged(_PropertyName As String) RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(_PropertyName)) End Sub Private m_Prop1 As String Private m_Prop2 As GenericEventArgs(Of GenericResultFlags) Public Property Prop1 As String Get Return m_Prop1 End Get Set(_Value As String) If m_Prop1 Is _Value Then Return End If m_Prop1 = _Value NotifyPropertyChanged(NameOf(Prop1)) End Set End Property Public Property Prop2 As GenericEventArgs Get Return m_Prop2 End Get Set(_Value As GenericEventArgs) If m_Prop2 = _Value Then Return End If m_Prop2 = _Value NotifyPropertyChanged(NameOf(Prop2)) End Set End Property Public Sub New(ByVal _Prop1 As String, ByVal _Prop2 As GenericEventArgs) m_Prop1 = _Prop1 m_Prop2 = _Prop2 End Sub End Class
  1. Execute the Implement IEquatable code provider

Expected results:

Visual Basic
Public Overrides Function Equals(_Obj As Object) As Boolean If TypeOf _Obj Is Class3 Then Return Equals(CType(_Obj, Class3)) End If Return MyBase.Equals(_Obj) End Function Public Shared Operator =(_First As Class3, _Second As Class3) As Boolean If CType(_First, Object) Is Nothing Then Return CType(_Second, Object) Is Nothing End If Return _First.Equals(_Second) End Operator Public Shared Operator <>(_First As Class3, _Second As Class3) As Boolean Return Not (_First = _Second) End Operator Public Overloads Function Equals(_Other As Class3) As Boolean Implements IEquatable(Of Class3).Equals If ReferenceEquals(Nothing, _Other) Then Return False End If If ReferenceEquals(Me, _Other) Then Return True End If Return Equals(m_Prop1, _Other.m_Prop1) AndAlso Equals(m_Prop2, _Other.m_Prop2) End Function Public Overrides Function GetHashCode() As Integer Dim hashCode As Long = 47 If m_Prop1 IsNot Nothing Then hashCode = CInt(((hashCode * 53) + EqualityComparer(Of String).Default.GetHashCode(m_Prop1)) And &H7FFFFFFFL) End If If m_Prop2 IsNot Nothing Then hashCode = CInt(((hashCode * 53) + EqualityComparer(Of GenericEventArgs).Default.GetHashCode(m_Prop2)) And &H7FFFFFFFL) End If Return CInt(hashCode) End Function

Current results:

Visual Basic
Public Overrides Function Equals(obj As Object) As Boolean If TypeOf obj Is Class3 Then Return Equals(CType(obj, Class3)) End If Return MyBase.Equals(obj) End Function Public Shared Operator =(first As Class3, second As Class3) As Boolean If CType(first, Object) Is Nothing Then Return CType(second, Object) Is Nothing End If Return first.Equals(second) End Operator Public Shared Operator <>(first As Class3, second As Class3) As Boolean Return Not (first = second) End Operator Public Overloads Function Equals(other As Class3) As Boolean Implements IEquatable(Of Class3).Equals If ReferenceEquals(Nothing, other) Then Return False End If If ReferenceEquals(Me, other) Then Return True End If Return Equals(m_Prop1, other.m_Prop1) AndAlso Equals(m_Prop2, other.m_Prop2) End Function Public Overrides Function GetHashCode() As Integer Dim hashCode As Long = 47 If m_Prop1 IsNot Nothing Then hashCode = CInt(((hashCode * 53) + EqualityComparer(Of String).Default.GetHashCode(m_Prop1)) And &H7FFFFFFFL) End If If m_Prop2 IsNot Nothing Then hashCode = CInt(((hashCode * 53) + EqualityComparer(Of GenericEventArgs).Default.GetHashCode(m_Prop2)) And &H7FFFFFFFL) End If Return CInt(hashCode) End Function

Answers approved by DevExpress Support

created a year ago

We have addressed the issue described in this ticket and will include a fix in our next maintenance update. Should you need to apply our fix prior to official release, you can request a hotfix here.

Important Notes:

  • Hotfixes may be unavailable for Early Access/Beta builds or updates set for release within a week.
  • .NET only: in the NuGet Package Manager, use your personal NuGet feed and check the "Include prerelease" option to view the hotfix package in the "Updates" tab.

    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.