|
|
DesignByContract
DesignByContract lets you specify constraint and checks to your code.
Introduction
You can find an introduction to design by contract here.
Details
Current features:
- Check for null parameters and return values
- Check for empty string parameters and return values
- Define singletons classes
Usage
Download source code from svn repository. Built it and copy Torch.DesignByContract.dll, Torch.DesignByContract.Weaver.dll and Torch.DesignByContract.psplugin to the PlugIns directory under the PostSharp installation location. Reference Torch.DesignByContract.dll from your project.
NonNull/NonEmpty
[return: NonNull] public SomeObject SomeMethod([NonNull] AnotherObject param1)
{
...
}Singleton
Declaration
[Singleton]
public class MySingletonCandidate
{
// default constructor
public MySingletonCandidate()
{
...
}
...
}Using the class
Just like any other class, if you are compiling against the plain class (not yet enhaced)MySingletonCandidate obj1 = new MySingletonCandidate();OrMySingletonCandidate obj1 = MySingletonCandidate.Instance;If you are compiling against the enhaced class.
Comments to altobarba at gmail dot com, or posting in the postsharp's forum.
Ignacio Vivona.
Sign in to add a comment
