AdamsLair / duality

a 2D Game Development Framework
https://adamslair.github.io/duality
MIT License
1.41k stars 290 forks source link

Switch to C# 7.3 #698

Closed Barsonax closed 5 years ago

Barsonax commented 5 years ago

Summary

Currently duality uses C# 4.0. This means we are missing the newer features that C#7.3 brings. Consider upgrading to a newer C# version.

Analysis

Barsonax commented 5 years ago

C# 8.0 among other features will bring nullable references. This is a opt in feature as the new syntax is a breaking change. It is backwards compatible once compiled though. You do need Visual studio 2019 which is currently still in preview.

Even if nullable references are not directly beneficial to duality it is to users that use duality as they can see when returns/parameters etc can be null or not. This will help users write more robust code because null reference exceptions will now be pointed out to them at compile time (warning by default but can be turned to errors).

It might be worth looking into once C# 8.0 is stable.

ilexp commented 5 years ago

Alright, let's get things started. Is there a feature-by-feature list of changes to C# by language version, as well as minimum required VS toolchain and its release date? If not, can we compile one as a basis for deciding which version to upgrade to?

Barsonax commented 5 years ago

From what I know: VS2015 C#6

VS2017 C#7

VS2019 C#8

Since you need C#8 for nullable references I say we go for C#8. VS2019 is out already and it's stable (and ALOT faster I have to say).

Appveyor has a VS2019 image so the CI part should work: image

Jup this does mean that ppl with VS2015 or VS2017 that want to work on the source of duality are out of luck but I don't believe this is a big problem as you can simply install multiple VS versions on one machine nowadays.

EDIT: enriched the list with some info about the language features

Barsonax commented 5 years ago

As a first step I say we just switch all projects to C# 8.0 and get appveyor working with it. After that we can start working on actually using the new features and changing the coding style where needed.

ilexp commented 5 years ago

Not new info, but for the record, as I didn't see it mentioned here: We can't upgrade to C# 8.0 yet, as VS 2019 doesn't support building PCL libraries by default and the AppVeyor 2019 image doesn't have the .NET Portable Library Targeting Pack.

So we can either do the switch to .NET Standard first (#573), or just upgrade to C# 7.3. I've created a new discussion on the AppVeyor support in the mean time.

I'll pick this up to upgrade to C# 7.3 and .NET 4.7.2.

ilexp commented 5 years ago

Progress

ToDo

Barsonax commented 5 years ago

Updated all Duality projects to use C# 7.3.

600 is now no longer blocked

ilexp commented 5 years ago

So we can either do the switch to .NET Standard first (#573), or just upgrade to C# 7.3. I've created a new discussion on the AppVeyor support in the mean time.

Discussion was moved to GitHub for further updates. See here: https://github.com/appveyor/ci/issues/3041

ilexp commented 5 years ago

According to this thread, C# 8.0 will only be available on .NET Core 3.0 and .NET Standard 2.1, but not on .NET Framework. That means further work on this is blocked until we eventually switched to .NET Core, which probably happens separately, after the anticipated .NET Standard switch.

ilexp commented 5 years ago

Because this will probably remain blocked for a bit and we've already done the upgrade to C# 7.3, I've made a new issue for C# 8.0 in #738. Closing this.