<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Exploring ShadeTree Features, Part 1: Static Reflection with ReflectionHelper</title>
	<atom:link href="http://lostechies.com/chadmyers/2008/07/06/exploring-shadetree-features-part-1-static-reflection-with-reflectionhelper/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/chadmyers/2008/07/06/exploring-shadetree-features-part-1-static-reflection-with-reflectionhelper/</link>
	<description>Software development, testing, and techie life</description>
	<lastBuildDate>Thu, 08 Mar 2012 22:19:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: Chad Myers</title>
		<link>http://lostechies.com/chadmyers/2008/07/06/exploring-shadetree-features-part-1-static-reflection-with-reflectionhelper/#comment-433</link>
		<dc:creator>Chad Myers</dc:creator>
		<pubDate>Mon, 21 Jul 2008 00:09:36 +0000</pubDate>
		<guid isPermaLink="false">/blogs/chad_myers/archive/2008/07/06/exploring-shadetree-features-part-1-static-reflection-with-reflectionhelper.aspx#comment-433</guid>
		<description>@Frank:  Yeah, Jeremy&#039;s been doing good just to do code on StoryTeller, let alone docs.  ShadeTree (which happens to live in the StoryTeller tree house for the time being), at this point, is a code repo and not much more (not a lot of organization).

The idea is that we&#039;re doing some interesting things at work and some of those things are not related to the IP or profitability of our company so we&#039;re trying to contribute to open source.  We&#039;re doing the best we can and trying to put as much as we can responsibly put in there in order to contribute to the community.

We realize that it&#039;s not terribly useful for other people if it&#039;s a hodge-podge and they can&#039;t discover what&#039;s in it or how to use it.  At this point, we have a list of things to do on ShadeTree to make it more friendly for use by people other than us.  

My hope with this blog post series was to try to make some of the gems that are in ShadeTree a little more widely known so you can at least grab some nuggets until we can polish it up a little.

If you or anyone else is willing to help put some docs together, I&#039;d be willing to spend some time on the phone/skype getting you started and walking through the important things. Sometimes, just having the bootstrapping for documentation (i.e. the outline, layout, styles, etc) helps encourage more people to write more.

