osu-framework icon indicating copy to clipboard operation
osu-framework copied to clipboard

Future works for modernizing the codebase

Open huoyaoyuan opened this issue 4 years ago • 0 comments

Language

C# 8

  • [x] Update to all pre-C# 8 features
  • [ ] Update for smallish features in C# 8
    • Let IDE help for this
  • [ ] Use switch expressions
    • Do this manually because IDE think many usages are not identical to convert. Most are missing throw guard for unreachable paths.
  • [x] Use nullable reference types
    • Do this in framework first then game can consume it.
    • At 3.0 time frame, only System.Private.CoreLib get annotated. The promised time for other corefx components is 5.0 (November 2020) (Can't find a textual source, I should heard about it when watching .NET Conf). See https://github.com/dotnet/corefx/issues/40623 for their working progress. Since we don't need to avoid breaking changes strictly like Microsoft products, it's ok to start now. Actually it's been started partially using JetBrains' annotations.
    • Updating target framework required. Although the nullable attributes (e.g. [MaybeNull], [NotNullWhen(true)]) can be defined manually, to consume annotations from corefx still requires targeting .NET Core 3.0+. The official recommended target for 3.x timeframe would be <TargetFrameworks>netcoreapp3.0;netstandard2.1</TargetFrameworks>.

C# Next

You can watch https://github.com/dotnet/csharplang/projects/4 to prepare for what's coming in the language. I'm pointing out the most useful proposals.

  • [x] Records
    • Helps a lot to get rid of keeping data structures with latest guideline.
  • [ ] Simplified parameter null check
    • Should come with an IDE quick fix, but may be not aware for all the variances of null checking. Search all references for ArgumentNullException should help.
  • [ ] Enhanced common type, target type, type inference scenarios
    • IDE should report for redundant cast/type specification then. Nothing special to prepare.
  • [ ] More effective interpolated strings and params Span<T>
    • Potential performance improvement. Requires to manually change the api shape.
  • [ ] Enhanced switch expressions (void-returning, comparison or complex patterns)
    • It's helpful to keep in mind when writing new code
  • [ ] Type class or other higher-kinded FP concepts
    • A very high level topic. The straightforward use cases are general operation for numbers, and more comfortable equating and comparing.

Frameworks

  • [x] .NET Standard 2.1
    • Requires updating Xamarin targets, and mobile OS requirement may be updated then. See https://github.com/dotnet/standard/blob/master/docs/versions.md .
    • .NET Framework will get dropped forever. Unless there's .NET Core runtime shipped with Windows Update, some convenience will get lost.
  • [x] .NET Core 3.1
    • LTS release, including better installation experience. Should be very easy to move to. Mostly at consumer side.
  • [x] .NET 5
    • Announced to unify every dialects of .NET. There may be some portion for Xamarin then, but after that we will have less gap in tooling. Current tools make many assumptions for .NET Core SDK, and have many issues with Xamarin projects.
  • [ ] Use .NET Core-ish native handling on desktop
    • At 3.0 time frame, I've seen you dropped .NET Framework/Mono and use .NET Core for building desktop. Let's make things Core-ish.

Static analysis

Roslyn is going to create a standard for code analysis. The analyzers can get the same view of code with compiler now. ReSharper and other tools parsing themselves do make more errors.

  • [ ] Wait for official build-integrated version of IDE built-in analysis to release.
    • Roslyn itself is consuming a preview package Microsoft.CodeAnalysis.CodeStyle.
  • [x] Configure things via editorconfig
  • [ ] Use FxCop
    • Many old rules in FxCop are problematic, but new rules are generally useful.
    • Legacy project system (UWP, Xamarin) has problem to configure analyzers now.

huoyaoyuan avatar Oct 24 '19 09:10 huoyaoyuan