Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.
This repository was archived by the owner on May 1, 2024. It is now read-only.

[Bug] Allow handling of null for Convert of BaseConverterOneWay<TFrom, TTo> #1705

@bijington

Description

@bijington

In order to match a bug fixing coming to the MAUI Toolkit we should aim to solve it here also. The issue in question is:
CommunityToolkit/Maui#184

Description

Currently it is not possible to pass in a null value to the BaseConverterOneWay<TFrom, TTo> converter or any implementations of it due to checks within the base class.

Most important details from the discussion/issue:

  • The TargetNullValue of XAML's Converter for bindings is applied to the result of the converter and not to the value before it goes in to the converter.
  • Let the BaseConverterOneWay<TFrom, TTo> check for null and fallback to the default value for TFrom instead of throwing an Exception. (Suggested by @pictos )
  • If we went with a blanket always replace nulls with default then that is a behavioral change but is still probably unlikely to have a big impact. If we added a way to opt-in as @Countryen suggested then it would have even less of an impact.

  • This would then mean that the actual custom converter's ConvertFrom(TFrom value) is called with default(TFrom) when value is null. We could then add a null check to return something the view can use.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working. Breaky break.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions