Last active
May 23, 2019 12:12
-
-
Save acple/394b5be3609f80cfa03d9d95f7f087c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<OutputType>Exe</OutputType> | |
<TargetFramework>netcoreapp2.2</TargetFramework> | |
<LangVersion>8.0</LangVersion> | |
<!-- for Visual Studio 16.2.x Preview --> | |
<Nullable>enable</Nullable> | |
<!-- for Visual Studio 2019, .NET Core SDK 3.0 Preview --> | |
<NullableContextOptions>enable</NullableContextOptions> | |
</PropertyGroup> | |
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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