Build/Test Issues

ValueTask confuses NSubstitute

Started by MihaMarkic on 4,884 views

I'm seeing a problem probably related to NCrunch.

See the code below.
One needs NUnit and NSubstitute nuget packages. It's a .net 4.6.1 class library.
The test passes.

Now, add System.Threading.Tasks.Extensions 4.5.1 nuget library and test will start failing.
If running outside NCrunch test still succeeds.
If I downgrade System.Threading.Tasks.Extensions to i.e. 4.4.0. it works again.

I think that MS screwed something with System.Threading.Tasks.Extensions 4.5.1 (it manifests problems in i.e. Xamarin as well).

Perhaps something to consider.

You can download repro here.


[TestFixture]
    public class Tests
    {
        [Test]
        public async Task Test()
        {
            var target = new Some();
            var worker = Substitute.For<IWorker>();

            await target.ProcessAsync(worker);

            worker.Received(1).Confirm();
        }
    }

    public interface IWorker
    {
        void Confirm();
    }

    public class Some
    {
        public async Task<bool> ProcessAsync(IWorker worker)
        {
            await Tubo();
            worker.Confirm();
            return true;
        }
        async ValueTask<bool> Tubo()
        {
            return true;
        }
    }
Thanks for sharing this with the repo. It looks like NCrunch hasn't been considering implicit Nuget package includes inside its runtime resolution logic (this seems to be a new thing as of VS2017.15.8).

Would you like to try the build below to see if this solves the problem for you?

NCrunch_Console_3.19.0.3.msi
NCrunch_Console_3.19.0.3.zip
NCrunch_GridNodeServer_3.19.0.3.msi
NCrunch_GridNodeServer_3.19.0.3.zip
NCrunch_LicenseServer_3.19.0.3.zip
NCrunch_VS2008_3.19.0.3.msi
NCrunch_VS2010_3.19.0.3.msi
NCrunch_VS2010_3.19.0.3.zip
NCrunch_VS2012_3.19.0.3.msi
NCrunch_VS2012_3.19.0.3.zip
NCrunch_VS2013_3.19.0.3.msi
NCrunch_VS2013_3.19.0.3.zip
NCrunch_VS2015_3.19.0.3.msi
NCrunch_VS2015_3.19.0.3.msi.7z
NCrunch_VS2015_3.19.0.3.zip
NCrunch_VS2017_3.19.0.3.msi
NCrunch_VS2017_3.19.0.3.msi.7z
NCrunch_VS2017_3.19.0.3.zip
Yep, this version seems to fix it.

Post a reply

Log in to reply.