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

Notification

Icon
Error

Optional argument causes build error when PCL does not target Silverlight
yanglee
#1 Posted : Tuesday, November 6, 2012 5:08:06 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/25/2012(UTC)
Posts: 89
Location: China

Thanks: 23 times
Was thanked: 19 time(s) in 18 post(s)
NCrunch 1.42.0.12
VS2012
Windows 8 64bit

This is a similar issue to this one: Portable class libraries fail to build if they include metro

Resharper and the built in test runner of VS2012 works fine. I tested some classes as optional argument and found only String and user created classes don't cause this issue.

Steps to reproduce the issue:

1) Create a Portable Class Library;
2) Remove Silverlight as target platform;
3) Add the following class:

Code:
    public class MyClass
    {
        public void DoSomething(Type arg = null)
        {
        }
    }


4) Enable NCrunch. I get the following build error:

Code:
[13:04:19.2936-BuildTask-7] ERROR (Compilation): PortableClassLibrary1:  (0): System.InvalidOperationException: Failed to resolve type: System.Type
   at Mono.Cecil.Mixin.CheckedResolve(TypeReference self)
   at Mono.Cecil.MetadataBuilder.GetConstantType(TypeReference constant_type, Object constant)
   at Mono.Cecil.MetadataBuilder.AddConstant(IConstantProvider owner, TypeReference type)
   at Mono.Cecil.MetadataBuilder.AddParameter(UInt16 sequence, ParameterDefinition parameter, ParamTable table)
   at Mono.Cecil.MetadataBuilder.AddParameters(MethodDefinition method)
   at Mono.Cecil.MetadataBuilder.AddMethod(MethodDefinition method)
   at Mono.Cecil.MetadataBuilder.AddMethods(TypeDefinition type)
   at Mono.Cecil.MetadataBuilder.AddType(TypeDefinition type)
   at Mono.Cecil.MetadataBuilder.AddTypeDefs()
   at Mono.Cecil.MetadataBuilder.BuildTypes()
   at Mono.Cecil.MetadataBuilder.BuildModule()
   at Mono.Cecil.ModuleWriter.<BuildMetadata>b__0(MetadataBuilder builder, MetadataReader _)
   at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func`3 read)
   at Mono.Cecil.ModuleWriter.BuildMetadata(ModuleDefinition module, MetadataBuilder metadata)
   at Mono.Cecil.ModuleWriter.WriteModuleTo(ModuleDefinition module, Stream stream, WriterParameters parameters)
   at Mono.Cecil.ModuleDefinition.Write(Stream stream, WriterParameters parameters)
   at Mono.Cecil.ModuleDefinition.Write(String fileName, WriterParameters parameters)
   at nCrunch.Compiler.StaticManipulation.BuiltAssembly.#=qVVxyPFyV07SGmGwvnqJ58GP1CjxFAgHrcNQX4zelNig=.#=qVhwsrVPHh0cRHCRNhV_dH0P51C3c8nYxqUsFAc9QohE=()
   at nCrunch.Compiler.StaticManipulation.BuiltAssembly.#=qxEWPuumRjENxBqFDuwVIPQ==(Action #=qNFebLMPvzAnxbLsp9k2cSw==)
   at nCrunch.Compiler.StaticManipulation.BuiltAssembly.Instrument(ComponentSourceLineMap sourceLineMap, IDictionary`2 instrumentationDirectivesByCodeFileId, IDictionary`2 codeFileIDsByFilePath, Boolean proxyProcessIsActive, Int32 componentId, IInstrumentationFilter[] instrumentationFilters)
   at nCrunch.Compiler.RemoteBuildRunner.#=qPVZ1Qvt7K1dg$S2Tsbki14jXz55V81a4b0lw2Gy2H9I=(ComponentBuildParameters #=qaLbij$nvLcp1xzKxt0ECzQ==, String #=q3Qo9mUTR8Ej_efd8kOmuaRPOgcadukhysqWjzfCknIs=, BuildOutput #=qc1a02FFghipoiqbEEWdEuA==, String #=qib4s6fOXht5wNWFzsTveI52_75PbtixMjh7DSUYzHhg=)
   at nCrunch.Compiler.RemoteBuildRunner.Build(ComponentBuildParameters parameters)



Regards,

Yang
Remco
#2 Posted : Tuesday, November 6, 2012 9:32:42 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi Yang,

Thanks for reporting this problem - it looks to be very similar to a resolution issue that was fixed in 1.42, which suggests there is more to this issue than first thought. I'll see if I can arrange a fix for it in the next minor revision.


Cheers,

Remco
Remco
#3 Posted : Tuesday, November 6, 2012 9:06:47 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
For anyone experiencing this problem, a potential workaround is to turn off the 'Instrument Output Assembly' setting for the project failing to build. Although this will turn off code coverage for the project, it should allow other depending projects in your solution to build and be processed normally.


Cheers,

Remco
1 user thanked Remco for this useful post.
yanglee on 11/7/2012(UTC)
yanglee
#4 Posted : Wednesday, November 7, 2012 4:55:08 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/25/2012(UTC)
Posts: 89
Location: China

Thanks: 23 times
Was thanked: 19 time(s) in 18 post(s)
Remco;3110 wrote:
For anyone experiencing this problem, a potential workaround is to turn off the 'Instrument Output Assembly' setting for the project failing to build. Although this will turn off code coverage for the project, it should allow other depending projects in your solution to build and be processed normally.


Cheers,

Remco

Thanks, it works!
1 user thanked yanglee for this useful post.
Remco on 11/7/2012(UTC)
yanglee
#5 Posted : Thursday, November 15, 2012 3:29:01 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/25/2012(UTC)
Posts: 89
Location: China

Thanks: 23 times
Was thanked: 19 time(s) in 18 post(s)
It appears turning off 'Instrument Output Assembly' not only turns off code coverage, but also causes another problem: When navigate to a source file via the stack trace of the Exception popup or NCrunch Tests window, a copied file in the NCrunch's workspace will be opened instead of the original source file in the solution folder.
Remco
#6 Posted : Thursday, November 15, 2012 8:04:12 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
This makes sense. The instrumentation step is also used to write the debugging information of the assembly so that it points back to the right place. There isn't an easy fix for this... I think I'd rather focus on the main issue that caused you to need to turn off this setting in the first place :)
Remco
#7 Posted : Monday, December 10, 2012 4:52:30 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
For anyone interested, 1.43 has just been released with a fix for the above PCL build problem.
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.047 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download