-
-
Notifications
You must be signed in to change notification settings - Fork 231
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
Process member/method chains within method arguments when using np
#444
Comments
@JonathanMagnan I can take a look here. |
Hello @zspitz. Actually, I think we already support this, you just have to use Like: np(FooValue.Two(
np(FooValue.Zero().Length),
np(FooValue.One(42).Length)
).Length) This should just work. And this also makes more sense, because you can also provide a default value. Like: np(FooValue.Two(
np(FooValue.Zero().Length, 77), // in case np resolves to null use value 77
np(FooValue.One(42).Length, 88) // in case np resolves to null use value 88
).Length) |
(I apologize; I can't reply at length ATM.) I think having this limitation on But in any case, it needs to be documented. |
Technically I think it's possible to support code like: np(FooValue.Two(FooValue.Zero().Length, FooValue.One(42).Length).Length) However this would mean that when using np ,all arguments will be treated as np, which could lead to some undesired functionality from the 'main' np method. So to my opinion, these options are possible:
|
Could you elaborate on this:
What undesired functionality do you anticipate? |
(Creating a new issure, at @StefH 's request.)
With #443, the result of method calls within a member chain when using
np
:are also null-checked, and the resultant expression looks like this:
or the C# equivalent:
whether the method has zero, one, or more arguments.
However, if there are member/method chains within the arguments to the method:
I would expect the same treatment:
(Note that
42
doesn't need to be checked fornull
, either because it's type (presumablyint
) cannot take null, or because it's not a member access or a method call.The text was updated successfully, but these errors were encountered: