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

Notification

Icon
Error

NCrunch having issues building a project referencing a Portable Class Library
Erwin
#1 Posted : Wednesday, October 22, 2014 7:56:39 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 10/22/2014(UTC)
Posts: 3
Location: Netherlands

Hi all,

I'm trying to build a project that references a portable class library.

Gallio.Model.ModelException: An exception occurred while invoking a test driver. ---> System.NotSupportedException: Unsupported type: System.Attribute
at Gallio.Common.Reflection.Impl.CecilReflectionPolicy.<>c__DisplayClass62.<MakeType>b__61()
at Gallio.Common.KeyedMemoizer`2.Memoize(TKey key, Func`1 populator)
at Gallio.Common.Reflection.Impl.CecilReflectionPolicy.MakeType(TypeReference typeHandle)
at Gallio.Common.Reflection.Impl.CecilReflectionPolicy.GetTypeBaseType(StaticDeclaredTypeWrapper type)
at Gallio.Common.Reflection.Impl.StaticDeclaredTypeWrapper.<get_BaseType>b__3()
at Gallio.Common.Memoizer`1.Memoize(Func`1 populator)
at Gallio.Common.Reflection.Impl.StaticDeclaredTypeWrapper.get_BaseType()
at Gallio.Common.Reflection.Impl.StaticDeclaredTypeWrapper.get_BaseTypeInternal()
at Gallio.Common.Reflection.Impl.StaticTypeWrapper.get_BaseType()
at Gallio.Common.Reflection.ReflectionUtils.IsDerivedFrom(ITypeInfo type, String qualifiedTypeName)
at Gallio.Common.Reflection.Impl.StaticCodeElementWrapper.<GetAttributeInfos>d__1.MoveNext()
at Gallio.Common.Reflection.AttributeUtils.<ResolveAttributes>d__c.MoveNext()
at Gallio.Common.Reflection.AttributeUtils.GetAttribute(ICodeElementInfo element, Type attributeType, Boolean inherit)
at Gallio.Common.Reflection.AttributeUtils.GetAttribute[T](ICodeElementInfo element, Boolean inherit)
at Gallio.Model.ModelUtils.PopulateMetadataFromAssembly(IAssemblyInfo assembly, PropertyBag metadataMap)
at Gallio.XunitAdapter.Model.XunitTestExplorer.CreateAssemblyTest(IAssemblyInfo assembly)
at Gallio.XunitAdapter.Model.XunitTestExplorer.GetAssemblyTest(IAssemblyInfo assembly, Test parentTest, Version frameworkVersion, Boolean populateRecursively)
at Gallio.XunitAdapter.Model.XunitTestExplorer.ExploreImpl(IReflectionPolicy reflectionPolicy, ICodeElementInfo codeElement)
at Gallio.Model.Helpers.TestExplorer.Explore(IReflectionPolicy reflectionPolicy, ICodeElementInfo codeElement)
at Gallio.Model.Helpers.SimpleTestDriver.GenerateTestModel(IReflectionPolicy reflectionPolicy, IEnumerable`1 codeElements, IMessageSink messageSink)
at Gallio.Model.Helpers.SimpleTestDriver.DescribeImpl(IReflectionPolicy reflectionPolicy, IList`1 codeElements, TestExplorationOptions testExplorationOptions, IMessageSink messageSink, IProgressMonitor progressMonitor)
at Gallio.Model.BaseTestDriver.Describe(IReflectionPolicy reflectionPolicy, IList`1 codeElements, TestExplorationOptions testExplorationOptions, IMessageSink messageSink, IProgressMonitor progressMonitor)
at Gallio.Model.DefaultTestFrameworkManager.FilteredTestDriver.<>c__DisplayClass17.<DescribeImpl>b__15(ITestDriver driver, IList`1 items, Int32 driverCount)
at Gallio.Model.DefaultTestFrameworkManager.FilteredTestDriver.ForEachDriver[T](MultiMap`2 testFrameworkPartitions, Func`4 func)
--- End of inner exception stack trace ---
at Gallio.Model.DefaultTestFrameworkManager.FilteredTestDriver.ForEachDriver[T](MultiMap`2 testFrameworkPartitions, Func`4 func)
at Gallio.Model.DefaultTestFrameworkManager.FilteredTestDriver.DescribeImpl(IReflectionPolicy reflectionPolicy, IList`1 codeElements, TestExplorationOptions testExplorationOptions, IMessageSink messageSink, IProgressMonitor progressMonitor)
at Gallio.Model.BaseTestDriver.Describe(IReflectionPolicy reflectionPolicy, IList`1 codeElements, TestExplorationOptions testExplorationOptions, IMessageSink messageSink, IProgressMonitor progressMonitor)
at nCrunch.TestExecution.Frameworks.Gallio.GallioWrapper.FindFrameworkTestsInAssembly(ReflectedAssembly assembly, FilePath assemblyFilePath, IList`1 referencedAssemblyFilePaths)
at nCrunch.TestExecution.Frameworks.Gallio.GallioTestFramework.FindFrameworkTestsInAssembly(ReflectedAssembly assembly, FilePath assemblyFilePath, IList`1 referencedAssemblyFilePaths)
at nCrunch.TestExecution.TestFinder.FindTestsForFrameworks(ReflectedAssembly assembly, FilePath assemblyFilePath, IList`1 referencedAssemblyFilePaths, TestFrameworkDescription[] frameworks)
at nCrunch.Compiler.StaticManipulation.BuiltAssembly.DiscoverTests(TestFrameworkDescription[] applicableTestFrameworks)
at nCrunch.Compiler.RemoteBuildRunner.#=qqZ$biBs7mvGRD42no0zcEfaWi4v$NuLBVy7NcKpqVcU=(ComponentBuildParameters #=q8_ZGEckiLbRsUjNXvAaKOg==, FilePath #=qkb_tmWgu4KtzCWen$hSPsMPrQ1mkbV0Q2nGsXkZrK6s=, BuildOutput #=qnXDAQpnfqAeJl0p31Gcd1w==, DirectoryPath[] #=qSofaDjiwWEBgv$s22DxHPsKSbp4hruna3jReeOLGOyg=, FilePath[] #=qfLDmMJzWXbDJK4KiH6tg6MwNo8hcfZSKZe0YwSutOdtYLr7gvxG6$V$9q044oc1x)
at nCrunch.Compiler.RemoteBuildRunner.Build(ComponentBuildParameters parameters)

If the referenced project is NOT a portable class library, but otherwise exactly the same, it works fine.

Any thoughts on how to solve this?

Regards,
Erwin
Remco
#2 Posted : Wednesday, October 22, 2014 9:40:42 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi Erwin,

Thanks for sharing this issue.

NCrunch relies on Gallio for its Xunit v1 integration. Gallio is quite old now and it predates the introduction of the PCL libraries - so it isn't really surprising that it is unable to make sense of metadata inside these libraries.

However, something that doesn't make sense to me is why this is happening for you in a project that is referencing the PCL project, rather than the PCL project itself. The failure is being caused by code intended to find tests within the output assembly, at a point where it attempts to parse assembly-level attributes inside the test project. Technically, this should have nothing to do with the PCL library at all - as an Xunit v1 test project by nature cannot be PCL. The only conclusion I can draw is that somehow NCrunch is trying to discover tests within the PCL assembly itself - which basically shouldn't happen.

Is there any chance you can construct and submit a sample solution that demonstrates this problem using the (- BROKEN LINK -)contact form[/url]? I've tried to reproduce this issue using a similar structure to what you've described and so far haven't been able to.


Cheers,

Remco
Erwin
#3 Posted : Wednesday, October 22, 2014 10:04:03 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 10/22/2014(UTC)
Posts: 3
Location: Netherlands

Hi Remco,

Thank you for your reply.

I got the issue while working on an open source testing framework called Chill. This commit still has the issue:

https://github.com/Erwin...59cc25c7d05a141bc9f55e7

The project that's failing in NCrunch is Chill.Examples.Tests. In the latest 'development' branch, I've 'solved' the issue by referencing a non PCL version of Chill, but i'd like to avoid that if possible.

If you need more info or a more separate repro, I'd love to hear it.

best regards,
Erwin
Remco
#4 Posted : Wednesday, October 22, 2014 10:48:27 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Thanks Erwin. I'm having some trouble getting this commit to build on my machine. Is there any chance you could send through a simpler example?
Erwin
#5 Posted : Wednesday, October 22, 2014 11:29:42 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 10/22/2014(UTC)
Posts: 3
Location: Netherlands

Hi Remco,

Just submitted a repro on the contact form. I've found out where the issues lie...

I'm using an assembly level attribute from the PCL assembly, which causes the build to fail. If you use the attribute on class level it 'only' doesn't see the tests.

best regards,
Erwin
Remco
#6 Posted : Wednesday, October 22, 2014 8:58:22 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Great stuff - that makes perfect sense! I'm not sure if I have an easy path to fix this right now .. if you need the assembly level attribute to be applied outside of NCrunch but still want NCrunch to work, you can simply disable it with an override. For example:

#if !NCRUNCH
[assembly: MyAttributeValue("abc")]
#endif
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.057 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download