CS 2589 - Boolean expressions should not be gratuitous

The following class produces a FP - SonarCloud detectes that the line

return value is bool castValue && castValue ? TrueValue : FalseValue;

always evaluates to true - Resharper does not have that problem.
It might be related to the fact that the property names have True and False in their name.

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Windows.Data;

namespace Sample
{
    /// <summary>
    /// An <see cref="IValueConverter"/> that compares incoming values with a set of predefined values.
    /// The outcome of <see cref="Convert"/>/<see cref="ConvertBack"/> is based on the quality with <see cref="TrueValue"/>/<see cref="FalseValue"/>
    /// </summary>
    public abstract class GenericEqualityConverter<T> : IValueConverter
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="GenericEqualityConverter{T}"/> class.
        /// </summary>
        protected GenericEqualityConverter(T trueValue, T falseValue)
        {
            TrueValue = trueValue;
            FalseValue = falseValue;
        }

        public T TrueValue { get; set; }
        public T FalseValue { get; set; }

        public virtual object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return value is bool castValue && castValue ? TrueValue : FalseValue;
        }

        public virtual object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return value is T castValue && EqualityComparer<T>.Default.Equals(castValue, TrueValue);
        }
    }
}

Hello @norberth
This FP is fixed with the following issue.
And it is part of the 8.16 release. Which is deployed on sonarcloud.
Could you please confirm it got fixed on your side?

Hi Caba,

Seems to be fixed - I’ll update this if I see the problem again.

Thanks
Norbert