1

Closed

Investigate and enable Refactor/Rename tests

description

The refactor/rename (RefactorRenameTests.cs) tests are randomly failing on the CI box and have been disabled. I spent some time investigating it but since there is no consisent repro and it does not happen on my box it's very time consuming. Here are my findings:
  • the failures are caused by the NullReferenceException that happens in GetFileChanges() method (EFRefactoringOperation.cs)
  • the cause of the NRE is that on the line:
    IEnumerable<CodeElement2> codeElements = generatedCodeProjectItem.FileCodeModel.CodeElements.OfType<CodeElement2>(); FileCodeModel is null
  • msdn is not helpful
  • I noticed that when the first test fails the generatedItem does not seem to be added (the ItemAdded event set up like this:
            ((Events2)((DTE2)artifactProjectItem.DTE).Events).ProjectItemsEvents.ItemAdded +=
                p => Debug.WriteLine("Added project item: {0}, {1}", p.Name, DateTime.Now.ToString("o"));
    
is not fired)
  • I thought it might have been a threading issue where we invoke RunCustomTool() and then we try accessing the generated code before it was actually generated but waiting (a loop, 20 iterations, sleep 100ms) did not help - the event was not fired and the FileCodeModel was null)
  • the second test would fail in the same way even though the events seem to be fired (so not sure if firing/not firing events is related. However on the machine where tests pass the events are fired).
  • another hypothesis is that since we are using the same instance of VS one of the tests ran earlier leave VS in a weird state that is causing the failure (however on a machine where tests pass the tests are executed in the same order)
  • I also wonder if the file used for the test is not somehow locked what causes the failure
  • an idea to debug this is to use Debugger.Break() - this should allow to look around/debug when stuff is about to break
  • we are considering removing/reimplementing rename/refactor so it might not be worth any further investigation (http://entityframework.codeplex.com/workitem/451)
Closed Oct 1, 2013 at 6:33 PM by RoMiller
We are removing the feature (tracked by another work item)

comments

RoMiller wrote Apr 4, 2013 at 4:46 PM

EF Team Triage: These aren't critical tests and we will likely disable this feature in EF6. Moving to Future for the moment but we can close if we disable the feature.