Responsible icon indicating copy to clipboard operation
Responsible copied to clipboard

Enable nullable reference types

Open sbergen opened this issue 2 years ago • 1 comments

It would be nice to enable nullable reference types, especially since most of the internals of Responsible use very few nullable values. However, there are some technical issues and non-trivial changes to solve.

Technical issues:

  • Unity doesn't have an official way to enable nullability in a package, so we'd need to put #nullable enable everywhere.
  • Unity 2019 doesn't support C# 8, so support would need to be dropped
  • Unity 2020 doesn't support C# 9, which might make generics handling a bit more complicated, but this might not be an issue.
  • The NUnit FixtureLifeCycleAttribute is not available in any Unity Test Framework version released to date (2.0.1-pre18), which means that everything assigned in a SetUp or OneTimeSetUp test would need to be initialized with = null!.

Non-trivial changes:

  • IOptionalTestResponder currently uses "type erasure" using object and instruction boxing internally. It's not immediately clear to me how this should be handled if some instructions use nullable types as the responder results.
  • BoxResult shares some internal code with optional responders, making things a bit more complicated. It might make sense to just separate the public functionality from the internal functionality, once/while we solve what to do with optional responders.

sbergen avatar May 01 '22 16:05 sbergen

Update on technical issues:

  • Adding -nullable:enable to csc.rsp works for enabling NRT in an assembly in Unity
  • We no longer support Unity 2019 or 2020
  • Still no FixtureLifeCycleAttribute

No updates for the non-trivial changes.

sbergen avatar Jul 07 '23 19:07 sbergen