[Mono-list] Design by Contract
Joshua Tauberer
tauberer@for.net
Fri, 31 Dec 2004 10:10:53 -0500 (EST)
> So, is support for DBC something that anyone would be willing to see in
> mcs? Is it even something the mcs folks would allow as a patch, or would
> I need to maintain a separate fork of mcs (something I'm not really
> willing to do)?
Rather than integrating DBC directly into mcs, it would (IMO) be better to
patch mcs with unobtrusive hooks that 'compiler extensions' can use, and
then write DBC entirely outside of mcs.
For instance, by adding a class to mcs with some delegates:
class Extensions {
public static MethodBodyPreGenerationHandler MethodBodyPreGeneration;
public delegate void MethodBodyPreGenerationHandler(MethodBase method,
ILGenerator ilgen);
}
And then sprinkled in various places in the compiler things like:
if (Extensions.MethodBodyPreGeneration != null)
Extensions.MethodBodyPreGeneration(method, ilgen);
- Josh