in Code in VS 2012

Edit: I just tried this with VS 2010, and the problem didn't occur. The issue only happens with VS 2012. Could this really be a bug? This is also happening on two separate laptops of mine, and even on a friend's laptop (that just got the latest code).

First, a screenshot of the problem. This method is all new code.

在这里输入图像描述

The debugger is skipping code from my recent check-in. The comments, in the code below, explain what is happening when I debug this method. So there really isn't a need to try and understand the code; just notice that lines of code are being skipped. If you're thinking that the code doesn't match the assembly being debugged, please bear with me. You'll see where the debugger recognizes new code, but not existing code. And this behavior is occurring on two different laptops, after deleting the code on disk and getting the latest again. Each comment tells you if the debugger hits a line.

[TestMethod()]
[DeploymentItem("PrestoCommon.dll")]
public void ApplicationShouldBeInstalledTest_UseCase9()
{
    // Debugger hits this line
    ApplicationServer appServerAccessor = new ApplicationServer();

    // Debugger does not hit these next two lines
    PrivateObject privateObject = new PrivateObject(appServerAccessor);
    ApplicationServer appServer = ApplicationServerLogic.GetByName("server10");

    // Debugger hits this line. Weirdness: both objects are null, and after this line runs,
    // appServerAccessor is no longer null.
    appServerAccessor.Id = appServer.Id;

    // Skips this line
    ApplicationWithOverrideVariableGroup appWithValidGroup = appServer.ApplicationsWithOverrideGroup[0];

    // Debugger hits this line, but F11 doesn't take me into the method.
    appWithValidGroup.CustomVariableGroup = CustomVariableGroupLogic.GetById("CustomVariableGroups/4");

    // Skips this line
    Assert.AreEqual(true, true);
}

The disassembly shows only the lines of code that actually get hit.

在这里输入图像描述

Now, check this out. If I add a new line of code, the debugger recognizes it, and the other lines of code change, as far as being recognized by the debugger. Just the second line of code, within the method, is new.

[TestMethod()]
[DeploymentItem("PrestoCommon.dll")]
public void ApplicationShouldBeInstalledTest_UseCase9()
{
    // Debugger hits this line
    ApplicationServer appServerAccessor = new ApplicationServer();

    // New line. It's recognized by the debugger, and it shows up in the disassembly.
    if (DateTime.Now > DateTime.Now.AddHours(1)) { return; }

    // Debugger does not hit these next two lines
    PrivateObject privateObject = new PrivateObject(appServerAccessor);
    ApplicationServer appServer = ApplicationServerLogic.GetByName("server10");  // Gets hit now.

    // Debugger hits this line. Weirdness: both objects are null, and after this line runs,
    // appServerAccessor is no longer null.
    appServerAccessor.Id = appServer.Id;  // No longer gets hit.

    // Skips this line (now it's getting hit)
    ApplicationWithOverrideVariableGroup appWithValidGroup = appServer.ApplicationsWithOverrideGroup[0];

    // Debugger hits this line, but F11 doesn't take me into the method. Now this gets skipped.
    appWithValidGroup.CustomVariableGroup = CustomVariableGroupLogic.GetById("CustomVariableGroups/4");

    // Skips this line. Still skipped.
    Assert.AreEqual(true, true);
}

And here's a partial snapshot of the disassembly, showing the new line of code:

在这里输入图像描述

How can this be happening?

Adding to the weirdness, at one point this even returned:

if (DateTime.Now > DateTime.Now.AddDays(1)) { return; }

Things I've tried:
- Delete source code from hard drive and force a get latest
- Repair VS 2012
- Do some VS clean-up
- Use VS 2010, change code, check in, get latest with VS 2012
- Reboot
- Other (can't remember all of them)


This appears to be unit-test specific. In VS 2012:

  • Test > Test Settings
  • Open the selected test settings file
  • Data and Diagnostics > deselect Code Coverage (Visual Studio 2010)
  • Apply
  • Note, I had the advantage of access to the source code, and I downloaded Presto (http://presto.codeplex.com/).

    链接地址: http://www.djcxy.com/p/69324.html

    上一篇: CSS:更改背景上的光标

    下一篇: 在VS 2012中的代码中