Fugue is a defect detection tool for .net software, which lets you record the rules for using a class or interface and then check whether code that uses the class or interface is obeying the rules. For example, Fugue can show you the places where null is stored in a field that should not be null, where your code neglects to call Dispose on an IDisposable object or uses the object after calling Dispose, where an object’s methods are being called in the wrong order, and even where the code makes domain-specific mistakes, such as creating a SqlCommand object on a bad sql query. When you run Fugue, it analyzes your code and prints a list of error messages and warnings, just like a compiler.
You can constrain the order in which an object’s methods may be called.
public Socket (...);
public void Bind (EndPoint localEP);
[ChangesState(”raw”, ”connected”), ChangesState(”bound”, ”connected”)]
public void Connect (EndPoint remoteEP);
public int Send (...);
public int Receive (...);
public void Shutdown (SocketShutdown how);
public void Close ();
You can use Nullness attributes To record whether an object can be null, you give the object’s declaration one of the following three attributes:
[NotNull] The object cannot be null.
[Null] The object is definitely null.1
[MayBeNull] The object might or might not be null.
[NotNull] private string name;
public string Name
public NullDemo([MayBeNull] string nm)
this.name = ( nm == null) ? "default" : nm ;
[return : MayBeNull]
public string GetOrigName()
return this.name.Equals("default") ? null : this.name;