Another .NET Blog

To content | To menu | To search

Tag - Code Contracts

Entries feed - Comments feed

Thursday 14 January 2010

Nouvelle release de Code Contracts

Hier soir est sortie une nouvelle release de Code Contracts, à télécharger ici.

Pour info, la release note:

Release 1.2.30113.1 (Jan 13, 2010) Contracts

  • Silverlight 4 support added, Silverlight2 dropped.
  • We now have a set of contract reference assemblies for the different target frameworks (3.5, 4.0, Silverlight 3.0, Silverlight 4.0). This allows contracts on newer APIs and avoids problems where the rewriter added the wrong references to the target assembly.
  • Contract invariant methods now must be private.
  • Invariants on auto properties are turned into pre and post conditions of the corresponding setter and getter. This permits using auto properties with contracts.
  • Added more contracts to System.Linq, System.Net, System.Collections, System.Data, System.Math namespaces
  • Fixed issues of referencing v3.5 assemblies with contracts from v4.0 projects
  • Tweaks to extraction of contracts from VB constructors

Runtime Checker

  • Makes sure contract invariant methods are not called directly
  • Object invariants are now delayed until the end of the constructor to avoid checking them prematurely
  • Fixes to contract inheritance that would generate bad IL.
  • Avoid FxCop warnings about catching all exceptions in OldValue expressions
  • Initial support for ContractIgnoredAttribute added (see documentation)
  • Fix in rewriting attributes with arrays of enums
  • Fixed codegen issues when removing Assert/Assumes from code

Documentation Generation

  • Fixed path problems
  • Fixed inheritance problems

Static Checker

  • Improved handling of IsNan
  • Improved error messages now include the condition in all cases (not just for other assemblies)
  • Improved interval analysis
  • Improved handling of box operations
  • Squigglies now work in VS2010
  • Fixed handling of unicode error messages in the output
  • Better handling of IntPtr and UIntPtr
  • Better handling of inferred mutations at method calls
  • Masking of warnings at the assembly level using SuppressMessage now supported for global warnings

Monday 21 December 2009

Go go PEX et Code Contracts !!!

Si vous ne connaissez pas PEX ou Code Contracts, bonne nouvelle! Il existe un podcast en français (oui oui!) qui présente très succinctement ces 2 nouveaux outils prévus pour .NET 4.0 qui vous permettront de faciliter vos développements en TDD.

En effet, Code Contracts vous permet de définir dans le corps de vos fonctions des contrats (étonnant non?) qui vont porter sur les valeurs d'entrée et de sortie de vos fonctions. Ça vous permet d'éviter toutes ces séries de tests rébarbatives vérifiant par exemple que ArgumentNullException est bien lancée quand vous passez un null, ou qu'une fonction ne retourne jamais null. De quoi alléger un peu les test.

PEX quant à lui va vous permettre d'automatiser l'appel des fonctions avec des valeurs plus ou moins aléatoires, ce qui va vous permettre de voir dans quelle mesure vos tests unitaires couvrent bien l'intégralité des possibilités d'erreur (ou non) lorsque vous utilisez ces fonctions.

2 nouveaux outils que je trouve vraiment très intéressant et pour lesquels je pense faire prochainement des articles lorsque je commencerai à les utiliser.

Via Coq Blog.