title: Exception's Stack trace not complete when throwing in Func
body: <p>I have an issue where when an exception is thrown inside a method accessed via a func the stack trace is getting truncated. Consider the following simple reproduction:</p>
  
  <pre><code>static void Main(string[] args)
  {
      Test();
      Console.ReadLine();
  }
  
  public static void Test()
  {
      try
      {
          Func&lt;string&gt; func = () =&gt; MyFunc();
          func();
      }
      catch (Exception ex)
      {
          Console.WriteLine("Exception.StackTrace:");
          Console.WriteLine(ex.StackTrace.ToString());
      }
  }
  
  public static string MyFunc()
  {
      Console.WriteLine("Environment.StackTrace:");
      Console.WriteLine(Environment.StackTrace);
      Console.WriteLine(new String('*', 20));
      throw new Exception("Where is my stack trace?");
  }
  </code></pre>
  
  <p>I would expect the stack trace written out in the catch block to be basically the same as that written out in <code>MyFunc</code>but in fact what gets written out as the stack trace of the exception is:</p>
  
  <pre><code>at FuncStackTraceIssue.Program.MyFunc() in Program.cs:line 36
  at FuncStackTraceIssue.Program.&lt;&gt;c.&lt;Test&gt;b__1_0() in Program.cs:line 21
  at FuncStackTraceIssue.Program.Test() in Program.cs:line 22
  </code></pre>
  
  <p>As you can see it only goes back as far as the Function where I invoked the func (<code>Test</code>). The writing out of the stack trace in MyFunc is:</p>
  
  <pre><code>at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
  at System.Environment.get_StackTrace()
  at FuncStackTraceIssue.Program.MyFunc() in Program.cs:line 34
  at FuncStackTraceIssue.Program.&lt;&gt;c.&lt;Test&gt;b__1_0() in Program.cs:line 21
  at FuncStackTraceIssue.Program.Test() in Program.cs:line 22
  at FuncStackTraceIssue.Program.Main(String[] args) in Program.cs:line 13
  </code></pre>
  
  <p>The reason this is causing me problems is that in the real code this is being called from several different places and passing in variables and other such things and when it goes wrong I log the exception including the stack trace. I want to be able to see exactly what the code path is that led to the error and preferably without having to change how I log.</p>
  
  <p>So the question is why do I not get a full stack trace and is there anything I can do to make it give me a full stack trace?</p>