Hi Remco,
after enabling NCrunch on the Newtonsoft.Json.Net40.sln from https://github.com/JamesNK/Newtonsoft.Json
I get this error message:
[15:39:06.7193-AnalysisTask-40] ERROR (Analysis): A failure occurred while analysing the assembly [SnapshotComponent: Newtonsoft.Json.Tests.Net40, 1, 35118415]: System.InvalidProgramException: Common Language Runtime detected an invalid program.
at Newtonsoft.Json.JsonConverterAttribute..ctor(Type converterType)
at System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule pModule, IRuntimeMethodInfo pCtor, Byte** ppBlob, Byte* pEndBlob, Int32* pcNamedArgs)
at System.Reflection.CustomAttribute.CreateCaObject(RuntimeModule module, IRuntimeMethodInfo ctor, IntPtr& blob, IntPtr blobEnd, Int32& namedArgs)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit)
at System.RuntimeType.GetCustomAttributes(Boolean inherit)
at NUnit.Core.Reflect.GetAttributes(ICustomAttributeProvider member, Boolean inherit)
at NUnit.Core.Reflect.HasAttribute(ICustomAttributeProvider member, String attrName, Boolean inherit)
at NUnit.Core.Builders.SetUpFixtureBuilder.CanBuildFrom(Type type)
at NUnit.Core.Extensibility.SuiteBuilderCollection.CanBuildFrom(Type type)
at NUnit.Core.TestFixtureBuilder.CanBuildFrom(Type type)
at NUnit.Core.Builders.TestAssemblyBuilder.GetFixtures(Assembly assembly, String ns)
at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, Boolean autoSuites)
at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, String testName, Boolean autoSuites)
at NUnit.Core.TestSuiteBuilder.Build(TestPackage package)
at nCrunch.TestExecution.Frameworks.NUnit.NUnitDynamicTestFinder.FindFrameworkTestsUsingRuntimeInvoke(TestPackage package, ILogger logger, List`1 tests)
at nCrunch.TestExecution.Frameworks.NUnit.NUnitTestFramework.FindFrameworkTestsInAssembly(ReflectedAssembly assembly, String assemblyFilePath, String[] referencedAssemblyFilePaths)
at nCrunch.TestExecution.TestFinder.FindTestsForFrameworks(ReflectedAssembly assembly, String assemblyFilePath, String[] referencedAssemblyFilePaths, TestFrameworkDescription[] frameworks)
at nCrunch.TestExecution.RemoteTaskRunner.AnalyseAssembly(TestFrameworkDescription[] applicableFrameworks)
Remco NCrunch Developer
#4050
23 Apr 2013 22:49 UTC
Hi,
Thanks for sharing this issue. It looks to be a clash between NCrunch's performance analysis instrumentation and a particular IL arrangement or CLR security feature that applies to this specific situation.
To work around this issue, set the analyse line execution times setting to FALSE.
I'll see what I can do about addressing this issue properly in the next maintenance release. It's quite complex, so I'm afraid there isn't much more information I can share at this stage. Thanks for providing the sample code, as this makes analysing the issue so much easier!
Cheers,
Remco
Thanks for sharing this issue. It looks to be a clash between NCrunch's performance analysis instrumentation and a particular IL arrangement or CLR security feature that applies to this specific situation.
To work around this issue, set the analyse line execution times setting to FALSE.
I'll see what I can do about addressing this issue properly in the next maintenance release. It's quite complex, so I'm afraid there isn't much more information I can share at this stage. Thanks for providing the sample code, as this makes analysing the issue so much easier!
Cheers,
Remco
Remco NCrunch Developer
#4336
04 Jul 2013 05:00 UTC
I've done some more digging into what is happening here ...
The project this exception is being thrown on is making use of AllowPartiallyTrustedCallersAttribute, which seems to trigger the CLR to impose additional restrictions on the nature of code that can be executed from .NET 4.0 onwards. These restrictions are extremely broad and I haven't yet found a way to work around them without disabling performance instrumentation. I would expect that the cases in which people would need to make use of this attribute within the NCrunch test environment are extremely limited, so a viable alternative to disabling performance analysis could be to simply switch off the attribute for NCrunch builds as such:
#if !NCRUNCH
[assembly: AllowPartiallyTrustedCallers]
#endif
A fix is being included in the next maintenance release that will detect the presence of this attribute and will automatically turn off performance analysis while showing a meaningful warning to describe what is happening.
The project this exception is being thrown on is making use of AllowPartiallyTrustedCallersAttribute, which seems to trigger the CLR to impose additional restrictions on the nature of code that can be executed from .NET 4.0 onwards. These restrictions are extremely broad and I haven't yet found a way to work around them without disabling performance instrumentation. I would expect that the cases in which people would need to make use of this attribute within the NCrunch test environment are extremely limited, so a viable alternative to disabling performance analysis could be to simply switch off the attribute for NCrunch builds as such:
#if !NCRUNCH
[assembly: AllowPartiallyTrustedCallers]
#endif
A fix is being included in the next maintenance release that will detect the presence of this attribute and will automatically turn off performance analysis while showing a meaningful warning to describe what is happening.
Post a reply
Log in to reply.