Would you (or anyone else here) be willing to get a documentation shell project going in ShadeTree (an empty HTML project with CSS layout and maybe just some basic &#039;getting started&#039; docs?  Maybe a wiki instead?)?</description>
		<content:encoded><![CDATA[<p>@Frank:  Yeah, Jeremy&#8217;s been doing good just to do code on StoryTeller, let alone docs.  ShadeTree (which happens to live in the StoryTeller tree house for the time being), at this point, is a code repo and not much more (not a lot of organization).</p>
<p>The idea is that we&#8217;re doing some interesting things at work and some of those things are not related to the IP or profitability of our company so we&#8217;re trying to contribute to open source.  We&#8217;re doing the best we can and trying to put as much as we can responsibly put in there in order to contribute to the community.</p>
<p>We realize that it&#8217;s not terribly useful for other people if it&#8217;s a hodge-podge and they can&#8217;t discover what&#8217;s in it or how to use it.  At this point, we have a list of things to do on ShadeTree to make it more friendly for use by people other than us.  </p>
<p>My hope with this blog post series was to try to make some of the gems that are in ShadeTree a little more widely known so you can at least grab some nuggets until we can polish it up a little.</p>
<p>If you or anyone else is willing to help put some docs together, I&#8217;d be willing to spend some time on the phone/skype getting you started and walking through the important things. Sometimes, just having the bootstrapping for documentation (i.e. the outline, layout, styles, etc) helps encourage more people to write more.</p>
<p>Would you (or anyone else here) be willing to get a documentation shell project going in ShadeTree (an empty HTML project with CSS layout and maybe just some basic &#8216;getting started&#8217; docs?  Maybe a wiki instead?)?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank Quednau</title>
		<link>http://lostechies.com/chadmyers/2008/07/06/exploring-shadetree-features-part-1-static-reflection-with-reflectionhelper/#comment-432</link>
		<dc:creator>Frank Quednau</dc:creator>
		<pubDate>Sun, 20 Jul 2008 16:36:41 +0000</pubDate>
		<guid isPermaLink="false">/blogs/chad_myers/archive/2008/07/06/exploring-shadetree-features-part-1-static-reflection-with-reflectionhelper.aspx#comment-432</guid>
		<description>Hi there, just got the trunk of storyteller. There seems to be no single line of documentation in it. Looks like the tests also leave well-trodden paths. Are the blog posts tom come the documentation or is there something somewhere that would help me drill the first hole into that?
Cheers</description>
		<content:encoded><![CDATA[<p>Hi there, just got the trunk of storyteller. There seems to be no single line of documentation in it. Looks like the tests also leave well-trodden paths. Are the blog posts tom come the documentation or is there something somewhere that would help me drill the first hole into that?<br />
Cheers</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Batum</title>
		<link>http://lostechies.com/chadmyers/2008/07/06/exploring-shadetree-features-part-1-static-reflection-with-reflectionhelper/#comment-431</link>
		<dc:creator>Paul Batum</dc:creator>
		<pubDate>Sun, 20 Jul 2008 15:16:56 +0000</pubDate>
		<guid isPermaLink="false">/blogs/chad_myers/archive/2008/07/06/exploring-shadetree-features-part-1-static-reflection-with-reflectionhelper.aspx#comment-431</guid>
		<description>@Chad

No worries at all! I really digging the new C# features and am doing my best to understand all the in&#039;s and outs. I really like how the expression trees are helping to bridge some of the &quot;metaprogramming gap&quot; that exists at the moment. The NHibernate mapping stuff that you and Jeremy have been doing is a good example I think. Really looking forward to seeing what else you guys come up with!</description>
		<content:encoded><![CDATA[<p>@Chad</p>
<p>No worries at all! I really digging the new C# features and am doing my best to understand all the in&#8217;s and outs. I really like how the expression trees are helping to bridge some of the &#8220;metaprogramming gap&#8221; that exists at the moment. The NHibernate mapping stuff that you and Jeremy have been doing is a good example I think. Really looking forward to seeing what else you guys come up with!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chad Myers</title>
		<link>http://lostechies.com/chadmyers/2008/07/06/exploring-shadetree-features-part-1-static-reflection-with-reflectionhelper/#comment-430</link>
		<dc:creator>Chad Myers</dc:creator>
		<pubDate>Sat, 19 Jul 2008 23:02:01 +0000</pubDate>
		<guid isPermaLink="false">/blogs/chad_myers/archive/2008/07/06/exploring-shadetree-features-part-1-static-reflection-with-reflectionhelper.aspx#comment-430</guid>
		<description>@Paul:

Thanks again for the catch! Sorry I was being so dense. I updated the post accordingly. Let me know if works for you.</description>
		<content:encoded><![CDATA[<p>@Paul:</p>
<p>Thanks again for the catch! Sorry I was being so dense. I updated the post accordingly. Let me know if works for you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chad Myers</title>
		<link>http://lostechies.com/chadmyers/2008/07/06/exploring-shadetree-features-part-1-static-reflection-with-reflectionhelper/#comment-429</link>
		<dc:creator>Chad Myers</dc:creator>
		<pubDate>Sat, 19 Jul 2008 14:08:22 +0000</pubDate>
		<guid isPermaLink="false">/blogs/chad_myers/archive/2008/07/06/exploring-shadetree-features-part-1-static-reflection-with-reflectionhelper.aspx#comment-429</guid>
		<description>@Paul

Yeah, I think I&#039;m mistaken with the CS0201 thing you pointed out.  I forgot that the compiler automatically adds the &quot;return&quot; keyword deep under the hood to lambdas like that.

I&#039;ll correct that later tonight (gotta run right now, unfortunately).</description>
		<content:encoded><![CDATA[<p>@Paul</p>
<p>Yeah, I think I&#8217;m mistaken with the CS0201 thing you pointed out.  I forgot that the compiler automatically adds the &#8220;return&#8221; keyword deep under the hood to lambdas like that.</p>
<p>I&#8217;ll correct that later tonight (gotta run right now, unfortunately).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Batum</title>
		<link>http://lostechies.com/chadmyers/2008/07/06/exploring-shadetree-features-part-1-static-reflection-with-reflectionhelper/#comment-428</link>
		<dc:creator>Paul Batum</dc:creator>
		<pubDate>Sat, 19 Jul 2008 08:53:19 +0000</pubDate>
		<guid isPermaLink="false">/blogs/chad_myers/archive/2008/07/06/exploring-shadetree-features-part-1-static-reflection-with-reflectionhelper.aspx#comment-428</guid>
		<description>@Chad:

Both you and Jimmy pointed out my mistake with trying to pass the block as type Expression - yep, I was totally wrong with that one.

However, I&#039;m still not satisfied :)

--- chad wrote
If you later try to execute/invoke that expression, THEN you&#039;ll get an error similar to the CS0201 above.  But for right now, the compiler lets it pass, and will generate the IL to pass your method or property a type of Expression&lt;&gt;.
---

I can&#039;t figure out how to write an expression that is fine at compile time, but will result in a CS0201 style error when you try to run it. I would really really love an example of this.

Thanks for being patient with me. </description>
		<content:encoded><![CDATA[<p>@Chad:</p>
<p>Both you and Jimmy pointed out my mistake with trying to pass the block as type Expression &#8211; yep, I was totally wrong with that one.</p>
<p>However, I&#8217;m still not satisfied :)</p>
<p>&#8212; chad wrote<br />
If you later try to execute/invoke that expression, THEN you&#8217;ll get an error similar to the CS0201 above.  But for right now, the compiler lets it pass, and will generate the IL to pass your method or property a type of Expression<>.<br />
&#8212;</p>
<p>I can&#8217;t figure out how to write an expression that is fine at compile time, but will result in a CS0201 style error when you try to run it. I would really really love an example of this.</p>
<p>Thanks for being patient with me. </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chad Myers</title>
		<link>http://lostechies.com/chadmyers/2008/07/06/exploring-shadetree-features-part-1-static-reflection-with-reflectionhelper/#comment-427</link>
		<dc:creator>Chad Myers</dc:creator>
		<pubDate>Fri, 18 Jul 2008 15:31:20 +0000</pubDate>
		<guid isPermaLink="false">/blogs/chad_myers/archive/2008/07/06/exploring-shadetree-features-part-1-static-reflection-with-reflectionhelper.aspx#comment-427</guid>
		<description>@Paul:

I think I&#039;m starting to understand what you&#039;re pointing at here.

Like I said above in my reply to Rob, yes, c=&gt;c.LastName will work as a Func&lt;T,U&gt; parameter because the compiler will translate c.LastName as a &quot;return c.LastName&quot; statement, which is, of course valid. So there&#039;s some compiler trickery happening there so MAKE an otherwise invalid statement, valid.

One note, you&#039;re using blocks {} around your lambda. That won&#039;t work with the Expression stuff like what I&#039;m talking about (for static reflection purposes). And the static reflection stuff doesn&#039;t work with Action&lt;T&gt;, it must be Func&lt;T,U&gt;.</description>
		<content:encoded><![CDATA[<p>@Paul:</p>
<p>I think I&#8217;m starting to understand what you&#8217;re pointing at here.</p>
<p>Like I said above in my reply to Rob, yes, c=>c.LastName will work as a Func<t ,U> parameter because the compiler will translate c.LastName as a &#8220;return c.LastName&#8221; statement, which is, of course valid. So there&#8217;s some compiler trickery happening there so MAKE an otherwise invalid statement, valid.</p>
<p>One note, you&#8217;re using blocks {} around your lambda. That won&#8217;t work with the Expression stuff like what I&#8217;m talking about (for static reflection purposes). And the static reflection stuff doesn&#8217;t work with Action</t><t>, it must be Func</t><t ,U>.</t></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Batum</title>
		<link>http://lostechies.com/chadmyers/2008/07/06/exploring-shadetree-features-part-1-static-reflection-with-reflectionhelper/#comment-426</link>
		<dc:creator>Paul Batum</dc:creator>
		<pubDate>Fri, 18 Jul 2008 14:56:49 +0000</pubDate>
		<guid isPermaLink="false">/blogs/chad_myers/archive/2008/07/06/exploring-shadetree-features-part-1-static-reflection-with-reflectionhelper.aspx#comment-426</guid>
		<description>@Chad

Sorry for being such a persistent bugger about this, but I still can&#039;t seem to replicate the magic you are describing. Would you mind pasting an example of a lambda expression body that doesn&#039;t compile unless you make it a parameter to a method that takes an Expression&lt;T&gt;?

This fails to compile for me:

        [Test]
        public void Test()
        {
            Magic(s =&gt; { s.Length; });            
        }

        private void Magic(Expression&lt;Action&lt;string&gt;&gt; action) { }
</description>
		<content:encoded><![CDATA[<p>@Chad</p>
<p>Sorry for being such a persistent bugger about this, but I still can&#8217;t seem to replicate the magic you are describing. Would you mind pasting an example of a lambda expression body that doesn&#8217;t compile unless you make it a parameter to a method that takes an Expression<t>?</p>
<p>This fails to compile for me:</p>
<p>        [Test]<br />
        public void Test()<br />
        {<br />
            Magic(s => { s.Length; });<br />
        }</p>
<p>        private void Magic(Expression<action <string>> action) { }<br />
</action></t></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chad Myers</title>
		<link>http://lostechies.com/chadmyers/2008/07/06/exploring-shadetree-features-part-1-static-reflection-with-reflectionhelper/#comment-425</link>
		<dc:creator>Chad Myers</dc:creator>
		<pubDate>Fri, 18 Jul 2008 12:36:12 +0000</pubDate>
		<guid isPermaLink="false">/blogs/chad_myers/archive/2008/07/06/exploring-shadetree-features-part-1-static-reflection-with-reflectionhelper.aspx#comment-425</guid>
		<description>@Paul:

The Expression Tree magic only appears to happen when the Expression&lt;T&gt; is a parameter to a method.  I don&#039;t think it works as a standard assignment or even a Property setter assignment.

If you wish to build up expression trees manually, you can use things like:

Expression.Lambda() 
Expression.MakeMemberAccess()
Expression.Equal()
Expression.AndAlso()
etc,etc,etc</description>
		<content:encoded><![CDATA[<p>@Paul:</p>
<p>The Expression Tree magic only appears to happen when the Expression<t> is a parameter to a method.  I don&#8217;t think it works as a standard assignment or even a Property setter assignment.</p>
<p>If you wish to build up expression trees manually, you can use things like:</p>
<p>Expression.Lambda()<br />
Expression.MakeMemberAccess()<br />
Expression.Equal()<br />
Expression.AndAlso()<br />
etc,etc,etc</t></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Batum</title>
		<link>http://lostechies.com/chadmyers/2008/07/06/exploring-shadetree-features-part-1-static-reflection-with-reflectionhelper/#comment-424</link>
		<dc:creator>Paul Batum</dc:creator>
		<pubDate>Fri, 18 Jul 2008 09:52:30 +0000</pubDate>
		<guid isPermaLink="false">/blogs/chad_myers/archive/2008/07/06/exploring-shadetree-features-part-1-static-reflection-with-reflectionhelper.aspx#comment-424</guid>
		<description>@Chad,

Sorry, I probably wasn&#039;t clear enough. I understand the difference, and why you need to use Expression instead of a plain Func in your example. You can interrogate the expression tree if its an expression, you can&#039;t if its a plain old func. What I don&#039;t understand is this:

--- chad wrote:
You might, rightly, expect to get this compile error:

error CS0201: Only assignment, call, increment, decrement, 
and new object expressions can be used as a statement

So why don&#039;t you?  Well, the trick is that your method or property must take a parameter of type Expression&lt;Func&lt;T,object&gt;&gt;.
---

Unless I&#039;m mistaken, the answer to &quot;why don&#039;t you?&quot; is that the compiler allows us to elide the return, braces and semicolon. src=&gt;src.Name is perfectly valid, because its equivalent to src =&gt; { return src.Name; }. You get this behavior regardless of whether you are using an expression or just a normal func.

And If this statement was true:

--- chad wrote:
This causes the C# compiler to behave strangely -- namely it does not treat the code inside the expression as executable code, but as a parsed language element for LATER evaluation. 
---

Then this line would compile:
Expression&lt;Action&lt;string&gt;&gt; exp = s =&gt; { s.Length; };
</description>
		<content:encoded><![CDATA[<p>@Chad,</p>
<p>Sorry, I probably wasn&#8217;t clear enough. I understand the difference, and why you need to use Expression instead of a plain Func in your example. You can interrogate the expression tree if its an expression, you can&#8217;t if its a plain old func. What I don&#8217;t understand is this:</p>
<p>&#8212; chad wrote:<br />
You might, rightly, expect to get this compile error:</p>
<p>error CS0201: Only assignment, call, increment, decrement,<br />
and new object expressions can be used as a statement</p>
<p>So why don&#8217;t you?  Well, the trick is that your method or property must take a parameter of type Expression<func <T,object>>.<br />
&#8212;</p>
<p>Unless I&#8217;m mistaken, the answer to &#8220;why don&#8217;t you?&#8221; is that the compiler allows us to elide the return, braces and semicolon. src=>src.Name is perfectly valid, because its equivalent to src => { return src.Name; }. You get this behavior regardless of whether you are using an expression or just a normal func.</p>
<p>And If this statement was true:</p>
<p>&#8212; chad wrote:<br />
This causes the C# compiler to behave strangely &#8212; namely it does not treat the code inside the expression as executable code, but as a parsed language element for LATER evaluation.<br />
&#8212;</p>
<p>Then this line would compile:<br />
Expression<action <string>> exp = s => { s.Length; };<br />
</action></func></p>
]]></content:encoded>
	</item>
</channel>
</rss>
