-
Notifications
You must be signed in to change notification settings - Fork 756
Description
In #2290, we made the constructor internal and introduced a Default static property which returns a new instance every time. I failed to notice this when reviewing that PR.
Edit: Thanks for the correction @mikkelbu. The Default property has been in NUnitEqualityComparer since v2.5.1!
I believe that static properties should return the same instance every time or at least semantically be able to return the same instance every time. If the returned instance is immutable, it should be a static property. If it's mutable, it must create a new instance every time and therefore should be a method. Rather than having a static method delegate to the default constructor, I'd prefer re-exposing the default constructor.
I would like to propose the following:
namespace NUnit.Framework.Constraints
{
public class NUnitEqualityComparer
{
+ public NUnitEqualityComparer();
+ [Obsolete("Deprecated. Use the default constructor instead.", error: true)]
public static NUnitEqualityComparer Default { get; }
}
}Should we make the obsoletion a warning or error? I prefer error because it helpfully points people to the necessary refactor while flushing out all uses but I could go either way.