Skip to content
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

Using C# 8.0 #1335

Closed
marcovisserFurore opened this issue Apr 20, 2020 · 3 comments · Fixed by #1372, #1371 or #1383
Closed

Using C# 8.0 #1335

marcovisserFurore opened this issue Apr 20, 2020 · 3 comments · Fixed by #1372, #1371 or #1383

Comments

@marcovisserFurore
Copy link
Member

According to the documentation only netstandard2.1 is supporting C# 8.0 (https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/configure-language-version).

So we should also upgrade to netstandard2.1 (we are now supporting netstandard2.0). We have to check if that does not cause too much problems.

@ewoutkramer
Copy link
Member

It looks like netstandard 2.1 is supported as well. We can avoid using the features that require the CLR changes - the most interesting bit is the new attributes that support nullable reference types:

Nullable reference types make use of several attributes to provide better warnings. Those attributes were added in .NET Core 3.0. Other target frameworks haven't been annotated with any of these attributes. That means nullable warnings may not accurately reflect potential issues.

Might mean we can only trust the output of the netstandard 2.1 warnings, not of the others. But I have not noticed these differences yet (did a small pilot a few weeks ago).

@ewoutkramer
Copy link
Member

Very good summary with pointers to even more details: https://stackoverflow.com/questions/56651472/does-c-sharp-8-support-the-net-framework (look for Stephen Kennedy's answer).

In short:

C# 8 will be fully supported on .net core 3.0 and .net standard 2.1 only. If you manually edit the project file to use C# 8 with .net core 2.1, you are in unsupported territory. Some C# 8 features will happen to work well, some C# 8 features will work not too well (e.g. poor performance), some C# 8 features will work with extra hacks, and some C# 8 features will not work at all. Very complex to explain. We do not actively block it so the expert users who can navigate through it can do so. I would not recommend this unsupported mix&match to be used broadly.

(Jan Kotas)

People like you who are willing understand -- and work around them -- are free to use C# 8. The point is, not all language features will work on down-level targets.

(Immo Landwerth)

@ewoutkramer
Copy link
Member

ewoutkramer commented Apr 20, 2020

Specifically about nullable references: dotnet/runtime#30493

And this shows the differences in support from the platforms clearly: https://www.meziantou.net/how-to-use-nullable-reference-types-in-dotnet-standard-2-0-and-dotnet-.htm.

(and even more details: https://devblogs.microsoft.com/dotnet/try-out-nullable-reference-types)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment