EnumerableExtensions.Any() overlaps with System.Linq.Enumerable.Any()

Topics: General
May 24, 2012 at 12:23 PM

New extension method EnumerableExtensions.Any() has the same signature as standard extension method System.Linq.Enumerable.Any(). It leads to the build error like this:

The call is ambiguous between the following methods or properties: 'NuGet.EnumerableExtensions.Any<string>(System.Collections.Generic.IEnumerable<string>)' and 'System.Linq.Enumerable.Any<string>(System.Collections.Generic.IEnumerable<string>)'

Steps to reproduce:

1. Add reference to NuGet.Core in your project

2. Try to compile this:

using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;
using NuGet;

namespace TestProject1
{
    [TestClass()]
    public class Class1Test
    {
        [TestMethod()]
        public void TestTest()
        {
            var items = new[] { "foo", "bar" };

            var result = items.Any();

            Assert.IsTrue(result);
        }
    }
}

Developer
May 24, 2012 at 4:17 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.