Fugue ( Software protocol checker for languages compiling to MSIL )

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.

[WithProtocol(”raw”,”bound”,”connected”,”down”)]
class Socket
{
    [Creates(”raw”)]
    public Socket (...);
    [ChangesState(”raw”, ”bound”)]
    public void Bind (EndPoint localEP);
    [ChangesState(”raw”, ”connected”), ChangesState(”bound”, ”connected”)]
    public void Connect (EndPoint remoteEP);
    [InState(”connected”)]
    public int Send (...);
    [InState(”connected”)]
    public int Receive (...);
    [ChangesState(”connected”, ”down”)]
    public void Shutdown (SocketShutdown how);
    [Disposes(State.Any)]
    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.

 

class NullDemo
{
    [NotNull] private string name;
  [NotNull]
    public string Name
    {
        get
        {
            return 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;
    }
 }
 
Download Figue

 
 
 

Leave a Reply