Skip to content
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

Merged
merged 7 commits into from
Dec 22, 2023
Merged

feat: [MVUX] Improve nullable support #2080

merged 7 commits into from
Dec 22, 2023

Conversation

dr1rrb
Copy link
Member

@dr1rrb dr1rrb commented Nov 29, 2023

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?

  • Most common factory methods (<Feed|State>.Async[Enumerable]) are now constrained with T : notnull
  • Select and SelectAsync operators are also constrained with TResult : notnull
  • When user returns a T with the T : struct constraint, we allowed him to return a T? which is interpreted as None
  • In any time, when user provide a T that is ref type and null, it's interpreted as None (e.g. Feed<MyObject>.Async(async _ => null!) will now goes in None).
  • SelectData and SelectDataAsync operators has been added to allow user to still use Some(null) if needed.

PR Checklist

  • Tested code with current supported SDKs
  • Docs have been added/updated which fit documentation template. (for bug fixes / features)
  • Unit Tests and/or UI Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Wasm UI Tests are not showing unexpected any differences. Validate PR Screenshots Compare Test Run results.
  • Contains NO breaking changes
  • Updated the Release Notes
  • Associated with an issue (GitHub or internal)

Other 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. use Feed**<MyObject?>**.Async(async _ => default(MyObject)). Same for Feed.AsyncEnumerable, State.Async and State.AsyncEnumerable
  • myFeed.Select(_ => default(MyObject)) is no longer allowed, to fix you need to use the SelectData operator. Same for SelectAsync where you need use SelectDataAsync.

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 as None". 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 accepts Option<T> instead of T.

@dr1rrb dr1rrb enabled auto-merge November 29, 2023 20:57
@dr1rrb dr1rrb disabled auto-merge November 29, 2023 21:13
@dr1rrb dr1rrb force-pushed the dev/dr/nullable2 branch 2 times, most recently from 7113cc1 to c6ffb89 Compare November 30, 2023 13:05
@dr1rrb
Copy link
Member Author

dr1rrb commented Nov 30, 2023

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@dr1rrb dr1rrb enabled auto-merge November 30, 2023 22:59
@dr1rrb dr1rrb changed the title feat: Improve nullable support feat: [MVUX] Improve nullable support Nov 30, 2023
@nickrandolph
Copy link
Contributor

@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?

@dr1rrb
Copy link
Member Author

dr1rrb commented Dec 1, 2023

@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 ...

@unoplatform unoplatform deleted a comment from azure-pipelines bot Dec 4, 2023
@dr1rrb dr1rrb disabled auto-merge December 22, 2023 14:24
@dr1rrb dr1rrb merged commit f14f671 into main Dec 22, 2023
13 of 14 checks passed
@dr1rrb dr1rrb deleted the dev/dr/nullable2 branch December 22, 2023 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[MVUX] Better support for nullability annotations
2 participants