1.5.7 and yield blocks in try/finally

1.5.7 and yield blocks in try/finally

The following class:

[TestFixture]
public class CoverageTest
{
    [Test]
    public void Test1()
    {
        foreach (Int32 value in IteratorMethod())
        {
            Assert.That(value, Is.GreaterThan(0));
        }
    }

    public IEnumerable<Int32> IteratorMethod()
    {
        try
        {
            for (Int32 index = 1; index <= 10; index++)
                yield return index;
        }
        finally
        {
            if (File.Exists(@"C:\test.txt"))
                File.Delete(@"C:\test.txt");
        }
    }
}


still reports that the finally-block is never executed, even though it is observable that it is during test execution. This is version 1.5.7. Was this part intended to be fixed in 1.5.7 or not?


Re: NCover hangs using NAnt and NUnit

Did you remember to regsvr32 coverlib.dll?