chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
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
asked by jkells (760 points)

8 Answers

0 votes
Hi,

We tried reproducing this issue as you described with no luck.
Please try version 7.5 and let me know if the issue persists.
answered by alex (17k points)
0 votes
Yep still happening with TypeMock 7.5.1

It wasn't crashing until I enabled mocking for 3rd party runners under the TypeMock menu in Visual Studio.
It's crashing every time on our build server running the XUnit runner. Crashes locally with the resharper runner.
answered by jkells (760 points)
0 votes
Here are some other people with the same issue. ( Our issue is also with RavenDB indexes but I isolated it to be just related to using ICSharpCode.NRefactory )

http://forum.ncrunch.net/yaf_postst1302 ... ogram.aspx
answered by jkells (760 points)
0 votes
Here is the relevant part of the TypeMock log.

*Thread 7C7CF30 [17:36:13.37]: ICSharpCode.NRefactory.CSharp.AstNode instance void .ctor()
Resolved TypeRef ICSharpCode.NRefactory.AbstractAnnotatable
Scope token is 23000002
Base module name is ICSharpCode.NRefactory with Len 23
*Thread 7C7CF30 [17:36:13.37]: Sig: 20 00 01
*Thread 7C7CF30 [17:36:13.37]: Adding extra stack 49
IL_0000 = ldstr 0x70030288
IL_0005 = ldtoken 0x01000003
IL_000a = ldtoken 0x0A00129C
IL_000f = ldtoken 0x02000016
IL_0014 = ldnull
IL_0015 = call 0x0A00129B
IL_001a = brfalse 0x0000002A
IL_001f = ldarg.0
IL_0020 = ldc.i4.0
IL_0021 = ldc.i4.0
IL_0022 = ldc.i4.0
IL_0023 = ldc.i4.0
IL_0024 = ldc.i4.0
IL_0025 = ldc.i4.0
IL_0026 = ldc.i4.0
IL_0027 = ldc.i4.0
IL_0028 = ldc.i4.0
IL_0029 = ldc.i4.0
IL_002a = ldc.i4.0
IL_002b = ldc.i4.0
IL_002c = ldc.i4.0
IL_002d = ldc.i4.0
IL_002e = ldc.i4.0
IL_002f = ldc.i4.0
IL_0030 = ldc.i4.0
IL_0031 = ldc.i4.0
IL_0032 = ldc.i4.0
IL_0033 = ldc.i4.0
IL_0034 = ldc.i4.0
IL_0035 = ldc.i4.0
IL_0036 = ldc.i4.0
IL_0037 = ldc.i4.0
IL_0038 = ldc.i4.0
IL_0039 = ldc.i4.0
IL_003a = ldc.i4.0
IL_003b = ldc.i4.0
IL_003c = ldc.i4.0
IL_003d = ldc.i4.0
IL_003e = ldc.i4.0
IL_003f = call 0x0A00129C
IL_0044 = br 0x00000044
IL_0049 = ldstr 0x70030288
IL_004e = ldtoken 0x01000003
IL_0053 = ldtoken 0x0A000223
IL_0058 = ldtoken 0x02000016
IL_005d = ldnull
IL_005e = call 0x0A00129B
IL_0063 = brfalse 0x0000002A
IL_0068 = ldarg.0
IL_0069 = ldc.i4.0
IL_006a = ldc.i4.0
IL_006b = ldc.i4.0
IL_006c = ldc.i4.0
IL_006d = ldc.i4.0
IL_006e = ldc.i4.0
IL_006f = ldc.i4.0
IL_0070 = ldc.i4.0
IL_0071 = ldc.i4.0
IL_0072 = ldc.i4.0
IL_0073 = ldc.i4.0
IL_0074 = ldc.i4.0
IL_0075 = ldc.i4.0
IL_0076 = ldc.i4.0
IL_0077 = ldc.i4.0
IL_0078 = ldc.i4.0
IL_0079 = ldc.i4.0
IL_007a = ldc.i4.0
IL_007b = ldc.i4.0
IL_007c = ldc.i4.0
IL_007d = ldc.i4.0
IL_007e = ldc.i4.0
IL_007f = ldc.i4.0
IL_0080 = ldc.i4.0
IL_0081 = ldc.i4.0
IL_0082 = ldc.i4.0
IL_0083 = ldc.i4.0
IL_0084 = ldc.i4.0
IL_0085 = ldc.i4.0
IL_0086 = ldc.i4.0
IL_0087 = ldc.i4.0
IL_0088 = call 0x0A00129C
IL_008d = ldarg.0
IL_008e = ldstr 0x70030288
IL_0093 = ldstr 0x70022FCB
IL_0098 = ldnull
IL_0099 = ldc.i4.0
IL_009a = ldc.i4.0
IL_009b = call 0x0A001296
IL_00a0 = brfalse.s 0x2F
IL_00a2 = ldarg.0
IL_00a3 = ldstr 0x70030288
IL_00a8 = ldstr 0x70022FCB
IL_00ad = ldnull
IL_00ae = ldc.i4.0
IL_00af = ldc.i4.0
IL_00b0 = call 0x0A00129A
IL_00b5 = dup
IL_00b6 = ldarg.0
IL_00b7 = ldstr 0x70030288
IL_00bc = ldstr 0x70022FCB
IL_00c1 = ldc.i4.0
IL_00c2 = call 0x0A001299
IL_00c7 = isinst 0x0100023C
IL_00cc = brtrue.s 0x02
IL_00ce = pop
IL_00cf = ret
IL_00d0 = pop
= nop
= nop
= nop
*Thread 7C7CF30 [17:36:13.38]:
--- IL Before Insertions ---
IL_0000 = ldstr 0x70030288
IL_0005 = ldtoken 0x01000003
IL_000a = ldtoken 0x0A000223
IL_000f = ldtoken 0x02000016
IL_0014 = ldnull
IL_0015 = call 0x0A00129B
IL_001a = brfalse 0x0000002A
IL_001f = ldarg.0
IL_0020 = ldc.i4.0
IL_0021 = ldc.i4.0
IL_0022 = ldc.i4.0
IL_0023 = ldc.i4.0
IL_0024 = ldc.i4.0
IL_0025 = ldc.i4.0
IL_0026 = ldc.i4.0
IL_0027 = ldc.i4.0
IL_0028 = ldc.i4.0
IL_0029 = ldc.i4.0
IL_002a = ldc.i4.0
IL_002b = ldc.i4.0
IL_002c = ldc.i4.0
IL_002d = ldc.i4.0
IL_002e = ldc.i4.0
IL_002f = ldc.i4.0
IL_0030 = ldc.i4.0
IL_0031 = ldc.i4.0
IL_0032 = ldc.i4.0
IL_0033 = ldc.i4.0
IL_0034 = ldc.i4.0
IL_0035 = ldc.i4.0
IL_0036 = ldc.i4.0
IL_0037 = ldc.i4.0
IL_0038 = ldc.i4.0
IL_0039 = ldc.i4.0
IL_003a = ldc.i4.0
IL_003b = ldc.i4.0
IL_003c = ldc.i4.0
IL_003d = ldc.i4.0
IL_003e = ldc.i4.0
IL_003f = call 0x0A00129C
IL_0044 = br 0x00000016
IL_0049 = ldarg.0
IL_004a = ldsfld 0x04000062
IL_004f = callvirt 0x0A000222
IL_0054 = stfld 0x04000069
IL_0059 = ldarg.0
IL_005a = call 0x0A000223
IL_005f = ldarg.0
IL_0060 = ldstr 0x70030288
IL_0065 = ldstr 0x70022FCB
IL_006a = ldnull
IL_006b = ldc.i4.0
IL_006c = ldc.i4.0
IL_006d = call 0x0A001296
IL_0072 = brfalse.s 0x2F
IL_0074 = ldarg.0
IL_0075 = ldstr 0x70030288
IL_007a = ldstr 0x70022FCB
IL_007f = ldnull
IL_0080 = ldc.i4.0
IL_0081 = ldc.i4.0
IL_0082 = call 0x0A00129A
IL_0087 = dup
IL_0088 = ldarg.0
IL_0089 = ldstr 0x70030288
IL_008e = ldstr 0x70022FCB
IL_0093 = ldc.i4.0
IL_0094 = call 0x0A001299
IL_0099 = isinst 0x0100023C
IL_009e = brtrue.s 0x02
IL_00a0 = pop
IL_00a1 = ret
IL_00a2 = pop
IL_00a3 = ldarg.0
IL_00a4 = callvirt 0x0600036E
IL_00a9 = brfalse.s 0x06
IL_00ab = ldarg.0
IL_00ac = call 0x0600036B
IL_00b1 = ret

<<< IL Before Insertions >>>
*Thread 7C7CF30 [17:36:13.38]:
--- IL After Insertions ---
IL_0000 = ldstr 0x70030288
IL_0005 = ldtoken 0x01000003
IL_000a = ldtoken 0x0A00129C
IL_000f = ldtoken 0x02000016
IL_0014 = ldnull
IL_0015 = call 0x0A00129B
IL_001a = brfalse 0x0000002A
IL_001f = ldarg.0
IL_0020 = ldc.i4.0
IL_0021 = ldc.i4.0
IL_0022 = ldc.i4.0
IL_0023 = ldc.i4.0
IL_0024 = ldc.i4.0
IL_0025 = ldc.i4.0
IL_0026 = ldc.i4.0
IL_0027 = ldc.i4.0
IL_0028 = ldc.i4.0
IL_0029 = ldc.i4.0
IL_002a = ldc.i4.0
IL_002b = ldc.i4.0
IL_002c = ldc.i4.0
IL_002d = ldc.i4.0
IL_002e = ldc.i4.0
IL_002f = ldc.i4.0
IL_0030 = ldc.i4.0
IL_0031 = ldc.i4.0
IL_0032 = ldc.i4.0
IL_0033 = ldc.i4.0
IL_0034 = ldc.i4.0
IL_0035 = ldc.i4.0
answered by jkells (760 points)
0 votes
Hi,

I reproduced it.
I'll keep you posted.
answered by alex (17k points)
0 votes
Hi,

Please download and install this patch.
It should fix this issue.
Let me know if it helps.
answered by alex (17k points)
0 votes
Hi Alex,

Thanks for that. I can confirm that this patch has fixed the broken test for me.
answered by jkells (760 points)
0 votes
Hi,

Thank you for the feedback.
This fix will be included in future releases.
answered by alex (17k points)
...