Design by Contract

Share with us how you use PostSharp, or how you would like to use it.

Re: Design by Contract

Postby blahetal on Sun Mar 09, 2008 3:56 pm

I have read that Spec# is partially implemented in the .NET 3.5 but its not possible to use it because all its classes are marked as internal. So I got felling that MS is planning to support DbC in the next main release of .net framework.
Spec# in .NET 3.5 - http://geekswithblogs.net/Podwysocki/archive/2007/12/10/117542.aspx


Well, I think MS is slowly working on adopting all successful open source projects. For instance NAnt vs MSBuild, NUnit/MbUnit vs MSTest framework, log4net vs entlib (logging block), IoC containers (eg. Castle Project) vs rather new Unity.
IMO its only a question of time when they realise that having DbC and AOP in .NET framework would be cool :)

Anyway do you know LinFu? Its a framework for .NET that allows programmers to use some advanced programming techniques like duck typing, IoC, proxies, AOP and even DbC.
Here is a tutorial describing its potential
http://www.codeproject.com/KB/cs/LinFuPart1.aspx

Libor
blahetal
 
Posts: 13
Joined: Sat Jan 12, 2008 4:55 pm
Full Name: blahetal

Re: Design by Contract

Postby cocotapioca on Mon Mar 10, 2008 5:16 pm

Nice lib. LinFu looks nice, and the contract examples seems like a path to follow. In my code i inject the verifications for NonNull/NonEmpty directly in the IL code. But i dont want that the user, do the same thing with some business contract. Maybe some translation of th IL from a custom contract to the IL of the target method/class/whatever. Only if we want to add this capabilities at compile time.

Now im trying to add the NonNull attribute to return types (to the method actually) too.

Cheers.
Ignacio.
Ignacio Vivona
cocotapioca
 
Posts: 19
Joined: Sat Jan 12, 2008 4:55 pm
Full Name: Ignacio Vivona

Re: Design by Contract

Postby cocotapioca on Mon Mar 10, 2008 7:39 pm

Ill made some more coding and then ill upload the code to the project page.

Ignacio.
Ignacio Vivona
cocotapioca
 
Posts: 19
Joined: Sat Jan 12, 2008 4:55 pm
Full Name: Ignacio Vivona

Re: Design by Contract

Postby soren on Mon Mar 10, 2008 7:52 pm

I'm not likely to be able to spend very much time on improving my code in the near future. Anyway, what Ignacio and LinFu are doing seem to be better approaches. If anyone want to take over my code, feel free.
/soren
Soren Skovsboll
soren
 
Posts: 15
Joined: Sat Jan 12, 2008 4:55 pm
Full Name: Soren Skovsboll

Re: Design by Contract

Postby cocotapioca on Wed Mar 12, 2008 3:14 pm

Hi people!
I'm trying to add the NonNull to return values. My idea is to rewrite the method adding the verifications before the Ret OpCode. To do this i'm reading the instructions of the method body and putting then in a list. But when i try to iterate over the list, all the instructions are Ret (but when i store then in the list were the proper instructions).
What's happening?
Someone have another approach?

Cheers.
Ignacio.
Ignacio Vivona
cocotapioca
 
Posts: 19
Joined: Sat Jan 12, 2008 4:55 pm
Full Name: Ignacio Vivona

Re: Design by Contract

Postby gfraiteur on Wed Mar 12, 2008 3:41 pm

You should use an advice of kind AfterMethodBodySuccess. The value being returned is in the variable context.ReturnValueVariable.
Gael Fraiteur, project leader
got good support? consider donating to the project.
gfraiteur
Site Admin
 
Posts: 581
Joined: Tue Dec 18, 2007 3:09 pm
Full Name: Gael Fraiteur
Company: postsharp.org

Re: Design by Contract

Postby cocotapioca on Thu Mar 13, 2008 12:45 am

Thanks! That was all i need.
Now it's working.

Ignacio.
Ignacio Vivona
cocotapioca
 
Posts: 19
Joined: Sat Jan 12, 2008 4:55 pm
Full Name: Ignacio Vivona

Re: Design by Contract

Postby cocotapioca on Fri Mar 14, 2008 9:41 pm

I pack everything (well, the code so far) as a plugin and i wanna upload it to the project page. How is the process to do that?
The license stuff is like postsharp/laos, the public attributes are unde LGPL 3 and the weaver is under GPL 3.
Distribution -> Zip file, installer later

Cheers.
Ignacio
Ignacio Vivona
cocotapioca
 
Posts: 19
Joined: Sat Jan 12, 2008 4:55 pm
Full Name: Ignacio Vivona

Re: Design by Contract

Postby gfraiteur on Fri Mar 14, 2008 11:35 pm

Good news! Communicate me your Google account id (e.g. [unused] gmail account) and I will make you a project admin.

Gael
Gael Fraiteur, project leader
got good support? consider donating to the project.
gfraiteur
Site Admin
 
Posts: 581
Joined: Tue Dec 18, 2007 3:09 pm
Full Name: Gael Fraiteur
Company: postsharp.org

Re: Design by Contract

Postby blahetal on Sun Mar 16, 2008 7:37 pm

great, please let us know when you release it :)
blahetal
blahetal
 
Posts: 13
Joined: Sat Jan 12, 2008 4:55 pm
Full Name: blahetal

PreviousNext

Return to What To Do With PostSharp?