C#: Extension Methods not accessible with aliased using directive

The following code compiles:

using Microsoft.SharePoint.Client

class Dummy()
{
    void DummyFunction(ClientContext ctx, ListCollection lists)
    {
        Context.Load(lists, lc => lc.Include(l => l.DefaultViewUrl);
    }
}

However, when switching to an aliased using, there is a problem with the Include function, which is an extension method:

using SP = Microsoft.SharePoint.Client

class DummyAliased()
{
    void DummyFunction(SP.ClientContext ctx, SP.ListCollection lists)
    {
        /* Does not compile: */
        Context.Load(lists, lc => lc.Include(l => l.DefaultViewUrl);
        /* Compiles (not using function as generic) */
        Context.Load(lists, lc => SP.ClientObjectQueryableExtension.Include(lc, l => l.DefaultViewUrl));
    }
}

The Include function can still be used, but not as an extension method. Is there any way to use it as an extension method without un-aliasing the using directive?

Jon Skeet
people
quotationmark

Not before C# 6... but in C# 6 you can use:

using static Microsoft.SharePoint.Client.ClientObjectQueryableExtension;

using SP = Microsoft.SharePoint.Client;

The first of these will pull in just the static members of ClientObjectQueryableExtension available, without anything to do with the rest of the namespace.

people

See more on this question at Stackoverflow