-
Notifications
You must be signed in to change notification settings - Fork 49
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
feat: [MVUX] Improve nullable support #2080
Conversation
a5fced4
to
80ea0b0
Compare
7113cc1
to
c6ffb89
Compare
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
c6ffb89
to
24c6bb6
Compare
@dr1rrb how are we going to deal with the breaking changes. I assume we need to push to v4 of extensions, to reflect breaking changes? |
I would agree, but usually (unfortunately) the "major" version number is more often a "marketing number" than a "semantic number"... especially since we have released v3 quite recently. We will have to discuss about that ... |
Factories are now auto converting null to None
…and SelectDataAsync
…ereNotNull operator
5e3b838
to
795cdc4
Compare
closes #1605
Feature
Improve nullable support in feed factories and relevant operators
What is the current behavior?
Nullable annotation are not used to interpreted by the feeds. There is no recommendation to use non nullable types in feeds and users are often involuntary using using
Some(null)
while they should use (/ thinking they are using)None
.What is the new behavior?
<Feed|State>.Async[Enumerable]
) are now constrained withT : notnull
Select
andSelectAsync
operators are also constrained withTResult : notnull
T
with theT : struct
constraint, we allowed him to return aT?
which is interpreted asNone
T
that is ref type andnull
, it's interpreted asNone
(e.g.Feed<MyObject>.Async(async _ => null!)
will now goes inNone
).SelectData
andSelectDataAsync
operators has been added to allow user to still useSome(null)
if needed.PR Checklist
Screenshots Compare Test Run
results.Contains NO breaking changesOther information
COMPILATION BREAKING CHANGES
This PR introduces few compilation breaking changes. Here is a shot summary of the known breaking
Feed.Async(async _ => default(MyObject))
is no longer allowed, to fix you need to specify the type of the value of the feed, i.e. useFeed**<MyObject?>**.Async(async _ => default(MyObject))
. Same forFeed.AsyncEnumerable
,State.Async
andState.AsyncEnumerable
myFeed.Select(_ => default(MyObject))
is no longer allowed, to fix you need to use theSelectData
operator. Same forSelectAsync
where you need useSelectDataAsync
.BEHAVIOR BREAKING CHANGES
This PR also introduces few behavior changes that could be breaking in few use case. Those are describe in the issue #1605, and which can be summarized "any time you return a
null
value, it's now automatically converted asNone
". This was already the case for some factories and operators and is expected to cause issue only in really rare use-cases. If you are encountering such an issue, use factories and operators overload that acceptsOption<T>
instead ofT
.