-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dotnet build error #10180
Comments
I would expect the need for a However, with a 3.0 SDK, I can't seem to get it to error with a @jaredpar is this some subtle behavior difference between the compilers that ship with 2.2 and 3.0? Regardless, this probably belongs as a Roslyn issue, but I'd like to discuss it before moving. |
@cston can confirm but believe this is a deliberate change between C# 7.3 and C# 8.0 (the latter allows the code now). |
@jaredpar I set the language version to 7.0 in vs 2019 and still compiled successfully. |
@Varorbc I noticed that as well and that appears to be a bug. If you actually use a 7.0 compiler though you'll see it doesn't compile. |
Adding @gafter for the compiler change since |
I think the change is deliberate and comes from dotnet/roslyn#25995 ("recursive-patterns(18): Permit a constant pattern to be used with an open type as input") Here's the championed issue: dotnet/csharplang#1284 |
@jcouv Thanks for the info! However, should If the answer is "no", then I think we can close this by design. If the answer is "yes", then we should transfer this to issue to Roslyn (with some changes, since this is expected behavior with a .NET Core 2.2 SDK, but it should be possible to get the error with a |
Ping @jcouv for follow-up question above. |
I checked with @gafter who said this was a new feature (as opposed to a bug fix). That means that |
Moving the issue over to Roslyn repo: dotnet/roslyn#34678 |
Steps to reproduce
1.
2. dotnet build dotnet build ConsoleApp1.csproj error
3.build by VS2019 16.0.0 RC.3 is success
Expected behavior
dotnet build success
Actual behavior
dotnet build error
Program.cs(19,22): error CS0403: 无法将 null 转换为类型参数“T”,因为它可能是不可以为 null 的值类型。请考虑改用“default(T)”
Environment data
dotnet --info
output:.NET Core SDK(反映任何 global.json):
Version: 2.2.105
Commit: 7cecb35
运行时环境:
OS Name: Windows
OS Version: 10.0.17763
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.2.105\
Host (useful for support):
Version: 2.2.3
Commit: 6b8ad509b6
.NET Core SDKs installed:
2.2.105 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
The text was updated successfully, but these errors were encountered: