I am creating an internal class to provide a construct for the Contract pattern.
using System;
using System.Runtime.Serialization;
namespace DCS2000.Common35.Core
{
public class Assertion
{
public static void Ensure(bool test)
{
if (!test)
{
throw new PreconditionException("Precondition test failed");
}
}
public static void Ensure(object obj)
{
if (obj == null)
{
throw new PreconditionException("Precondition null object failed");
}
}
public static void Require(bool test)
{
if (!test)
{
throw new PostconditionException("Postcondition test failed");
}
}
public static void Require(object obj)
{
if (obj == null)
{
throw new PostconditionException("Postcondition null object failed");
}
}
}
}
When a developer goes to use this they will see these as options in Intellisense:
- Ensure
- Equals
- ReferenceEquals
- Require
This is confusing and I am wondering if there is a way to hide Equals and ReferenceEquals.
NOTE: I have already tried this, but it did not work for me:
[EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object obj)
{
return base.Equals(obj);
}