Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

netcoreapp3.1 appears to reference C# 7.3 and not 8 as documented

I've updated an existing asp.net mvc app from netcoreapp3.0 to netcoreapp3.1, along with all referenced packages. The project settings have the target framework and my PC has the SDK installed

<TargetFramework>netcoreapp3.1</TargetFramework>

I have an error in a place where I use the C# coaslescing assignment feature ??= This was working without issue before updating. @SebastianHofmann has kindly confirmed other C#8 features do not work either.

Error   CS8370  Feature 'coalescing assignment' is not available in C# 7.3.
 Please use language version 8.0 or greater.    

According to MSFT netcoreapp3.1 should be using C#8 and indeed must enter image description here

The advance project settings I just saw has been disabled within Visual Studio 2019 (16.3.10) enter image description here

I can toggle back to 3.0 and it compiles again

like image 245
dove Avatar asked Dec 04 '19 12:12

dove


1 Answers

I've added ??= to an existing Core 3 project and had no errors, then updated VS with latest patch (V 4.7.03062) to get 3.1, then upgraded the project to 3.1 also with no error. the only way I could get your error was down grading the project to 2.1. Is it worth running a repair / update on your VS.

like image 107
David Hinchliffe Avatar answered Oct 10 '22 03:10

David Hinchliffe