Build/Test Issues

NCrunch can't build projects that use generic attributes

Started by yusuf on 1,580 views

Code to reproduce:

namespace ConsoleApp1;

[AttributeUsage(AttributeTargets.All)]
public class TestAttribute<T> : Attribute
{
}

[Test<string>]
public class Program
{
    public static void Main()
    {
    }
}


Error message:

NCrunch has encountered an internal error: System.Exception: nCrunch.Compiler.StaticManipulation.CilTypeHashException: Unable to hash type 'ConsoleApp1.Program' due to exception: System.NotSupportedException: TypeSpec
   at nCrunch.Compiler.Cil.Methods.CilMemberReference.GetReferencedTypeImpactId()
   at nCrunch.Compiler.Cil.CustomAttributes.CilCustomAttribute..(CilMemberReference )
   at nCrunch.Compiler.Cil.CustomAttributes.CilCustomAttribute.[T](Func`2 , Func`2 )
   at nCrunch.Compiler.Cil.CustomAttributes.CilSortedCustomAttributeEnumerator.MoveNext()
   at nCrunch.Compiler.StaticManipulation.CilMethodHashGenerator.HashType(FNV64& hash, CilTypeDefinition type)
   at nCrunch.Compiler.StaticManipulation.BuiltCilAssembly.ExtractClassMethodData(TestFrameworkDescription[] applicableTestFrameworks, IDictionary`2 codeFileIDsByForegroundFilePath, Boolean storeImpactHashes)
   at nCrunch.Compiler.StaticManipulation.BuiltCilAssembly.ExtractClassMethodData(TestFrameworkDescription[] applicableTestFrameworks, IDictionary`2 codeFileIDsByForegroundFilePath, Boolean storeImpactHashes)
   at nCrunch.Compiler.CilProcessingTasks.CilMethodHashingTask..()
   at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
   at nCrunch.Compiler.CilProcessingTasks.ConcurrentCilTaskProcessor.()
   at nCrunch.Compiler.CilProcessingTasks.ConcurrentCilTaskProcessor.ProcessTasks(Int32 backgroundThreadsAllowed)
   at nCrunch.Compiler.RemoteBuildRunner.(ComponentInstrumentationParameters , BuildOutput , IBackgroundTaskProcessor )
   at nCrunch.Compiler.RemoteBuildRunner.PerformPostProcessingOfBuiltAssembly(ComponentInstrumentationParameters instrumentationParameters, BuildOutput output, IBackgroundTaskProcessor backgroundTaskProcessor)
   at nCrunch.Core.BuildManagement.BuildEnvironment..()
   at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
   at nCrunch.Core.BuildManagement.BuildEnvironment.Build(SnapshotComponent snapshotComponentToBuild, IList`1 referencedComponents, GridClientId gridClientId, IList`1 customEnvironmentVariables, IPlatformBuildExtender extender, Guid taskId, GridAddress clientAddress, Boolean extractCoverageReportStructure)
Hi, thanks for sharing this.

I actually didn't know this was possible. We'll implement a fix for this in the next release. Thanks for bringing it to my attention.
This post has been deleted.
Would you be interested in trying the build below? It contains a fix to introduce support for generic custom attributes.

NCrunch_Console_4.16.0.1.msi
NCrunch_Console_4.16.0.1.zip
NCrunch_GridNodeServer_4.16.0.1.msi
NCrunch_GridNodeServer_4.16.0.1.zip
NCrunch_LicenseServer_4.16.0.1.zip
NCrunch_VS2010_4.16.0.1.msi
NCrunch_VS2010_4.16.0.1.zip
NCrunch_VS2012_4.16.0.1.msi
NCrunch_VS2012_4.16.0.1.zip
NCrunch_VS2013_4.16.0.1.msi
NCrunch_VS2013_4.16.0.1.zip
NCrunch_VS2015_4.16.0.1.msi
NCrunch_VS2015_4.16.0.1.msi.7z
NCrunch_VS2015_4.16.0.1.zip
NCrunch_VS2017_4.16.0.1.msi
NCrunch_VS2017_4.16.0.1.msi.7z
NCrunch_VS2017_4.16.0.1.zip
NCrunch_VS2019_4.16.0.1.msi
NCrunch_VS2019_4.16.0.1.msi.7z
NCrunch_VS2019_4.16.0.1.zip
NCrunch_VS2022_4.16.0.1.msi
NCrunch_VS2022_4.16.0.1.msi.7z
NCrunch_VS2022_4.16.0.1.zip

Post a reply

Log in to reply.