Build/Test Issues

Issue with TypeCatalog only under NCrunch

Started by scmccart on 6,850 views

Hey, I've come across some odd behavior where System.ComponentModel.Composition.Hosting.TypeCatalog instances initialized with generic type definitions lose track of their parts when running under NCrunch but not under the normal MSTest runner.

Here's the whole test file,

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.Linq;

namespace MinimumTypeCatalogIssue
{
    [TestClass]
    public class UnitTest1
    {
        public interface TestInterface
        {

        }

        [Export(typeof(TestInterface))]
        public class TestA<T> : TestInterface
        {

        }

        [Export(typeof(TestInterface))]
        public class TestB<T> : TestInterface
        {

        }

        [TestMethod]
        public void TestMethod1()
        {
            var catalog = new TypeCatalog(typeof(TestA<>), typeof(TestB<>));

            Assert.AreNotEqual(0, catalog.Parts.Count());
        }
    }
}


Any clue on how to work around this one or if it can be fixed?

Edited

Hi,

Thanks for sharing this issue.

This looks to be related to the .NET version of the task runner NCrunch is using to execute the test. It appears that Microsoft introduced a fix for the TypeCatalog class in v4.5 of the .NET framework. This means that any environment executing this code with a framework version less than v4.5 will fail to execute it correctly.

I observed the issue in all test runners except for MSTest, which suggests that this is quite a widespread issue. Most test runners continue to work with v4.5 and v4.5.1 code using v4 runners, as the metadata is still the same. It seems you've been unlucky enough to find a point of difference.

Other than changing the way your code works to avoid using TypeCatalog for generic types, I see no way to work around this problem. It will need to be resolved with a code fix to NCrunch. I'll try to get you a fixed build before Christmas.


Cheers,

Remco
Hi,

I've prepared a build containing a fix for this issue. It's a V2 build - I hope that's ok.

Download links are below:

http://downloads.ncrunch.net/NCrunch_VS2012_2.3.0.14.msi
http://downloads.ncrunch.net/NCrunch_VS2013_2.3.0.14.msi
http://downloads.ncrunch.net/NCrunch_GridNodeServer_2.3.0.14.msi

It would be great if you could confirm whether this solves the issue for you. If so, I'll include this fix in all future releases.

Have a great Christmas!


Cheers,

Remco
Just getting back to work today, will try this out right now! thanks!
This build does indeed fix the issue, thanks for the quick turn around!

Post a reply

Log in to reply.