<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Introduction to Code Contracts [Melitta Andersen]</title><link>http://blogs.msdn.com/b/bclteam/archive/2008/11/11/introduction-to-code-contracts-melitta-andersen.aspx</link><description>This blog post is to provide a bit more detail about the Code Contracts feature that was recently announced at the PDC and in Justin’s blog entry , and that can be found in the Visual Studio 2010 and .NET Framework 4.0 CTP . I’ll include some information</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>Relacja z C2C (Communities to Communities) 2009</title><link>http://blogs.msdn.com/b/bclteam/archive/2008/11/11/introduction-to-code-contracts-melitta-andersen.aspx#9480014</link><pubDate>Mon, 16 Mar 2009 02:00:35 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9480014</guid><dc:creator>. jak .NET by Maciej Aniserowicz</dc:creator><description>&lt;p&gt;Relacja z C2C (Communities to Communities) 2009&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9480014" width="1" height="1"&gt;</description></item><item><title>Relacja z C2C (Communities to Communities) 2009</title><link>http://blogs.msdn.com/b/bclteam/archive/2008/11/11/introduction-to-code-contracts-melitta-andersen.aspx#9480011</link><pubDate>Mon, 16 Mar 2009 01:59:14 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9480011</guid><dc:creator>. jak .NET by Maciej Aniserowicz</dc:creator><description>&lt;p&gt;Dzień: 14 marca 2009. Miejsce: Wydział Biologii UW. Wydarzenie: druga edycja konferencji Communities&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9480011" width="1" height="1"&gt;</description></item><item><title>Preview of Code Contract Tools Now Available</title><link>http://blogs.msdn.com/b/bclteam/archive/2008/11/11/introduction-to-code-contracts-melitta-andersen.aspx#9458864</link><pubDate>Wed, 04 Mar 2009 23:06:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9458864</guid><dc:creator>CLR Team Blog</dc:creator><description>&lt;p&gt;We’ve mentioned Code Contracts over on the BCL Blog a few times now, but never yet on the CLR Blog. Basically,&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9458864" width="1" height="1"&gt;</description></item><item><title>Preview of Code Contract Tools Now Available [Melitta Andersen]</title><link>http://blogs.msdn.com/b/bclteam/archive/2008/11/11/introduction-to-code-contracts-melitta-andersen.aspx#9441885</link><pubDate>Tue, 24 Feb 2009 02:02:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9441885</guid><dc:creator>BCL Team Blog</dc:creator><description>&lt;p&gt;In my Introduction to Code Contracts post, I mentioned that the tools to enable runtime checking and&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9441885" width="1" height="1"&gt;</description></item><item><title>re: Introduction to Code Contracts [Melitta Andersen]</title><link>http://blogs.msdn.com/b/bclteam/archive/2008/11/11/introduction-to-code-contracts-melitta-andersen.aspx#9160748</link><pubDate>Mon, 01 Dec 2008 19:11:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9160748</guid><dc:creator>Flavien Charlon</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Contracts are really nice.&lt;/p&gt;
&lt;p&gt;In order to be able to use them properly though, we will need pre and postconditions from all the classes we use in our program, for exemple, List&amp;lt;T&amp;gt;.Count is always positive or zero.&lt;/p&gt;
&lt;p&gt;Are you going to update the whole BCL with code contracts for .NET 4.0? This sounds like a huge work, but without that, contracts won't be usable at their full potential.&lt;/p&gt;
&lt;p&gt;My second question is why C# wouldn't have a syntax that would get translated into CodeContracts upon compilation.&lt;/p&gt;
&lt;p&gt;With this we get a good langage support in C#, as well as the ability to have it supported accross all CLR langages.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9160748" width="1" height="1"&gt;</description></item><item><title>契約によるプログラミング.NET</title><link>http://blogs.msdn.com/b/bclteam/archive/2008/11/11/introduction-to-code-contracts-melitta-andersen.aspx#9142081</link><pubDate>Tue, 25 Nov 2008 18:08:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9142081</guid><dc:creator>biac の それさえもおそらくは幸せな日々@nifty</dc:creator><description>&lt;p&gt;InfoQ に日本語記事が載ったので f(^^; .NET 4 の新機能を探る： コード契約作者 Jonathan Allen, 翻訳者 金森 諭 投稿日 2008年11月22日 午前12時53分 契約による設計は静的型付けのように、 コンパイル時に検証されないと一定の動作を実行することができないという考え方だ。 契約&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9142081" width="1" height="1"&gt;</description></item><item><title>Various Links</title><link>http://blogs.msdn.com/b/bclteam/archive/2008/11/11/introduction-to-code-contracts-melitta-andersen.aspx#9130259</link><pubDate>Thu, 20 Nov 2008 23:02:35 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9130259</guid><dc:creator>Mike Taulty's Blog</dc:creator><description>&lt;p&gt;I've been catching up on my blog reading...interesting stuff I came across; PNRP in Windows 7 being...&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9130259" width="1" height="1"&gt;</description></item><item><title>re: Introduction to Code Contracts [Melitta Andersen]</title><link>http://blogs.msdn.com/b/bclteam/archive/2008/11/11/introduction-to-code-contracts-melitta-andersen.aspx#9102764</link><pubDate>Sun, 16 Nov 2008 12:24:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9102764</guid><dc:creator>int19h</dc:creator><description>&lt;p&gt;Judging by its past track, one .NET language that will almost certainly provide syntactic sugar for the library contracts is Delphi Prism (aka RemObjects Oxygene). They do in fact already have &amp;quot;require&amp;quot;, &amp;quot;ensure&amp;quot;, and &amp;quot;invariant&amp;quot; keywords, so it would make sense for them to plug them into those BCL bits for .NET 4.0, and extend the syntax to cover all other cases (&amp;quot;require ... on raise ...&amp;quot; etc).&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9102764" width="1" height="1"&gt;</description></item><item><title>re: Introduction to Code Contracts [Melitta Andersen]</title><link>http://blogs.msdn.com/b/bclteam/archive/2008/11/11/introduction-to-code-contracts-melitta-andersen.aspx#9098000</link><pubDate>Sat, 15 Nov 2008 16:57:04 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9098000</guid><dc:creator>Steven the .NET Junkie</dc:creator><description>&lt;p&gt;I don't like using attributes for the contracts. It’s almost impossible to do compile time checking on them, and they’re very verbose. I've seen Spec# and it has the ideal language syntax. I hope this syntax makes it to C# 5.0. (Well… I'm really hoping C# 4.0 will have all this, but I know this isn't going to happen ;-)).&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9098000" width="1" height="1"&gt;</description></item><item><title>re: Introduction to Code Contracts [Melitta Andersen]</title><link>http://blogs.msdn.com/b/bclteam/archive/2008/11/11/introduction-to-code-contracts-melitta-andersen.aspx#9080968</link><pubDate>Sat, 15 Nov 2008 02:27:34 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9080968</guid><dc:creator>BCL Team</dc:creator><description>&lt;p&gt;Hi Judah,&lt;/p&gt;
&lt;p&gt;Thanks for pointing out that I neglected to mention how code contracts work on interfaces. &amp;nbsp;As you've said, you can't put code into interface methods. &amp;nbsp;What you do is create a separate class to contain the contracts that &amp;lt;i&amp;gt;explicitly&amp;lt;/i&amp;gt; implements the interface. &amp;nbsp;Then you link them with a pair of attributes: &amp;nbsp;[ContractClass(Type)] and [ContractClassFor(Type)]. &amp;nbsp;For example you could have an interface IFoo &amp;nbsp;with a class IFooContract that contains the contracts.&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;[ContractClass(typeof(IFooContract))]&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;interface IFoo&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;int DoSomething(string parameter);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;[ContractClassFor(typeof(IFoo))]&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;sealed class IFooContract : IFoo&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;int IFoo.DoSomething(string parameter)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CodeContract.Requires(parameter != null);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CodeContract.Ensures(0 &amp;lt;= CodeContract.Result&amp;lt;int&amp;gt;());&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;throw new NotImplementedException(&amp;quot;This method is only for interface contracts. &amp;nbsp;Do not call&amp;quot;);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt;As for your question about attributes, if they were powerful enough, we certainly would have considered using them to implement contracts, though I can't say for sure what we would have decided. &amp;nbsp; &amp;nbsp;As it is, we don't know of any plans for more expressive attributes, and even if they do come along later, we would already have an established contracts system. &amp;nbsp;There would by that point be many factors to take into consideration when looking at adding attribute support.&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Melitta&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9080968" width="1" height="1"&gt;</description></item></channel></rss>