<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JAPF &#187; Tools</title>
	<atom:link href="http://www.japf.fr/category/tools/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.japf.fr</link>
	<description>Jeremy Alles Presentation Foundation: WPF, Silverlight, Windows Phone 7, Windows 8</description>
	<lastBuildDate>Fri, 27 Jan 2012 07:57:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>ReSharper and code generation</title>
		<link>http://www.japf.fr/2012/01/resharper-and-code-generation/</link>
		<comments>http://www.japf.fr/2012/01/resharper-and-code-generation/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 12:58:39 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[resharper]]></category>

		<guid isPermaLink="false">http://www.japf.fr/?p=1053</guid>
		<description><![CDATA[I don&#8217;t know why I&#8217;ve found this feature only today, but I wanted to share another great feature of ReSharper. Let say you need to implement a C# structure. You may start with the following code: ?View Code CSHARP1 2 3 4 5 6 public struct ServerItem &#123; public string Id &#123; get; private set; [...]]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t know why I&#8217;ve found this feature only today, but I wanted to share another great feature of ReSharper. Let say you need to implement a C# structure. You may start with the following code:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1053code4'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10534"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p1053code4"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">struct</span> ServerItem
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Id <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> <span style="color: #0600FF; font-weight: bold;">private</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> DateTime<span style="color: #008000;">?</span> Added <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> <span style="color: #0600FF; font-weight: bold;">private</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> ChildCount <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> <span style="color: #0600FF; font-weight: bold;">private</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>Then you start thinking, &#8220;I need to setup a constructor&#8230;&#8221; You can do it manually, but you can also ask ReSharper do to the job for you. All you have to do is press ALT+Enter (this might depend on your configuration obviously&#8230;)</p>
<p><a href="http://www.japf.fr/wp-content/uploads/2012/01/GeneratorCtor.png" rel="lightbox[1053]"><img class="alignnone size-full wp-image-1056" title="GeneratorCtor" src="http://www.japf.fr/wp-content/uploads/2012/01/GeneratorCtor.png" alt="" width="324" height="237" /></a></p>
<p>ReSharper will generate the constructor for you:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1053code5'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10535"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="p1053code5"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">struct</span> ServerItem
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> ServerItem<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> id, DateTime<span style="color: #008000;">?</span> added, <span style="color: #6666cc; font-weight: bold;">int</span> childCount<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">:</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Id</span> <span style="color: #008000;">=</span> id<span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Added</span> <span style="color: #008000;">=</span> added<span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ChildCount</span> <span style="color: #008000;">=</span> childCount<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Id <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> <span style="color: #0600FF; font-weight: bold;">private</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> DateTime<span style="color: #008000;">?</span> Added <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> <span style="color: #0600FF; font-weight: bold;">private</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> ChildCount <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> <span style="color: #0600FF; font-weight: bold;">private</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>Fine. Then you remember that you also need to setup equality members properly&#8230; You have to override Equals, GetHashCode&#8230; This is not complicated but it can become cumbersome and it often feels like a waste of time. Here is the ReSharper way of doing this:</p>
<p>1. Press ALT+Enter</p>
<p><a href="http://www.japf.fr/wp-content/uploads/2012/01/GenerateEquals0.png" rel="lightbox[1053]"><img class="alignnone size-full wp-image-1054" title="GenerateEquals0" src="http://www.japf.fr/wp-content/uploads/2012/01/GenerateEquals0.png" alt="" width="433" height="236" /></a></p>
<p>2. Choose &#8220;Equality members&#8221; and setup the code generation:</p>
<p><a href="http://www.japf.fr/wp-content/uploads/2012/01/GenerateEquals1.png" rel="lightbox[1053]"><img class="alignnone  wp-image-1055" title="GenerateEquals1" src="http://www.japf.fr/wp-content/uploads/2012/01/GenerateEquals1.png" alt="" width="378" height="378" /></a></p>
<p>And BOOOM ! You&#8217;re done:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1053code6'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10536"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
</pre></td><td class="code" id="p1053code6"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">struct</span> ServerItem
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> ServerItem<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> id, DateTime<span style="color: #008000;">?</span> added, <span style="color: #6666cc; font-weight: bold;">int</span> childCount<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">:</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Id</span> <span style="color: #008000;">=</span> id<span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Added</span> <span style="color: #008000;">=</span> added<span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ChildCount</span> <span style="color: #008000;">=</span> childCount<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Id <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> <span style="color: #0600FF; font-weight: bold;">private</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> DateTime<span style="color: #008000;">?</span> Added <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> <span style="color: #0600FF; font-weight: bold;">private</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> ChildCount <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> <span style="color: #0600FF; font-weight: bold;">private</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">bool</span> Equals<span style="color: #008000;">&#40;</span>ServerItem other<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span> Equals<span style="color: #008000;">&#40;</span>other<span style="color: #008000;">.</span><span style="color: #0000FF;">Id</span>, <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Id</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&amp;&amp;</span> other<span style="color: #008000;">.</span><span style="color: #0000FF;">Added</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Equals</span><span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Added</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&amp;&amp;</span> other<span style="color: #008000;">.</span><span style="color: #0000FF;">ChildCount</span> <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ChildCount</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">override</span> <span style="color: #6666cc; font-weight: bold;">bool</span> Equals<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> obj<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>ReferenceEquals<span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">null</span>, obj<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>obj<span style="color: #008000;">.</span><span style="color: #0000FF;">GetType</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">!=</span> <span style="color: #008000;">typeof</span><span style="color: #008000;">&#40;</span>ServerItem<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span> Equals<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>ServerItem<span style="color: #008000;">&#41;</span>obj<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">override</span> <span style="color: #6666cc; font-weight: bold;">int</span> GetHashCode<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #008000;">unchecked</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #6666cc; font-weight: bold;">int</span> result <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Id</span> <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">?</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Id</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetHashCode</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">:</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            result <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>result <span style="color: #008000;">*</span> <span style="color: #FF0000;">397</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">^</span> <span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Added</span><span style="color: #008000;">.</span><span style="color: #0000FF;">HasValue</span> <span style="color: #008000;">?</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Added</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetHashCode</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">:</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            result <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>result <span style="color: #008000;">*</span> <span style="color: #FF0000;">397</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">^</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ChildCount</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> result<span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">bool</span> <span style="color: #0600FF; font-weight: bold;">operator</span> <span style="color: #008000;">==</span><span style="color: #008000;">&#40;</span>ServerItem left, ServerItem right<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span> left<span style="color: #008000;">.</span><span style="color: #0000FF;">Equals</span><span style="color: #008000;">&#40;</span>right<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">bool</span> <span style="color: #0600FF; font-weight: bold;">operator</span> <span style="color: #008000;">!=</span><span style="color: #008000;">&#40;</span>ServerItem left, ServerItem right<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #008000;">!</span>left<span style="color: #008000;">.</span><span style="color: #0000FF;">Equals</span><span style="color: #008000;">&#40;</span>right<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>The code-generation features of ReSharper has been there for a long time&#8230; But because I just found out the power of them, I wanted to briefly showcased them in this post <img src='http://www.japf.fr/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.japf.fr/2012/01/resharper-and-code-generation/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>If you like typing XAML you will love ReSharper 6.1 !</title>
		<link>http://www.japf.fr/2012/01/if-you-like-typing-xaml-you-will-love-resharper-6-1/</link>
		<comments>http://www.japf.fr/2012/01/if-you-like-typing-xaml-you-will-love-resharper-6-1/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 17:42:25 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Windows 8]]></category>
		<category><![CDATA[Windows Phone]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[resharper]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://www.japf.fr/?p=1029</guid>
		<description><![CDATA[Resharper is an amazing tool for any .Net developers. The latest version 6.1 has been released just a couple of weeks ago and I wanted to share with you a brief overview of the new workflow available in the XAML world ! Visual Studio 2010 introduced 2 new design time properties: d:DesignInstance and d:DesignData. Those [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.jetbrains.com/resharper/">Resharper</a> is an amazing tool for any .Net developers. The latest version 6.1 has been released just a couple of weeks ago and I wanted to share with you a brief overview of the new workflow available in the XAML world !</p>
<p>Visual Studio 2010 introduced 2 new design time properties: d:DesignInstance and d:DesignData. Those properties can be used in order to specify a design time DataContext in order to have more help during the creation of a binding.</p>
<p>For example, when you create a binding using the Property dialog of VS2010 you can browse your DataContext to select the right property (image from this <a href="http://karlshifflett.wordpress.com/2009/10/28/ddesigninstance-ddesigndata-in-visual-studio-2010-beta2/">blog post</a> from <a href="http://karlshifflett.wordpress.com/">Karl Shifflet</a>):</p>
<p><a href="http://www.japf.fr/wp-content/uploads/2012/01/bindingbuilder_thumb.png" rel="lightbox[1029]"><img class="alignnone size-medium wp-image-1031" title="bindingbuilder_thumb" src="http://www.japf.fr/wp-content/uploads/2012/01/bindingbuilder_thumb-300x291.png" alt="" width="300" height="291" /></a></p>
<p>Resharper 6.1 is now able to use those metadata in order to improve the experience you have while typing XAML (which I personally do a LOT!). Here is how it works:</p>
<ul>
<li>you create a new ViewModel with a simple property (this property has just get/set because we don&#8217;t need much more in the context of this post&#8230;)</li>
</ul>
<p><a href="http://www.japf.fr/wp-content/uploads/2012/01/01.png" rel="lightbox[1029]"><img class="alignnone size-medium wp-image-1034" title="01" src="http://www.japf.fr/wp-content/uploads/2012/01/01-300x99.png" alt="" width="300" height="99" /></a></p>
<ul>
<li>you setup a binding in your view</li>
</ul>
<p><a href="http://www.japf.fr/wp-content/uploads/2012/01/02.png" rel="lightbox[1029]"><img class="alignnone size-full wp-image-1035" title="02" src="http://www.japf.fr/wp-content/uploads/2012/01/02.png" alt="" width="514" height="126" /></a></p>
<p>At this point the ReSharper magic comes into play&#8230;</p>
<ul>
<li>ReSharper warns you the DataContext is unknown</li>
</ul>
<p><a href="http://www.japf.fr/wp-content/uploads/2012/01/02.1.png" rel="lightbox[1029]"><img class="alignnone size-full wp-image-1043" title="02.1" src="http://www.japf.fr/wp-content/uploads/2012/01/02.1.png" alt="" width="565" height="126" /></a></p>
<ul>
<li>Offer the ability to fix this</li>
</ul>
<p><a href="http://www.japf.fr/wp-content/uploads/2012/01/03.png" rel="lightbox[1029]"><img title="03" src="http://www.japf.fr/wp-content/uploads/2012/01/03.png" alt="" width="545" height="271" /></a></p>
<ul>
<li>Note that like in C#, you can very easily resolve namespace issues</li>
</ul>
<p><a href="http://www.japf.fr/wp-content/uploads/2012/01/041.png" rel="lightbox[1029]"><img class="alignnone size-full wp-image-1046" title="04" src="http://www.japf.fr/wp-content/uploads/2012/01/041.png" alt="" width="602" height="192" /></a></p>
<ul>
<li>Then notice that the warning is gone (the Title property is no longer underlined)</li>
</ul>
<p><a href="http://www.japf.fr/wp-content/uploads/2012/01/06.png" rel="lightbox[1029]"><img class="alignnone size-full wp-image-1039" title="06" src="http://www.japf.fr/wp-content/uploads/2012/01/06.png" alt="" width="577" height="191" /></a></p>
<ul>
<li>You can now add a new binding</li>
</ul>
<p><a href="http://www.japf.fr/wp-content/uploads/2012/01/07.png" rel="lightbox[1029]"><img class="alignnone size-full wp-image-1040" title="07" src="http://www.japf.fr/wp-content/uploads/2012/01/07.png" alt="" width="576" height="207" /></a></p>
<ul>
<li>You can then ask ReSharper to create the property in your ViewModel</li>
</ul>
<p><a href="http://www.japf.fr/wp-content/uploads/2012/01/08.png" rel="lightbox[1029]"><img class="alignnone size-full wp-image-1041" title="08" src="http://www.japf.fr/wp-content/uploads/2012/01/08.png" alt="" width="580" height="378" /></a></p>
<ul>
<li>Choosing the first option will get you to the ViewModel definition</li>
</ul>
<p><a href="http://www.japf.fr/wp-content/uploads/2012/01/09.png" rel="lightbox[1029]"><img class="alignnone size-full wp-image-1042" title="09" src="http://www.japf.fr/wp-content/uploads/2012/01/09.png" alt="" width="417" height="242" /></a></p>
<p>Now that I&#8217;ve upgraded my installation to version 6.1, I think this is a must have !</p>
<p>That&#8217;s all for today ! Hope it helps <img src='http://www.japf.fr/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.japf.fr/2012/01/if-you-like-typing-xaml-you-will-love-resharper-6-1/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>R# can create resources for you in XAML</title>
		<link>http://www.japf.fr/2010/04/resharper-to-creates-resources-in-xaml/</link>
		<comments>http://www.japf.fr/2010/04/resharper-to-creates-resources-in-xaml/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 12:33:36 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[resharper]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://www.japf.fr/?p=498</guid>
		<description><![CDATA[I was aware for some time now that R# offers some support for editing XAML but I didn&#8217;t know the following features until recently.When you create a StaticResource in XAML, R# is able to help you by generating some code for you. The famous R# &#8220;bubble&#8221; shows up offering various options to create the resource: [...]]]></description>
			<content:encoded><![CDATA[<p>I was aware for some time now that R# offers some support for editing XAML but I didn&#8217;t know the following features until recently.When you create a StaticResource in XAML, R# is able to help you by generating some code for you. The famous R# &#8220;bubble&#8221; shows up offering various options to create the resource:</p>
<p><a href="http://www.japf.fr/wp-content/uploads/2010/04/2.png" rel="lightbox[498]"><img class="alignnone size-full wp-image-501" title="2" src="http://www.japf.fr/wp-content/uploads/2010/04/2.png" alt="" width="507" height="191" /></a></p>
<p>Then the resource is automatically created for you:</p>
<p><a href="http://www.japf.fr/wp-content/uploads/2010/04/3.png" rel="lightbox[498]"><img class="alignnone size-full wp-image-502" title="3" src="http://www.japf.fr/wp-content/uploads/2010/04/3.png" alt="" width="469" height="173" /></a></p>
<p>Note that it works with converter too:</p>
<p><a href="http://www.japf.fr/wp-content/uploads/2010/04/4.png" rel="lightbox[498]"><img class="alignnone size-full wp-image-503" title="4" src="http://www.japf.fr/wp-content/uploads/2010/04/4.png" alt="" width="691" height="255" /></a></p>
<p>R# 5.0 has been released a couple of weeks ago. Go ahead and <a href="http://www.jetbrains.com/resharper/">grab your copy</a> !</p>
]]></content:encoded>
			<wfw:commentRss>http://www.japf.fr/2010/04/resharper-to-creates-resources-in-xaml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Leveraging expression trees to unit test ViewModel classes</title>
		<link>http://www.japf.fr/2010/03/leveraging-expression-trees-to-unit-test-viewmodel-classes/</link>
		<comments>http://www.japf.fr/2010/03/leveraging-expression-trees-to-unit-test-viewmodel-classes/#comments</comments>
		<pubDate>Tue, 23 Mar 2010 13:36:53 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[model-view-viewmodel]]></category>
		<category><![CDATA[moq]]></category>
		<category><![CDATA[mvvm]]></category>
		<category><![CDATA[test]]></category>

		<guid isPermaLink="false">http://www.japf.fr/?p=483</guid>
		<description><![CDATA[Introduction: In this article, I&#8217;m describing a technique which leverage the expression trees of C# 3.0 in order to facilitate the unit testing of ViewModel&#8217;s properties. My final goal is to be able to unit test a ViewModel property in 1 line. Without any doubt MVVM is now the most used framework to leverage WPF [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Introduction:</strong> In this article, I&#8217;m describing a technique which leverage the expression trees of C# 3.0 in order to facilitate the unit testing of ViewModel&#8217;s properties. My final goal is to be able to unit test a ViewModel property in 1 line.</p>
<p>Without any doubt MVVM is now the most used framework to leverage WPF and Silverlight functionalities in the best way ! During the last <a href="http://live.visitmix.com">Mix</a>, 3 sessions were dedicated to this methodology (you can watch the videos online <a href="http://live.visitmix.com/Videos">here</a>).</p>
<p>As you already know one of the key advantage of the MVVM methodology is to <strong>improve the testability</strong> of the overall application by reducing the amount of code in the code-behind and producing ViewModel classes which are testable. We use to say that ViewModel classes are testable because:</p>
<ul>
<li>they are not coupled to UI concepts (controls, focus, keyboard input&#8230;)</li>
<li>they can wrap model objects using interfaces (for instance a PersonViewModel wraps a IPerson object)</li>
<li>they are not subclassing a UI control (such as Button or Window)</li>
</ul>
<p>Today I&#8217;d like to share a technique I&#8217;m using to facilitate the unit tests of some properties of my ViewModel classes.</p>
<p>Let&#8217;s use a very simple ViewModel class as example:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p483code14'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p48314"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
</pre></td><td class="code" id="p483code14"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> PersonViewModel <span style="color: #008000;">:</span> ViewModelBase
<span style="color: #008000;">&#123;</span>
  <span style="color: #0600FF; font-weight: bold;">private</span> IPerson person<span style="color: #008000;">;</span>
  <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">bool</span> isSelected<span style="color: #008000;">;</span>
&nbsp;
  <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Name 
  <span style="color: #008000;">&#123;</span>
     get
     <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">person</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span><span style="color: #008000;">;</span>
     <span style="color: #008000;">&#125;</span>
     set
     <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">person</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">OnPropertyChanged</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Name&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
     <span style="color: #008000;">&#125;</span>
  <span style="color: #008000;">&#125;</span>
&nbsp;
  <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">bool</span> IsSelected
  <span style="color: #008000;">&#123;</span>
    get
    <span style="color: #008000;">&#123;</span>
      <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">isSelected</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
    set
    <span style="color: #008000;">&#123;</span>
      <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">isSelected</span> <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span>
      <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">OnPropertyChanged</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;IsSelected&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
  <span style="color: #008000;">&#125;</span>
&nbsp;
  <span style="color: #008080; font-style: italic;">// rest of the code omitted for simplicity</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>The Name property, as usually with the MVVM pattern gets its value from the wrapped model object. The easiest way to unit test this property is to use a mocking library. Here is a example using <a href="http://code.google.com/p/moq/">MOQ</a> (my favourite mocking library):</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p483code15'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p48315"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code" id="p483code15"><pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&#91;</span>Test<span style="color: #008000;">&#93;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> TestName<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
  var mockPerson <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Mock<span style="color: #008000;">&lt;</span>IPerson<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
  var vm <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> PersonViewModel<span style="color: #008000;">&#40;</span>mockPerson<span style="color: #008000;">.</span><span style="color: #6666cc; font-weight: bold;">Object</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
  vm<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Jeremy&quot;</span><span style="color: #008000;">;</span>
&nbsp;
  <span style="color: #008080; font-style: italic;">// verify that the Name property of the IPerson interface has been set</span>
  mockPerson<span style="color: #008000;">.</span><span style="color: #0000FF;">VerifySet</span><span style="color: #008000;">&#40;</span>p <span style="color: #008000;">=&gt;</span> p<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Jeremy&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>The Selected property is different because it doesn&#8217;t wrap a model property. It&#8217;s an information that is added to the ViewModel layer in order to control a UI-related property (for example the IsSelected property of a ListBoxItem). This technique is heavily used to have ViewModel classes interact with the WPF or Silverlight TreeView or ListBox control (you can check out this <a href="http://www.codeproject.com/KB/WPF/TreeViewWithViewModel.aspx">excellent article</a> of Josh Smith for more detail).</p>
<p>In order to unit test this property, we must:<br />
1/ ensure the PropertyChanged event of the INotifyPropertyChanged is  raised properly<br />
2/ ensure we can write a value and read back the  correct value</p>
<p>Here is a sample code which does this unit test:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p483code16'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p48316"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code" id="p483code16"><pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&#91;</span>Test<span style="color: #008000;">&#93;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> TestName<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
var vm <span style="color: #008000;">=</span> <span style="color: #008000;">new</span>  PersonViewModel<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #6666cc; font-weight: bold;">bool</span> propertyChanged <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
&nbsp;
vm<span style="color: #008000;">.</span><span style="color: #0000FF;">PropertyChanged</span> <span style="color: #008000;">+=</span> <span style="color: #008000;">&#40;</span>s, e<span style="color: #008000;">&#41;</span> <span style="color: #008000;">=&gt;</span> propertyChanged <span style="color: #008000;">=</span> e<span style="color: #008000;">.</span><span style="color: #0000FF;">PropertyName</span> <span style="color: #008000;">==</span>  <span style="color: #666666;">&quot;Name&quot;</span><span style="color: #008000;">;</span>
vm<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;newName&quot;</span><span style="color: #008000;">;</span>
&nbsp;
Assert<span style="color: #008000;">.</span><span style="color: #0000FF;">IsTrue</span><span style="color: #008000;">&#40;</span>propertyChanged<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
Assert<span style="color: #008000;">.</span><span style="color: #0000FF;">AreEqual</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;newName&quot;</span>, vm<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>It quickly become cumbersome to copy/paste this unit test for all the ViewModel properties we have. That&#8217;s the reason I started thinking about another way to do it&#8230;</p>
<p>Here is the feature I&#8217;m proposing:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p483code17'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p48317"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p483code17"><pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&#91;</span>Test<span style="color: #008000;">&#93;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> TestName<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
var vm <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> PersonViewModel<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
TestHelper<span style="color: #008000;">.</span><span style="color: #0000FF;">TestProperty</span><span style="color: #008000;">&#40;</span>vm, v <span style="color: #008000;">=&gt;</span> v<span style="color: #008000;">.</span><span style="color: #0000FF;">IsSelected</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>In this sample, I&#8217;m telling I want to test the IsSelected property of the PersonViewModel type. The advantages are:<br />
1/ less code involved : 1 line to test 1 property<br />
2/ intellisense support in order to prevent typing error and no more &#8220;magic&#8221; string to give the name of the property<br />
3/ refactoring the name of the property will refactor this sample code too<br />
4/ automatic generation of default test values behind the scene</p>
<p><strong>How does it works ?</strong></p>
<ul>
<li>TestProperty treats the second parameter as an Expression&lt;Func&gt; and not as a Func directly</li>
<li>Using expression tree (the &#8220;v =&gt; v.IsSelected&#8221; part),  I&#8217;m able to retrieve the name of the property and its type</li>
<li>Using reflection, I&#8217;m able to get and set the value</li>
<li>Depending on the type of the property (string, bool, int, double), I have default values write and read back (with a test to ensure that the PropertyChanged event has been raised properly).</li>
</ul>
<p>Here is the code of the TestPropertyMethod:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p483code18'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p48318"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code" id="p483code18"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> TestProperty<span style="color: #008000;">&lt;</span>T, U<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span>T viewmodel, Expression<span style="color: #008000;">&lt;</span>Func<span style="color: #008000;">&lt;</span>T, U<span style="color: #008000;">&gt;&gt;</span> expression<span style="color: #008000;">&#41;</span>
    <span style="color: #0600FF; font-weight: bold;">where</span> T <span style="color: #008000;">:</span> INotifyPropertyChanged
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>expression<span style="color: #008000;">.</span><span style="color: #0000FF;">Body</span> <span style="color: #008000;">is</span> MemberExpression<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        MemberExpression memberExpression <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>MemberExpression<span style="color: #008000;">&#41;</span> expression<span style="color: #008000;">.</span><span style="color: #0000FF;">Body</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>expression<span style="color: #008000;">.</span><span style="color: #0000FF;">Body</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Type</span> <span style="color: #008000;">==</span> <span style="color: #008000;">typeof</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">bool</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            TestViewModelProperty<span style="color: #008000;">&#40;</span>viewmodel, memberExpression<span style="color: #008000;">.</span><span style="color: #0000FF;">Member</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span>, <span style="color: #0600FF; font-weight: bold;">true</span>, <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">else</span> <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>expression<span style="color: #008000;">.</span><span style="color: #0000FF;">Body</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Type</span> <span style="color: #008000;">==</span> <span style="color: #008000;">typeof</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            TestViewModelProperty<span style="color: #008000;">&#40;</span>viewmodel, memberExpression<span style="color: #008000;">.</span><span style="color: #0000FF;">Member</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span>, <span style="color: #666666;">&quot;value1&quot;</span>, <span style="color: #666666;">&quot;value2&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span> 
        <span style="color: #0600FF; font-weight: bold;">else</span> <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>expression<span style="color: #008000;">.</span><span style="color: #0000FF;">Body</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Type</span> <span style="color: #008000;">==</span> <span style="color: #008000;">typeof</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            TestViewModelProperty<span style="color: #008000;">&#40;</span>viewmodel, memberExpression<span style="color: #008000;">.</span><span style="color: #0000FF;">Member</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span>, <span style="color: #FF0000;">1</span>, <span style="color: #FF0000;">99</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">else</span> <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>expression<span style="color: #008000;">.</span><span style="color: #0000FF;">Body</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Type</span> <span style="color: #008000;">==</span> <span style="color: #008000;">typeof</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">double</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            TestViewModelProperty<span style="color: #008000;">&#40;</span>viewmodel, memberExpression<span style="color: #008000;">.</span><span style="color: #0000FF;">Member</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span>, <span style="color: #FF0000;">1.0</span>, <span style="color: #FF0000;">99.0</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">else</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">throw</span> <span style="color: #008000;">new</span> NotSupportedException<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Type is not supported&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
   <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>And the TestViewModelProperty:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p483code19'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p48319"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code" id="p483code19"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> TestViewModelProperty<span style="color: #008000;">&lt;</span>T, U<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span>T viewModel, <span style="color: #6666cc; font-weight: bold;">string</span> propertyName, U value1, U value2<span style="color: #008000;">&#41;</span>
    <span style="color: #0600FF; font-weight: bold;">where</span> T <span style="color: #008000;">:</span> INotifyPropertyChanged
<span style="color: #008000;">&#123;</span>
    <span style="color: #6666cc; font-weight: bold;">bool</span> propertyChanged<span style="color: #008000;">;</span>
    viewModel<span style="color: #008000;">.</span><span style="color: #0000FF;">PropertyChanged</span> <span style="color: #008000;">+=</span> <span style="color: #008000;">&#40;</span>s, e<span style="color: #008000;">&#41;</span> <span style="color: #008000;">=&gt;</span> propertyChanged <span style="color: #008000;">=</span> e<span style="color: #008000;">.</span><span style="color: #0000FF;">PropertyName</span> <span style="color: #008000;">==</span> propertyName<span style="color: #008000;">;</span>
&nbsp;
    propertyChanged <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
    viewModel<span style="color: #008000;">.</span><span style="color: #0000FF;">SetValue</span><span style="color: #008000;">&#40;</span>propertyName, value1<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    Assert<span style="color: #008000;">.</span><span style="color: #0000FF;">IsTrue</span><span style="color: #008000;">&#40;</span>propertyChanged<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    Assert<span style="color: #008000;">.</span><span style="color: #0000FF;">IsTrue</span><span style="color: #008000;">&#40;</span>viewModel<span style="color: #008000;">.</span><span style="color: #0000FF;">GetValue</span><span style="color: #008000;">&lt;</span>U<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span>propertyName<span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Equals</span><span style="color: #008000;">&#40;</span>value1<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    propertyChanged <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
    viewModel<span style="color: #008000;">.</span><span style="color: #0000FF;">SetValue</span><span style="color: #008000;">&#40;</span>propertyName, value2<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    Assert<span style="color: #008000;">.</span><span style="color: #0000FF;">IsTrue</span><span style="color: #008000;">&#40;</span>propertyChanged<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    Assert<span style="color: #008000;">.</span><span style="color: #0000FF;">IsTrue</span><span style="color: #008000;">&#40;</span>viewModel<span style="color: #008000;">.</span><span style="color: #0000FF;">GetValue</span><span style="color: #008000;">&lt;</span>U<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span>propertyName<span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Equals</span><span style="color: #008000;">&#40;</span>value2<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>I&#8217;m using 2 extensions methods in order to get and set value from the ViewModel object using reflection. Here they are:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p483code20'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p48320"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code" id="p483code20"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> T GetValue<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span> <span style="color: #6666cc; font-weight: bold;">object</span> obj, <span style="color: #6666cc; font-weight: bold;">string</span> propertyName<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    var propertyInfo <span style="color: #008000;">=</span> obj<span style="color: #008000;">.</span><span style="color: #0000FF;">GetType</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetProperty</span><span style="color: #008000;">&#40;</span>propertyName<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #008000;">&#40;</span>T<span style="color: #008000;">&#41;</span>propertyInfo<span style="color: #008000;">.</span><span style="color: #0000FF;">GetValue</span><span style="color: #008000;">&#40;</span>obj, <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> SetValue<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span> <span style="color: #6666cc; font-weight: bold;">object</span> obj, <span style="color: #6666cc; font-weight: bold;">string</span> propertyName, T value<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    var propertyInfo <span style="color: #008000;">=</span> obj<span style="color: #008000;">.</span><span style="color: #0000FF;">GetType</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetProperty</span><span style="color: #008000;">&#40;</span>propertyName<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    propertyInfo<span style="color: #008000;">.</span><span style="color: #0000FF;">SetValue</span><span style="color: #008000;">&#40;</span>obj, value, <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>Please feel free to <a href="http://www.japf.fr/wp-content/uploads/2010/03/TestViewModelHelper.txt">download the source code</a> of the ViewModelTestHelper class.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.japf.fr/2010/03/leveraging-expression-trees-to-unit-test-viewmodel-classes/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Mix10: Windows Phone 7 series development tools available</title>
		<link>http://www.japf.fr/2010/03/mix10-windows-phone-7-series-development-tools-available/</link>
		<comments>http://www.japf.fr/2010/03/mix10-windows-phone-7-series-development-tools-available/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 19:40:27 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Windows Phone]]></category>
		<category><![CDATA[mix10]]></category>

		<guid isPermaLink="false">http://www.japf.fr/?p=469</guid>
		<description><![CDATA[The first keynote of Mix10 is just over and the biggest announcement I was waiting for occured: Windows Phone 7 series development tools are NOW available for FREE. Grab the tools right now ! You&#8217;ll need: Expression Blend 4 Beta Windows Phone Developer Tools Expression Blend Add-in for Windows Phone Expression Blend SDK for Windows [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.japf.fr/wp-content/uploads/2010/03/Mix101.jpg" rel="lightbox[469]"><img class="alignnone size-full wp-image-456" title="Mix10" src="http://www.japf.fr/wp-content/uploads/2010/03/Mix101.jpg" alt="" width="157" height="96" /></a></p>
<p>The first keynote of Mix10 is just over and the biggest announcement I was waiting for occured: Windows Phone 7 series development tools are NOW available for FREE.</p>
<p>Grab the tools right now ! You&#8217;ll need:</p>
<ul>
<li><a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=6f014e07-0053-4aca-84a7-cd82f9aa989f&amp;displaylang=en">Expression Blend 4 Beta</a></li>
<li><a href="http://developer.windowsphone.com/windows-phone-7-series">Windows Phone Developer Tools</a></li>
<li><a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=47f5c718-9dec-4557-9687-619c0fdd3d4f&amp;displaylang=en">Expression Blend Add-in for Windows Phone</a></li>
<li><a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=86370108-4c14-42ee-8855-226e5dd9b85b">Expression Blend SDK for Windows Phone</a></li>
</ul>
<p>If you want more details about Blend4, you can check out Christian Schormann&#8217;s <a href="http://electricbeach.org/?p=438">overview</a>.<a href="http://electricbeach.org/?p=438" target="_blank"><strong> </strong></a> A new website is now live for all Windows Phone 7 series related development information at <a href="http://developer.windowsphone.com/">http://developer.windowsphone.com/</a></p>
<p>Another announcements is the availability of Silverlight 4 RC and support for VS2010 RC:</p>
<ul>
<li><a href="http://go.microsoft.com/fwlink/?LinkID=141284">Silverlight  4 Tools for Visual Studio 2010</a> (this installs Silverlight developer  runtime, SDK, tools, and <a href="http://silverlight.net/riaservices">WCF  RIA Services</a>).</li>
<li><a href="http://silverlight.codeplex.com/">Silverlight Toolkit</a> March 2010 Release</li>
<li><a href="http://go.microsoft.com/fwlink/?LinkId=185121">WCF RIA  Services Toolkit</a></li>
<li><a href="http://go.microsoft.com/fwlink/?LinkId=169446">Expression  Blend 4 beta</a></li>
<li><a href="http://go.microsoft.com/fwlink/?LinkId=167831">BREAKING  CHANGES DOCUMENTATION</a></li>
<li><a href="http://silverlight.net/getstarted/devices/windows-phone">Windows  Phone Developer tools</a></li>
</ul>
<p>For more information about Silverlight 4 RC, you can check out the blog post of <a href="http://timheuer.com/blog/archive/2010/03/15/whats-new-in-silverlight-4-rc-mix10.aspx?utm_source=Twitter-timheuer">Tim Heuer</a>.</p>
<p>I can&#8217;t wait to play with all this new stuff. It&#8217;s very impressive to see the work done around Windows Phone 7 series. WPF and Silverlight developers just became Windows Phone developer today, and I think this is great !</p>
<p>I&#8217;ll give more feedback as soon as the tools will be installed <img src='http://www.japf.fr/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.japf.fr/2010/03/mix10-windows-phone-7-series-development-tools-available/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using Reflector to debug a .Net app in Visual Studio without the original source code</title>
		<link>http://www.japf.fr/2010/03/debug-any-app-in-visual-studio-without-the-original-sources/</link>
		<comments>http://www.japf.fr/2010/03/debug-any-app-in-visual-studio-without-the-original-sources/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 22:40:43 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[Visual Stutio]]></category>
		<category><![CDATA[reflector]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://www.japf.fr/?p=436</guid>
		<description><![CDATA[Many .Net developers use to say &#8220;if you&#8217;re a serious developer, then you MUST Reflector&#8221;. I would like to add another statement: &#8220;if you want to have an insight and powerful look at how things works internally, use Reflector Professional&#8221;. Last Wednesday, RedGate released a new version of Reflector. You&#8217;re probably going to download it [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.japf.fr/wp-content/uploads/2010/03/ReflectorPro10.png" rel="lightbox[436]"><img class="alignnone size-full wp-image-445" title="ReflectorPro10" src="http://www.japf.fr/wp-content/uploads/2010/03/ReflectorPro10.png" alt="" width="243" height="66" /></a></p>
<p>Many .Net developers use to say <em>&#8220;if you&#8217;re a serious developer, then you MUST Reflector&#8221;</em>.</p>
<p>I would like to add another statement:<em> &#8220;if you want to have an insight and powerful look at how things works internally, use Reflector Professional&#8221;</em>.</p>
<p>Last Wednesday, <a href="http://www.red-gate.com">RedGate</a> released a new version of Reflector. You&#8217;re probably going to download it soon or later because your actual version is going to expire. When you&#8217;ll download the free version, you&#8217;ll automatically get a trial (14 days) of the professional edition. Nice, but what&#8217;s so special about this edition ?</p>
<p>Let&#8217;s see a demonstration of what can be done using Reflector Pro. The following is not an ad for RedGate, I&#8217;m just totally amazed by their new feature <img src='http://www.japf.fr/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>1. Reflector is now integrated into Visual Studio (2005, 2008 and 2010 RC):</p>
<p><a href="http://www.japf.fr/wp-content/uploads/2010/03/ReflectorPro2.png" rel="lightbox[436]"><img class="alignnone size-full wp-image-438" title="ReflectorPro2" src="http://www.japf.fr/wp-content/uploads/2010/03/ReflectorPro2.png" alt="" width="261" height="174" /></a></p>
<p>2. Select the &#8220;Choose Assemblie to Debug&#8230;&#8221; option to select .Net assemblies for which you don&#8217;t have the source code. In this example, I&#8217;m using one of the Blend3&#8242;s assemblies:</p>
<p><a href="http://www.japf.fr/wp-content/uploads/2010/03/ReflectorPro3.png" rel="lightbox[436]"><img class="alignnone size-full wp-image-439" title="ReflectorPro3" src="http://www.japf.fr/wp-content/uploads/2010/03/ReflectorPro3.png" alt="" width="437" height="319" /></a><a href="http://www.japf.fr/wp-content/uploads/2010/03/ReflectorPro4.png" rel="lightbox[436]"></a></p>
<p>3. Once the process is completed, select the &#8220;Explore Decompiled Assemblies&#8221; option:</p>
<p><a href="http://www.japf.fr/wp-content/uploads/2010/03/ReflectorPro4.png" rel="lightbox[436]"><img class="alignnone size-full wp-image-440" title="ReflectorPro4" src="http://www.japf.fr/wp-content/uploads/2010/03/ReflectorPro4.png" alt="" width="263" height="177" /></a></p>
<p>4. Browse to your target assembly and select an interesting type:</p>
<p><a href="http://www.japf.fr/wp-content/uploads/2010/03/ReflectorPro5.png" rel="lightbox[436]"><img class="alignnone size-full wp-image-441" title="ReflectorPro5" src="http://www.japf.fr/wp-content/uploads/2010/03/ReflectorPro5.png" alt="" width="463" height="326" /></a></p>
<p>5. Put a breakpoint in the code, like you do every day when you debug an app:</p>
<p><a href="http://www.japf.fr/wp-content/uploads/2010/03/ReflectorPro6.png" rel="lightbox[436]"><img class="alignnone size-full wp-image-442" title="ReflectorPro6" src="http://www.japf.fr/wp-content/uploads/2010/03/ReflectorPro6.png" alt="" width="859" height="136" /></a></p>
<p>6. Run the executable</p>
<p><a href="http://www.japf.fr/wp-content/uploads/2010/03/ReflectorPro7.png" rel="lightbox[436]"><img class="alignnone size-full wp-image-443" title="ReflectorPro7" src="http://www.japf.fr/wp-content/uploads/2010/03/ReflectorPro7.png" alt="" width="261" height="175" /></a></p>
<p>7. Debug Blend3&#8242;s source code ! Use breakpoints, step into methods, inspect variables&#8230;</p>
<p><a href="http://www.japf.fr/wp-content/uploads/2010/03/ReflectorPro9.png" rel="lightbox[436]"><img class="alignnone size-full wp-image-444" title="ReflectorPro9" src="http://www.japf.fr/wp-content/uploads/2010/03/ReflectorPro9.png" alt="" width="1071" height="507" /></a></p>
<p>And that&#8217;s it. With Reflector Professional, you can:</p>
<ul>
<li>Decompile third-party assemblies       from within Visual Studio</li>
<li>Step through decompiled assemblies and use all the debugging techniques  you would use on your own code. This is incredibly powerful as we saw by debugging Blend3&#8243;s source code !</li>
</ul>
<p>Reflector Professional is available for about 195$ on <a href="http://www.red-gate.com/products/reflector/">RedGate website</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.japf.fr/2010/03/debug-any-app-in-visual-studio-without-the-original-sources/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PDC09 : How VS2010 was built with WPF ?</title>
		<link>http://www.japf.fr/2009/11/pdc09-how-vs2010-was-built-with-wpf/</link>
		<comments>http://www.japf.fr/2009/11/pdc09-how-vs2010-was-built-with-wpf/#comments</comments>
		<pubDate>Thu, 26 Nov 2009 11:24:01 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Visual Stutio]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[architecture]]></category>
		<category><![CDATA[pdc]]></category>
		<category><![CDATA[vs2010]]></category>

		<guid isPermaLink="false">http://www.japf.fr/?p=362</guid>
		<description><![CDATA[In my last blog post, I did a review of a PDC09 Session &#8220;Advanced performance tuning with WPF&#8221;. Today, I&#8217;m doing a review for another very interesting session &#8220;How VS2010 was built with WPF ?&#8221;. The video is available here. Why did Microsoft choose WPF for VS2010 ? Technological: prove the capabilities of WPF4 Architectural [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.japf.fr/wp-content/uploads/2009/08/PDC09.jpg" rel="lightbox[362]"><img class="alignnone size-full wp-image-245" title="PDC09" src="http://www.japf.fr/wp-content/uploads/2009/08/PDC09.jpg" alt="PDC09" width="79" height="109" /></a></p>
<p>In my <a href="http://www.japf.fr/2009/11/pdc09-wpf-application-performance-tuning/">last blog post</a>, I did a review of a PDC09 Session &#8220;Advanced performance tuning with WPF&#8221;. Today, I&#8217;m doing a review for another very interesting session &#8220;<strong>How VS2010 was built with WPF</strong> ?&#8221;. The video is available <a href="http://microsoftpdc.com/Sessions/CL09">here</a>.</p>
<p style="text-align: center;"><a href="http://www.japf.fr/wp-content/uploads/2009/11/vs2008tovs2010.png" rel="lightbox[362]"><img class="size-large wp-image-365 aligncenter" title="vs2008tovs2010" src="http://www.japf.fr/wp-content/uploads/2009/11/vs2008tovs2010-1024x361.png" alt="vs2008tovs2010" width="543" height="191" /></a></p>
<p>Why did Microsoft choose WPF for VS2010 ?</p>
<ul>
<li>Technological: prove the capabilities of WPF4</li>
<li>Architectural
<ul>
<li>Separated presentation</li>
<li>Support for long range road map (+10 years)</li>
</ul>
</li>
<li>Key VS2010 features need it: Editor, Architecture Editor, Parallel tools debugging</li>
<li>Take an opportunity to give feedback for WPF4: when VS2010 development started, .Net 3.5 SP1 was just shipped and it was the right time to give feedback for the new features and fixes for WPF4.</li>
</ul>
<p>It is worth noting that VS2010 is a project that is being watched carefully inside Microsoft. We can expect that more Microsoft applications will move to WPF in the next coming years.</p>
<p>What WPF features are used ?</p>
<ul>
<li>Declarative UI using XAML</li>
<li>Databinding</li>
<li>Styles and templates</li>
<li>Application Resources</li>
<li>Interop Win32 (because they did not have the time to rewrite everything using WPF or because features doest not need to use WPF for example de WinForms designer&#8230;)</li>
<li>Integration with the message loop (to deal with particular focus issues)</li>
<li>New text stack (part of WPF4) based on DirectWrite</li>
</ul>
<p>Staged approach</p>
<ul>
<li>Define data models: a huge diagramming and architectural exercice</li>
<li>Replace the main window with WPF (only the window not its content !) to start the mix approach (managed/unmanaged, WPF/Hwnds)</li>
<li>Write new managed components: Window manager, command bar presentation</li>
<li>Scout with other VS teams</li>
<li>Test, Test, Test&#8230;</li>
</ul>
<p>What were the challenges ?</p>
<ul>
<li>Mixed mode application: native and managed code; WPF and HWNDs (Win32 or WinForms)</li>
<li>Keep existing extensions working and allow new extensions to take advantage of WPF</li>
<li>Don&#8217;t &#8220;stop the train&#8221; other teams were working at the same time on the product to add new functionalities</li>
<li>Text clarity</li>
<li>Performance</li>
<li>Focus management</li>
</ul>
<p>You can watch the session <a href="http://microsoftpdc.com/Sessions/CL09">here</a> if you want more detail and demos of what I mention in this post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.japf.fr/2009/11/pdc09-how-vs2010-was-built-with-wpf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Analyzing events usage using a R# plugin</title>
		<link>http://www.japf.fr/2009/10/analyzing-events-usage-using-a-resharper-plugin/</link>
		<comments>http://www.japf.fr/2009/10/analyzing-events-usage-using-a-resharper-plugin/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 12:20:47 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[practises]]></category>
		<category><![CDATA[refactoring]]></category>
		<category><![CDATA[resharper]]></category>

		<guid isPermaLink="false">http://www.japf.fr/?p=286</guid>
		<description><![CDATA[As you might already know, even if the .Net framework has a garbage collector, you can easily create memory leaks in your application. The most common way to create a leak is to register to an event handler on a object that has a longer lifetime than the object where the handler is defined. The [...]]]></description>
			<content:encoded><![CDATA[<p>As you might already know, even if the .Net framework has a garbage collector, you can easily create memory leaks in your application.</p>
<p>The most common way to create a leak is to register to an event handler on a object that has a longer lifetime than the object where the handler is defined. The problem can also occurs by using static class such as EventManager (for more information see <a href="http://www.japf.fr/2009/08/wpf-memory-leak-with-eventmanager-registerclasshandler/">this blog post</a>). Some .Net developers have been working on a way to go round the problem using Reflection, Weak Reference and other cool stuff. You can check out for example <a href="http://www.codeproject.com/KB/cs/WeakEvents.aspx">this excellent article</a> on Code Project.</p>
<p>However, if you cannot change the way your declare events (because of internal policies in the company or because you don&#8217;t have the source code), you must be very carefull about the way you manage your events.</p>
<p>I&#8217;ve been working lately on a <a href="http://www.jetbrains.com/resharper/index.html">Resharper</a> plugin that helps detecting events that are never unsubscribed. Basically, what is does is the following:</p>
<p><a href="http://www.japf.fr/wp-content/uploads/2009/10/resharper_plugin.png" rel="lightbox[286]"><img class="size-full wp-image-287 alignnone" title="resharper_plugin" src="http://www.japf.fr/wp-content/uploads/2009/10/resharper_plugin.png" alt="resharper_plugin" width="528" height="213" /></a></p>
<p><strong>I&#8217;d like to have feedback from you .Net developpers, about whether you find such a plugin useful or not. </strong></p>
<ul>
<li>How do you deal with the event memory leak problem ?</li>
<li>Would you like to use my plugin ?</li>
<li>Would you like me to release it on a open source platform ?</li>
<li>What other kind of possible leaks are you thinking about to enhance the plugin ?</li>
</ul>
<p>Please write a comment to let my know what you think. Thank you for your feedback !</p>
]]></content:encoded>
			<wfw:commentRss>http://www.japf.fr/2009/10/analyzing-events-usage-using-a-resharper-plugin/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>.Net4, WPF4 and VS2010 interesting links</title>
		<link>http://www.japf.fr/2009/05/net4-wpf4-and-vs2010-interesting-links/</link>
		<comments>http://www.japf.fr/2009/05/net4-wpf4-and-vs2010-interesting-links/#comments</comments>
		<pubDate>Thu, 28 May 2009 14:43:30 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Visual Stutio]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.japf.fr/?p=224</guid>
		<description><![CDATA[Since the release of VS2010 last week a lot of cool blog posts had been written. The thing is more than VS2010 itself, the Beta1 comes with .Net4 and WPF4 too, and that&#8217;s exciting too ! Because I didn&#8217;t have time yet to write my own feedback, I&#8217;m sharing some links I found the last [...]]]></description>
			<content:encoded><![CDATA[<p>Since the release of VS2010 last week a lot of cool blog posts had been written. The thing is more than VS2010 itself, the Beta1 comes with .Net4 and WPF4 too, and that&#8217;s exciting too !</p>
<p>Because I didn&#8217;t have time yet to write my own feedback, I&#8217;m sharing some links I found the last couple of days.</p>
<p><strong>Download</strong></p>
<ul>
<li>A full list of what is available to download (VS2010, .Net framework&#8230;) can be found <a href="http://blogs.msdn.com/wpfsdk/archive/2009/05/20/visual-studio-10-beta-1-bits-are-now-publically-available.aspx">here</a>.</li>
</ul>
<p><strong>MSDN Documentations</strong></p>
<ul>
<li>.Net Framework4 Beta1: <a href="http://msdn.microsoft.com/en-us/library/w0x726c2(VS.100).aspx">here</a></li>
<li>What&#8217;s new in .Net Framework4 Beta1: <a href="http://msdn.microsoft.com/en-us/library/dd409230(VS.100).aspx">here</a></li>
<li>WPF4 Beta1: <a href="http://msdn.microsoft.com/en-us/library/ms754130(VS.100).aspx">here</a></li>
<li>What&#8217;s new in WPF4 Beta1: <a href="http://msdn.microsoft.com/en-us/library/bb613588(VS.100).aspx">here</a></li>
<li>VS2010 Beta1: <a href="http://msdn.microsoft.com/en-us/library/dd831853(VS.100).aspx">here</a></li>
<li>What&#8217;s new in VS2010 Beta1: <a href="http://msdn.microsoft.com/en-us/library/bb386063(VS.100).aspx">here</a></li>
</ul>
<p><strong>From Beta1 to Beta1 and RTM</strong></p>
<ul>
<li>Jaime Rodriguez wrote a <a href="http://blogs.msdn.com/jaimer/archive/2009/05/27/wpf-4-and-net-framework-4-beta-1-list-of-features-totrack.aspx">very nice article today</a> and share his &#8220;insider view&#8221; of what&#8217;s on the road to RTM.</li>
<li>Karl Shifflet <a href="http://karlshifflett.wordpress.com/2009/05/27/wpf-4-0-data-binding-change-great-feature/">explained on his blog</a> what&#8217;s going to change in the DataBinding pipeline (no more dummy converter !)</li>
</ul>
<p><strong>Channel9</strong></p>
<ul>
<li><a href="http://channel9.msdn.com/shows/Continuum/WPF4Beta1/">Interviews</a> of WPF and Silverlight program managers.</li>
<li>Rob Releya <a href="http://channel9.msdn.com/shows/Continuum/XAMLinNET4/">is also talking</a> on the new XAML stack available in the framework. More information can be found on <a href="http://blogs.windowsclient.net/rob_relyea/">his blog</a>.</li>
</ul>
<p><strong>Other bloggers</strong></p>
<ul>
<li>Patrick Smacchia gave us <a href="http://codebetter.com/blogs/patricksmacchia/archive/2009/05/21/a-quick-analyze-of-the-net-fx-v4-0-beta1.aspx">an inside look of the changes</a> from .Net 3.5SP1 to .Net 4 Beta1 using NDepend.</li>
</ul>
<p><strong>And also, Blend3</strong></p>
<ul>
<li>Unni&#8217;s wrote <a href="http://blogs.msdn.com/unnir/archive/2009/05/25/connect-and-blend-3.aspx">an article</a> about updates that had been made to Blend regarding user feedback on Connect.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.japf.fr/2009/05/net4-wpf4-and-vs2010-interesting-links/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Browse your codebase like a pro with ReSharper</title>
		<link>http://www.japf.fr/2009/05/browse-your-codebase-like-a-pro-with-resharper/</link>
		<comments>http://www.japf.fr/2009/05/browse-your-codebase-like-a-pro-with-resharper/#comments</comments>
		<pubDate>Mon, 18 May 2009 11:27:03 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[Visual Stutio]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[resharper]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://www.japf.fr/?p=211</guid>
		<description><![CDATA[I&#8217;ve already blogged about R# a couple of times. There is no doubt: it&#8217;s a must have for any serious .Net developper. A few weeks ago I learned and setup new shortcuts to improve my navigation skills in Visual Studio. Here are the results&#8230; If I want: to find a Type I hit Ctrl+T to [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve already blogged about R# a couple of times. There is no doubt: it&#8217;s a must have for any serious .Net developper. A few weeks ago I learned and setup new shortcuts to improve my navigation skills in Visual Studio.</p>
<p>Here are the results&#8230; If I want:</p>
<ul>
<li>to find a <strong>Type</strong> I hit <strong>Ctrl+T</strong></li>
<li>to find a <strong>File</strong> I hit <strong>Ctrl+Shift+T</strong></li>
<li>to find a <strong>Member</strong> (in a file) I hit <strong>Ctrl+Alt+T</strong> (Note: I setup this one on my own using Tools/Options/Keyboard)</li>
</ul>
<p>A search box opens and I can start searching instantaneously.</p>
<p><a href="http://www.japf.fr/wp-content/uploads/2009/05/resharpernavigation1.png" rel="lightbox[211]"><img class="alignnone size-medium wp-image-217" title="resharpernavigation1" src="http://www.japf.fr/wp-content/uploads/2009/05/resharpernavigation1-300x92.png" alt="resharpernavigation1" width="300" height="92" /></a></p>
<p>Here are the basic scenarios :</p>
<ul>
<li>I want to open the <strong>ViewModelBase</strong> class, I hit <strong>Ctrl+T</strong> and then <strong>VMB</strong> (R# is able to search using capital letters)</li>
<li>I want to go to the <strong>OnPropertyChanged</strong>, I hit <strong>Ctrl+Alt+T</strong> and then <strong>OPC</strong> (same as previous example)</li>
<li>Finally, to open the file in the Solution Explorer I hit <strong>Shift+Alt+L</strong></li>
</ul>
<p>It&#8217;s simply amazing the time we can save using those simple shorcuts. Of course, you need to be quite familiar with your codebase (if you just arrive on a project it will be harder :p)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.japf.fr/2009/05/browse-your-codebase-like-a-pro-with-resharper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

