Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Issue with TypeCatalog only under NCrunch
scmccart
#1 Posted : Wednesday, December 18, 2013 10:12:10 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 7/27/2012(UTC)
Posts: 4
Location: North Carolina

Thanks: 1 times
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,

Code:
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?
Remco
#2 Posted : Wednesday, December 18, 2013 11:31:35 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,161

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
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
Remco
#3 Posted : Tuesday, December 24, 2013 6:26:36 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,161

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
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
1 user thanked Remco for this useful post.
scmccart on 1/6/2014(UTC)
scmccart
#4 Posted : Monday, January 6, 2014 3:36:56 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 7/27/2012(UTC)
Posts: 4
Location: North Carolina

Thanks: 1 times
Just getting back to work today, will try this out right now! thanks!
scmccart
#5 Posted : Monday, January 6, 2014 3:55:58 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 7/27/2012(UTC)
Posts: 4
Location: North Carolina

Thanks: 1 times
This build does indeed fix the issue, thanks for the quick turn around!
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.035 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download