vkhorikov / CSharpFunctionalExtensions

Functional extensions for C#

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Breaking Change in Maybe<T> implicit operator.

wainwrightmark opened this issue · comments

The 2.31 release has changed the behaviour of the Maybe<T> implicit operator.
Now if the default value (e.g. false for a bool, 0 for an int) of T is given it will be converted to Maybe.None instead of Maybe.From(value)

This is unexpected and I think the change should be reverted.

using CSharpFunctionalExtensions;

namespace TestProject1;

[TestClass]
public class UnitTest1
{
    [TestMethod]
    public void TestMethod1()//This test passes on 2.30
    {
        Maybe<bool> b = false; //Use implicit operator

        Assert.IsTrue(b.HasValue); //Fails here on 2.31
        Assert.IsFalse(b.Value);
    }
}

Indeed, looks like a regression. Thanks much, will publish the fix as v2.31.1 shortly.