To reproduce create a new test project, add ICSharpCode.NRefactory from Nuget and run the following test
[TestClass]
public class Class1
{
[TestMethod]
public void Test1()
{
var decl = new TypeDeclaration();
}
}
The test should fail with the following exception
Test method TypeMockCrash.Class1.Test2 threw exception:
System.TypeInitializationException: The type initializer for 'ICSharpCode.NRefactory.CSharp.AstNode' threw an exception. ---> System.InvalidProgramException: Common Language Runtime detected an invalid program.
at ICSharpCode.NRefactory.CSharp.AstNode..ctor()
at ICSharpCode.NRefactory.CSharp.AstNode.NullAstNode..ctor()
at ICSharpCode.NRefactory.CSharp.AstNode..cctor()
--- End of inner exception stack trace ---
at TypeMockCrash.Class1.Test2() in Class1.cs: line 22
The exception only occurs when running without the debugger attached. To reproduce with the debugger attached untick "Suppress JIT optimization on module load" in debugging options.
I can reproduce on two machines here,
the exception only occurs when TypeMock is enabled.
We are running Windows 8.1, VS2013, Resharper 8.2, TypeMock 7.4.3 ( have also tried 7.4.2 )
I should also note it doesn't always fail. Once it starts working it will keep working, if you restart VS and rebuild the project it will often start failing again.
Cheers,
Jared