Skip to content

Optional<T> API do-over

Mateusz Brawański requested to merge github/fork/uwx/patch-109 into master

Created by: uwx

Summary

I never noticed that the Optional<T> APIs were all public, which has now made me a bit ashamed of adding to it without writing documentation. So I decided to clean up minor things and just make it more betterer.

Details

I documented all of the public-facing APIs for Optional and extracted the FromValue/FromNoValue methods into a static class so that the type parameters could be inferred by the compiler ... some of the time. That last part is what turned this PR so huge.

The changes to outside Optional.cs were all made by a robot.

All in all, after looking through all the processed code, I'm not 100% sure if I like the new pattern or not, so I'll leave that for you to decide.

Changes proposed

  • Document Optional<T>.IfPresent
  • Squish (technical term) Optional<T>.Equals
  • Squish Optional<T>.Value
  • Make Optional<T>._val read-only (it should have been from the start)
  • Move Optional<T>.FromValue and FromNoValue to separate static utility classes that use the type parameters in the method signature rather than the class signature, allowing for type inference when the compiler decides it
    • This required changes to every class that used it

Notes

I will actually get to fixing bugs in the lib and doing other important things ... in the near future. PS am tired and started writing this PR 5 hours ago but will actually test things now if I still got time (probably not) or tomorrow

Merge request reports

Loading