title: How do I get 100% code coverage for "catch with rethrow" block in VB.NET in Visual Studio 2010 Ultimate?
body: <p>I am unable to achieve 100% code coverage for a "catch with rethrow" block in my VB.NET source code.  My workplace IDE is Visual Studio 2010 Ultimate. Below example represents a simplified version of my actual problem.</p>
  
  <p><strong>Source in C#: (light-blue background indicates full code coverage)</strong></p>
  
  <p><img src="https://i.stack.imgur.com/eOOBh.jpg" alt="Source in C#"></p>
  
  <p><br/></p>
  
  <p><strong>Equivalent source in VB.NET: (yellow background indicates partial code coverage)</strong></p>
  
  <p><img src="https://i.stack.imgur.com/xEeCt.jpg" alt="Source in VB.NET"></p>
  
  <p><br/></p>
  
  <p><strong>MSTests for both C# and VB.NET source (intended to achieve 100% code coverage)</strong></p>
  
  <p><img src="https://i.stack.imgur.com/jgys3.jpg" alt="MSTests"></p>
  
  <p><br/></p>
  
  <p><strong>Code Coverage Report</strong></p>
  
  <p><img src="https://i.stack.imgur.com/w3dAW.jpg" alt="Code Coverage Report"></p>
  
  <p><br/></p>
  
  <p>The code coverage report shows 100% for C#, but only 91.67% for VB.NET. It also shows 1 block of code with 0 lines being uncovered in VB.NET. </p>
  
  <p>Is this an issue with the tool? Or am I missing something obvious?</p>
  
  <p><strong>EDIT #1:</strong> Sharing source code as requested by @Raptor</p>
  
  <p><strong>Source code in C#</strong></p>
  
  <pre><code>public class CodeCoverage
  {
     public void DoWork(bool flag = false)
     {
        try
        {
           Thread.Sleep(1);
  
          if (flag)
              {
                 throw new Exception("test");
              }
        }
        catch (Exception ex)
        {
           throw new Exception(string.Format("something happened: {0}", ex.Message));
        }
     }
  }
  </code></pre>
  
  <p><br/></p>
  
  <p><strong>Source code in VB.NET</strong></p>
  
  <pre><code>Public Class CodeCoverage2
     Public Sub DoWork(Optional ByVal flag As Boolean = False)
        Try
              Thread.Sleep(1)
  
              If flag Then
                  Throw New Exception("test")
              End If
          Catch ex As Exception
              Throw New Exception(String.Format("something happened: {0}", ex.Message))
          End Try
      End Sub
  End Class
  </code></pre>
  
  <p><br/></p>
  
  <p><strong>Source code for MSTests</strong></p>
  
  <pre><code>[TestClass]
  public class CodeCoverageTest
  {
     [TestMethod]
     public void DoWorkTest()
     {
        var obj = new CodeCoverage();
        obj.DoWork();
     }
  
     [TestMethod]
     [ExpectedException(typeof(Exception))]
     public void DoWorkTest2()
     {
        var obj = new CodeCoverage();
        obj.DoWork(true);
     }
  
     [TestMethod]
     public void DoWorkTest3()
     {
        var obj = new CodeCoverage2();
        obj.DoWork();
     }
  
     [TestMethod]
     [ExpectedException(typeof(Exception))]
     public void DoWorkTest4()
     {
        var obj = new CodeCoverage2();
        obj.DoWork(true);
     }
  }
  </code></pre>