SceneGate / Yarhl

Framework for the implementation of format converters like game assets or media files
https://scenegate.github.io/Yarhl/
MIT License
60 stars 10 forks source link

Annotate API reference types for nullable awareness #176

Closed pleonex closed 2 years ago

pleonex commented 2 years ago

Description

Introduced with C# 8.0, we can annotate the code to specify if a reference-type variable can be null or not. Then, we can enable a new static analysis check that check for potential code paths that will de-reference a null pointer, throwing a NullReferenceException. Annotating the API allows user to enable the feature as well and ensure a safe usage of the code. Fix all the related warnings

This is introducing the following breaking changes:

Example

To enable the feature in any user project, just set <Nullable>enable</Nullable> in the csproj.