-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Harden Option<T>
by disallowing null value
#6426
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -5122,10 +5122,12 @@ namespace Akka.Util | |||
public struct Option<T> | |||
{ | |||
public static readonly Akka.Util.Option<T> None; | |||
[System.ObsoleteAttribute("Use Option<T>.Create() instead")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -50,7 +58,7 @@ public Option(T value) | |||
/// </summary> | |||
/// <param name="value">The object to convert</param> | |||
/// <returns>The result of the conversion.</returns> | |||
public static implicit operator Option<T>(T value) => new Option<T>(value); | |||
public static implicit operator Option<T>(T value) => Create(value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should enable nullable
in the future for this project - there's ways to do it in increments.
Fixes #4604
Hardens Option
Changes
Option<T>
constructor throw anArgumentNullException
when null value is passed inCreate
static method that returns aNone
when null is passed in