Skip to content

PropertyBindingMixins.OneWayBind does not show a nullable warning when using a selector #4009

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

Open
elem-74 opened this issue Apr 10, 2025 · 1 comment
Labels

Comments

@elem-74
Copy link
Contributor

elem-74 commented Apr 10, 2025

Describe the bug 🐞

Basically it's the opposite of #2913
When the object you select is actually nullable, there is no warning for dereferencing it without nullcheck.

If I understand correctly, before the fix for issue 2913, TProp was always considered nullable (Both in Expression<Func<TViewModel, TProp?>> and in Func<TProp?, TOut>) because every TProp was nullable annotated, which caused issue 2913.

The fix removed the nullable annotation in the Func, so now TProp is explicitely considered not nullable in the selector, which causes the current behavior.

If we want to fix both issues, TProp should never be nullable annotated. Then, if TProp is detected as class?, TProp will actually be nullable, and if TProp is detected as class, it will be not nullable.

Step to reproduce

See screenshot

Reproduction repository

https://github.com/reactiveui/ReactiveUI

Expected behavior

When the object you select is nullable, there is a warning for dereferencing it without nullcheck. If the object is not nullable, there is no warning.

Screenshots 🖼️

Image

IDE

Rider Windows

Operating system

Windows

Version

11

Device

No response

ReactiveUI Version

20.2.45

Additional information ℹ️

I have a PR available at https://github.com/elem-74/ReactiveUI/tree/fixOneWayBindAnnotations but your contributing guidelines said to open an issue before a PR, so here it is.

@elem-74 elem-74 added the bug label Apr 10, 2025
@glennawatson
Copy link
Contributor

Thanks for respecting the contribution guidelines. Your branch seems to be good would appreciate the PR.

ChrisPulman pushed a commit that referenced this issue Apr 15, 2025
<!-- Please be sure to read the
[Contribute](https://github.com/reactiveui/reactiveui#contribute)
section of the README -->

**What kind of change does this PR introduce?**
Fixes nullable annotations for OneWayBind



**What is the current behavior?**
#4009



**What is the new behavior?**
When the object you select is nullable, there is a warning for
dereferencing it without nullcheck. If the object is not nullable, there
is no warning.



**What might this PR break?**
Not sure, I'm not that familiar with the codebase, but I don't see what
it could break.


**Please check if the PR fulfills these requirements**
- [ ] Tests for the changes have been added (for bug fixes / features)
- [ ] Docs have been added / updated (for bug fixes / features)

**Other information**:
Let me know if I should improve the PR in any way.

Co-authored-by: David Vreony <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants