-
Notifications
You must be signed in to change notification settings - Fork 131
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
Add OptionalNullable<T>
?
#6308
Comments
Better approach: add |
Do we know of any Azure services which send |
Here is what I am thinking about: #6322. If we find out that we need this, we can implement it as in that PR, and it should be a change that is easy to make and not break anyone. |
Knowing that we can do that is probably good enough to close this work item. So, if we find out that we need this, we'll implement it as in that PR and will update the codegen. |
Oh, that's rather clever. I like it. And it's good to have this in our back pocket. |
Non-nullable optionals should be
Nullable<>
- to distinguish between "not set" vs""
(strings) /0
(ints),[]
(arrays).That distinction allows customer to express any value, without sacrificing anything. When
!HasValue()
, we don't send the value.With non-optional nullables, everything is also
Nullable<>
, the only difference is that when nullable has no value, we serialize it asnull
(at least, in JSON body context; I don't remember exactly how paths/query params/headers behave - that's ok, that's beyond the point).And finally, if there is an optional nullable, then we have two options:
Nullable<T>
, "not set" = do not send, "has value" = send value. This won't allow users to sendnull
values, but maybe it is practical enough.Nullable<T>
, "not set" = sendnull
-- I don't think it is the right approach to optionals.Nullable<Nullable<T>>
,options.Property.HasValue() == false
= do not send,options.Property.HasValue() == true && options.Property.Value().HasValue() == false
= sendnull
;options.Property.HasValue() == true && options.Property.Value().HasValue() == true
= sendoptions.Value().Value()
. This would be an implementation that allows to accurately represent any value, but it is most likely too complex to be used by humans. I think we should implement option 1, and if we ever encounter a need for the service to distinguish betweennull
and lack of value sent in this case, we work with the service team, or we should put some other solution (i.e. something like item 4 below).OptionalNullable<T>
, which has methods for bothHasNonNullValue()
andIsNull()
(and does not haveHasValue()
to avoid confusion withNulable<T>
). To set null values, we addoperator=(std::nullptr_t)
/OptionalNullable<T>(std::nullptr_t)
.The text was updated successfully, but these errors were encountered: