I have been trying for hours and a lot recode but can get rid of the CA1067 violation.
Using:
Visual Studio 2022, .Net v6.0.13, VB.NET
I will appreciate any help to solve the issue and insights in what I am doing wrong.
So the case is the following:
I have a template class SimNode(Of P,A)
where P
stands for the data type for parent and A
for the data type of the three attributes of the node.
Public Class SimNode(Of P, A)
Implements ISimNode(Of P, A)
Implements IEquatable(Of SimNode(Of P, A))
'[a bunch of properties and methods]
Public Overridable Shadows Function Equals(other As SimNode(Of P, A)) As Boolean Implements IEquatable(Of SimNode(Of P, A)).Equals
If Not Parent.Equals(other.Parent) Then Return False
If Depth <> other.Depth Then Return False
....
Return True
End Function
End Class
I then needed to create another class called SimNode
which inherits from SimNode(UShort,UShort)
and requires an IEquatable(Of SimNode)
because only unique SimNode
instances will be added into a template 'container' -> Container(Of T as IEquatable(Of T))
.
The word container is generic it could be e.g. a list, a dictionary or a hashset.
This new class is exactly the same as the parent class but with an extra member (list).
Private Class SimNode
Inherits SimNode(Of UShort, UShort)
Implements IEquatable(Of SimNode)
'[a bunch of properties and methods]
Private Shadows Function Equals(other As SimNode) As Boolean Implements IEquatable(Of SimNode).Equals
Return MyBase.Equals(other)
End Function
End Class
My equality criteria is still the same as the one in the parent class despite the extra list.
This approach is leading to a CA1067 violation and I just cannot get this correct.
I will appreciate very much any help!
I have try to follow the suggestions from Visual Studio but all lead to error. The suggestion of override the method Equals
in the child class (SimNode
) will produce obviously error because it can't override the base class since they have different signatures.
I also worked around this https://stackoverflow.com/questions/2441346/cascading-iequatableof-t with no success.