Closed x789 closed 1 year ago
solved
I thought about it again. .NET does not know the principle of overriding. The possibility to override is a C# thing.
Therefore the approach to see if there is a method with the name Equals
was right, but the syntax was wrong. The parameters were missing.
The following code checks (successfully) if a type implements (and thus overwrites) the System.Equals(System.Object)
method.
Classes().That().ResideInNamespace("Domain").Should().HaveMemberWithName("Equals(System.Object)").Check(architecture);
I like to use ArchUnit in a project where certain classes need to override the Equals and GetHashCode methods. Since these are virtual methods of
object
, the creation of an interface and a check for its implementation will not work.I have tried the following:
as well as
Does anyone have a hint on how I can implement this check?