Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
<Project Sdk="Microsoft.NET.Sdk">
<!-- for Visual Studio 16.2.x Preview -->
<!-- for Visual Studio 2019, .NET Core SDK 3.0 Preview -->
using System;
using System.Linq;
namespace ConsoleApp1
class Program
static bool X(Func<int, bool> predicate) => predicate(default);
static void Main(string[] args)
X("abc".GenericExtensionMethod); // CS8622
X(new Program().GenericExtensionMethod); // CS8622
X(new object().GenericExtensionMethod); // No error
X(Enumerable.Empty<int>().GenericExtensionMethod); // CS8622
X(Enumerable.Empty<int>().Contains); // CS8622
public static class Extension
public static bool GenericExtensionMethod<T>(this T instance, int value) => true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.