{"id":26673660,"url":"https://github.com/networm/ncrunchadapterforunity","last_synced_at":"2025-04-12T06:13:42.402Z","repository":{"id":139107217,"uuid":"105786498","full_name":"networm/NCrunchAdapterForUnity","owner":"networm","description":"Fix NCrunch didn't work in project generated by Unity.","archived":false,"fork":false,"pushed_at":"2017-11-11T07:07:02.000Z","size":231,"stargazers_count":7,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T06:13:37.394Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/networm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-04T15:42:10.000Z","updated_at":"2024-03-17T15:21:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"29dcb395-22b9-4e9f-bfaa-785c3ed7b337","html_url":"https://github.com/networm/NCrunchAdapterForUnity","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/networm%2FNCrunchAdapterForUnity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/networm%2FNCrunchAdapterForUnity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/networm%2FNCrunchAdapterForUnity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/networm%2FNCrunchAdapterForUnity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/networm","download_url":"https://codeload.github.com/networm/NCrunchAdapterForUnity/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248525138,"owners_count":21118619,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-26T01:37:13.471Z","updated_at":"2025-04-12T06:13:42.395Z","avatar_url":"https://github.com/networm.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NCrunchAdapterForUnity\r\n\r\nFix NCrunch didn't work in project generated by Unity.\r\n\r\n## Introduction\r\n\r\nWhen enabled NCrunch in project generated by Unity, after initializing the status in `Tests` window would become `Analysis failed` and log message is:\r\n\r\n```\r\nAn error occurred while analysing this project after it was built: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---\u003e System.InvalidCastException: Unable to cast object of type 'nCrunch.Module.NUnit3.Integration.NUnit3CallbackProxy' to type 'System.Web.UI.ICallbackEventHandler'.\r\n   at NUnit.Framework.Api.FrameworkController.LoadTestsAction..ctor(FrameworkController controller, Object handler)\r\n   --- End of inner exception stack trace ---\r\n   at System.RuntimeMethodHandle._InvokeConstructor(Object[] args, SignatureStruct\u0026 signature, IntPtr declaringType)\r\n   at System.RuntimeMethodHandle.InvokeConstructor(Object[] args, SignatureStruct signature, RuntimeTypeHandle declaringType)\r\n   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)\r\n   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)\r\n   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)\r\n   at nCrunch.Module.NUnit3.Integration.FrameworkController.LoadTests(INUnit3CallbackHandler handler)\r\n   at nCrunch.Module.NUnit3.Integration.NUnit3FrameworkInteractor.\u003cprepareFramework\u003eb__7_0()\r\n   at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)\r\n   at nCrunch.Common.PerformanceTracking.PerfTracker.TryTrackActivity(String name, Action activity)\r\n   at nCrunch.Module.NUnit3.Integration.NUnit3FrameworkInteractor.prepareFramework(DynamicProxy[] dynamicProxies)\r\n   at nCrunch.Module.NUnit3.Integration.NUnit3FrameworkInteractor..ctor(ReflectedAssembly assembly, IList`1 referencedAssemblyFilePaths, ComponentUniqueName testComponentUniqueName, DynamicProxy[] dynamicProxies)\r\n   at nCrunch.Module.NUnit3.Integration.NUnit3FrameworkRuntimeEnvironment.FindFrameworkTestsInAssembly(ReflectedAssembly assembly, FilePath assemblyFilePath, IList`1 referencedAssemblyFilePaths, ComponentUniqueName testComponentUniqueName, PlatformType platformType, DynamicProxy[] dynamicProxies)\r\n   at nCrunch.TestExecution.TestFinder..()\r\n   at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)\r\n   at nCrunch.TestExecution.TestFinder..()\r\n   at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)\r\n   at nCrunch.TestExecution.TestFinder.FindTestsForFrameworks(ReflectedAssembly assembly, FilePath assemblyFilePath, IList`1 referencedAssemblyFilePaths, DescribedTestFrameworkDiscoverer[] describedDiscoverers, ComponentUniqueName testComponentUniqueName, PlatformType platformType, DynamicProxy[] dynamicProxies)\r\n   at nCrunch.TestExecution.RemoteTaskRunner.AnalyseAssembly(DescribedTestFrameworkDiscoverer[] applicableFrameworks, ComponentUniqueName testComponentUniqueName, PerfTracker perfTracker)\r\n```\r\n\r\nThe reason is Unity customed NUnit 3.5.0 dll which had critical code that was fundamentally incompatible with the normal NUnit API.\r\nNCrunch developer has explaned it at [Build failed on Unity project - Build/Test Issues - NCrunch Forum](http://forum.ncrunch.net/yaf_postsm11307_Build-failed-on-Unity-project.aspx#post11307).\r\n\r\nThe Unity customed NUnit 3.5.0 dll is at path `C:\\Program Files\\Unity\\Editor\\Data\\UnityExtensions\\Unity\\TestRunner\\net35\\unity-custom\\nunit.framework.dll`\r\n\r\n## Solution\r\n\r\nChange reference from Unity customed NUnit dll to NUnit official dll in csharp project.\r\n\r\n## Environment\r\n\r\n- NCrunch 3.11.0.9\r\n- Unity 2017.1.1f1\r\n- Visual Studio Community 2017 15.3.5\r\n\r\nThese are release versions and update-to-date until 2017/10/04.\r\n\r\n## Usage\r\n\r\n1. Clone repository into `Assets/Plugins/Editor` directory.\r\n2. Click menu `Assets` \u003e `Open C# Project` to open Visual Studio.\r\n\r\nJob done! You will notice that NCrunch works normally.\r\n\r\nNote: `External Script Editor` should be `Visual Studio` to make Unity generate project compatible with Visual Studio.\r\n\r\nNote: Use this adapter wouldn't break `Test Runner` in Unity. You could still use `Test Runner` run Unity related tests at the same time. Reference in project only affects behaviour in Visual Studio.\r\n\r\n## Inside\r\n\r\n1. `Open C# Project` then Unity will regenerate project if detect changes, then Visual Studio is opened after that `OnGeneratedCSProjectFiles()` is called. So if we change project in this callback, Visual Studio will prompt solution has changed and do you want to reload it everytime you `Open C# Project`. It's not good.\r\n2. So I change to use method provided by `Visual Studio Tools for Unity` - `ProjectFilesGenerator.ProjectFileGeneration`. Change project in this callback will not cause solution prompt reload.\r\n3. Unity use customed NUnit 3.5.0, so we use the same version to get best compatibility.\r\n\r\n## Library\r\n\r\n[NUnit](http://nunit.org/) - v3.5.0 - [MIT License](http://nunit.org/nuget/nunit3-license.txt)\r\n\r\n## License\r\n\r\n[MIT License](LICENSE)\r\n\r\n## Reference\r\n\r\n1. [Build failed on Unity project - Build/Test Issues - NCrunch Forum](http://forum.ncrunch.net/yaf_postsm11307_Build-failed-on-Unity-project.aspx#post11307)\r\n2. [Customize Project Files Created by VSTU | Microsoft Docs](https://docs.microsoft.com/en-us/visualstudio/cross-platform/customize-project-files-created-by-vstu)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetworm%2Fncrunchadapterforunity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetworm%2Fncrunchadapterforunity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetworm%2Fncrunchadapterforunity/lists"}