title: Iterator block generates try-fault in IL
body: <p>After experimenting with an iterator block I noticed the generated IL code is not what I expect it to be. Instead of a try-finally block a try-fault block is generated, which I have never seen. I noticed that the compiler doesn't allow me use the fault keyword in 'handwritten' C#.</p>
  
  <p>Is there any difference between the 2? </p>
  
  <p>C# code:</p>
  
  <pre><code>static IEnumerable&lt;string&gt; ReadAllLines(string fileName)
  {
      using (var file = System.IO.File.OpenText(fileName))
      {
          string s;
          while ((s = file.ReadLine()) != null)
          {
              yield return s;
          }
      }
  }
  </code></pre>
  
  <p>MSIL Code:</p>
  
  <pre><code>.method private hidebysig newslot virtual final instance bool MoveNext() cil managed
  {
      .override [mscorlib]System.Collections.IEnumerator::MoveNext
      .maxstack 3
      .locals init (
          [0] bool CS$1$0000,
          [1] int32 CS$4$0001,
          [2] string CS$0$0002,
          [3] bool CS$4$0003)
      L_0000: ldarg.0 
  
      // try body
  
      L_008d: leave.s L_0097
      L_008f: ldarg.0 
      L_0090: call instance void ConsoleApplication2.Program/&lt;ReadAllLines&gt;d__0::System.IDisposable.Dispose()
      L_0095: nop 
      L_0096: endfinally 
      L_0097: nop 
      L_0098: ldloc.0 
      L_0099: ret 
      .try L_0000 to L_008f fault handler L_008f to L_0097
  }
  </code></pre>
  
  <p>The interesting line is the last line of the IL where a fault handler is specified, where in a normal try-finally block a finally handler is specified.</p>