dotnet / wpf

WPF is a .NET Core UI framework for building Windows desktop applications.
MIT License
6.93k stars 1.15k forks source link

IValueConverter does not support nullable contexts #9301

Open vsfeedback opened 3 weeks ago

vsfeedback commented 3 weeks ago

This issue has been moved from a ticket on Developer Community.


System.Windows.Data.IValueConverter is also available in nullable contexts.

interface IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture); public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture): }

However, the value and parameter arguments across the Convert(), ConvertVack() functions can be NULL, and the return value can also be NULL.

interface IValueConverter { public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture); public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture): }

It must be.


Original Comments

Feedback Bot on 10/8/2023, 06:47 AM:

(private comment, text removed)

Feedback Bot on 2/5/2024, 00:15 PM:

(private comment, text removed)


Original Solutions

(no solutions)

miloush commented 3 weeks ago

It is not clear to me what is author asking for.

    public class C : IValueConverter
    {
        public object? Convert(object? value, Type? targetType, object? parameter, CultureInfo? culture)
        {
            throw new NotImplementedException();
        }

        public object? ConvertBack(object? value, Type? targetType, object? parameter, CultureInfo? culture)
        {
            throw new NotImplementedException();
        }
    }

compiles just fine. If this is about nullable annotations, then it's duplicate of #7563