Get Func<T> and Expression<Func<T>> from single parameter?
<p>I would like to get both the compiled Func(of boolean) and an
Expression( of Func(of boolean)) using a single parameter. I don't intend to modify
the expression tree. The only reason to take an Expression tree at all
is so i can print out the code that is being executed.</p>

<pre><code>void Assert(Expression&lt;Func&lt;bool&gt;&gt; assertionExpression) {
    if (!assertionExpression.Compile()()) 
    { 
        throw new AssertFailedException(assertionExpression.ToString()); 
    }
}
</code></pre>

<p>Is there any reasonable way to do this?</p>

<p>As a corrolarry, in the case of simple compiler generated expression trees, will the same instance always be passed as a parameter?</p>

<pre><code>static Dictionary&lt;Expression&lt;Func&lt;bool&gt;&gt;, Func&lt;bool&gt;&gt; cache;

static void Assert(Expression&lt;Func&lt;bool&gt;&gt; assertionExpression) {
    Func&lt;bool&gt; method = null;
    if (!cache.TryGetValue(assertionExpression, out method)) {
        cache.Add(assertionExpression, method = assertionExpression.Compile());
        Console.WriteLine("cache insert");
    }
    else {
         Console.WriteLine("cache hit");
    }
    if (!method()) 
    { 
        throw new AssertFailedException(assertionExpression.ToString()); 
    }
}

static void someCodeThatExecutesRegularly() {
    Assert(()=&gt;true);
}

public static void Main(string[] args, int argc) 
{
    someCodeThatExecutesRegularly();

    someCodeThatExecutesRegularly();

    someCodeThatExecutesRegularly();
}
</code></pre>

<p>Will the output be 'cache insert, 'cache hit', 'cache hit' or 'cache insert', 'cache insert', 'cache insert'.</p>
