You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
<!-- 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]>
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 inExpression<Func<TViewModel, TProp?>>
and inFunc<TProp?, TOut>
) because everyTProp
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, ifTProp
is detected asclass?
,TProp
will actually be nullable, and ifTProp
is detected asclass
, 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 🖼️
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.
The text was updated successfully, but these errors were encountered: