Starting with Visual Studio 2019 Preview 4 and RC, we’ll be adjusting how C# versions are treated in .NET tooling. Read more below <cut>.
Firstly, we’re adding two new Language Version (LangVersion) values: LatestMajor and Preview. Here’s how they stack up with the currently supported list of values:
|LatestMajor||Latest supported major C# language version|
|Preview||Latest available preview C# language version|
|Latest||Latest supported C# language version (including minor version)|
When no LangVersion is specified, the default meaning is now determined by the target framework of your project. When you target a preview framework that also has a corresponding preview C# version, that preview version is the default. If you do not target a preview framework, then Latest is chosen.
The following scenarios explain how the default C# version will be interpreted while C# 8.0 is still in preview.
The default language version chosen in this scenario is Preview. The C# 8.0 features you have access to are based entirely on the version of the compiler (and thus the .NET SDK) that you are using. As you use future previews, you may get more (or slightly tweaked) features. When you build a project, the .NET SDK will emit a warning that this is all still in preview.
The default language version chosen in this scenario is Latest. Any use of a C# 8.0 feature is a compile error. Visual Studio tooling will prompt you with a quick fix that can change the language version for the project or solution when one of these errors is encountered. Because some features require underlying types or runtime features that are not available on .NET Framework, such as Default Interface Members, you may still get an error for those features when targeting .NET Framework.
For the netcoreapp3.0/netstandard2.1 preview targets, the language version is Preview. A warning is emitted on build from the .NET SDK. For the .NET Framework target, the language version is Latest.
If you explicitly set a LangVersion value, that will be respected and the previously mentioned default behavior is ignored.
Eventually, C# 8.0 and .NET Core 3.0 will ship in a GA-quality release. Here’s what the relevant LangVersion values will map to at that time:
|Preview||Not yet determined|
Projects that do not specify a LangVersion will be treated as if they are Latest when C# 8.0 is GA.
If you created a project for C# 8.0 preview targeting .NET Core 3.0 preview or .NET Standard 2.1 preview, and also did not specify a LangVersion, it will be as if Latest is chosen. You will not be opted into Preview under any scenario once C# 8.0 and .NET Core 3.0 are GA.
At the time of writing, there is no plan for a preview of C# when C# 8.0 is GA. Eventually, a preview will ship and we’ll have a blog post explaining it.
Up until this point, the default C# version used in Visual Studio was equivalent to LatestMajor. This has been problematic for two reasons:
More generally, as we evolve C# and continue to release more features that align with a future .NET Core version, we want to make sure that you can use these features as seamlessly as possible. This also allows you to use features earlier in their development lifecycle, increasing the window of time that actionable feedback on a feature could influence its design.
The way to think about support is also a bit different. To allow the use of C# 8.0 preview features within a released Visual Studio 2019, support and compatibility concerns are distinguished by preview vs. released features:
In short, if you use C# 8.0 preview in Visual Studio 2019, some features and behavior may change between now and when C# 8.0 fully releases.
Вы можете помочь и перевести немного средств на развитие сайта