Hi,
I recently discovered TypeMock.NET and I have to say I think it's really great :D
I have now changed our build script to run our entire test suite through TMockRunner.exe.
The problem is that I am getting a
System.InvalidOperationException on 6 tests that previously run just fine. All these tests run against the same method which internally instanciates a
System.Xml.Xsl.XslCompiledTransform.
Here are the details of the error:
System.InvalidOperationException : Instances of abstract classes cannot be created.
at System.Diagnostics.SymbolStore.SymDocumentWriter..ctor(ISymUnmanagedDocumentWriter* pDocumentWriter)
at System.Diagnostics.SymbolStore.SymWriter.DefineDocument(String url, Guid language, Guid languageVendor, Guid documentType)
at System.Reflection.Emit.ModuleBuilder.DefineDocumentNoLock(String url, Guid language, Guid languageVendor, Guid documentType)
at System.Reflection.Emit.ModuleBuilder.DefineDocument(String url, Guid language, Guid languageVendor, Guid documentType)
at System.Xml.Xsl.IlGen.XmlILModule.AddSourceDocument(String fileName)
at System.Xml.Xsl.IlGen.GenerateHelper.MarkSequencePoint(ISourceLineInfo sourceInfo)
at System.Xml.Xsl.IlGen.GenerateHelper.MethodBegin(MethodInfo methInfo, ISourceLineInfo sourceInfo, Boolean initWriters)
at System.Xml.Xsl.IlGen.XmlILVisitor.Function(QilFunction ndFunc)
at System.Xml.Xsl.IlGen.XmlILVisitor.Visit(QilExpression qil, GenerateHelper helper, MethodInfo methRoot)
at System.Xml.Xsl.XmlILGenerator.Generate(QilExpression query, AssemblyName asmName)
at System.Xml.Xsl.XslCompiledTransform.CompileIlFromQil(XsltSettings settings)
at System.Xml.Xsl.XslCompiledTransform.LoadInternal(Object stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
at System.Xml.Xsl.XslCompiledTransform.Load(XmlReader stylesheet)
The relevant part of the TypeMock log file shows:
System.Guid instance unsigned int8[] ToByteArray()
System.Runtime.InteropServices.Marshal void Copy(unsigned int8[],int32,int,int32)
System.Runtime.InteropServices.Marshal int StringToCoTaskMemUni(class System.String)
System.IntPtr instance int64 ToInt64()
System.Runtime.InteropServices.Marshal void FreeCoTaskMem(int)
System.Runtime.InteropServices.Marshal bool IsNotWin32Atom(int)
System.Diagnostics.SymbolStore.SymDocumentWriter instance void .ctor(value class System.Diagnostics.SymbolStore.Private.ISymUnmanagedDocumentWriter*)
Sig: 20 01 01 0f 11 2c
IL_0 = ldarg.0
IL_1 = ldstr 0x7000065C
IL_2 = ldstr 0x7000060A
IL_3 = ldnull
IL_4 = ldc.i4.0
IL_5 = call 0x0A000070
IL_6 = brfalse.s 0x69
IL_7 = ldarg.0
IL_8 = ldstr 0x7000065C
IL_9 = ldstr 0x7000060A
IL_10 = ldnull
IL_11 = ldc.i4.0
IL_12 = ldarg.1
IL_13 = ldobj 0x0200000B
IL_14 = box 0x0200000B
IL_15 = call 0x0A000075
IL_16 = dup
IL_17 = ldstr 0x7000065C
IL_18 = ldstr 0x7000060A
IL_19 = ldc.i4.0
IL_20 = call 0x0A000071
IL_21 = brfalse.s 0x20
IL_22 = ldarg.1
IL_23 = ldstr 0x7000065C
IL_24 = ldstr 0x7000060A
IL_25 = ldc.i4.0
IL_26 = call 0x0A000071
IL_27 = unbox 0x0200000B
IL_28 = ldobj 0x0200000B
IL_29 = stobj 0x0200000B
IL_30 = ldstr 0x7000065C
IL_31 = ldstr 0x7000060A
IL_32 = call 0x0A000073
IL_33 = isinst 0x0100005F
IL_34 = brtrue.s 0x02
IL_35 = pop
IL_36 = ret
IL_37 = pop
nop
nop
nop
System.InvalidOperationException instance void .ctor()
System.Environment class System.String GetResourceString(class System.String)
System.Collections.Generic.Dictionary`2 instance void Resize()
<Module> Modifier ? void ReleaseHolder<System::Diagnostics::SymbolStore::Private::ISymUnmanagedDocumentWriter>.{dtor}(Modifier ? Modifier ? value class ReleaseHolder<System::Diagnostics::SymbolStore::Private::ISymUnmanagedDocumentWriter>*)
I figured that it might had something to do with the interception mechanism used by TypeMock.NET being a little too intrusive, so I enabled Fast Mode, in order to intercept only explicitly mocked classes. And sure enough, that works! All tests pass correctly.
Can this be a bug in TypeMock.NET or am I missing something here? By the way, I am using the latest version, 4.0.2.0.
Thanks in advance,
/Enrico