Skip to content

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

Closed
@elem-74

Description

@elem-74

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions