CSharpFunctionalExtensions icon indicating copy to clipboard operation
CSharpFunctionalExtensions copied to clipboard

Extension resolution

Open FrancoisM opened this issue 7 years ago • 0 comments

This works:

private IObservable<Unit> MyMethod() => MyApi
            .DoSomething()
            .Select(result => ResultExtensions
                .OnSuccess(result, () => { _myVariable = result.Value; })
                .OnSuccess(() => NavigationService.GoBack())
                .OnFailure(async error => await NavigationService.DisplayAlert(error))
                .OnBoth(_ => Unit.Default));

this doesn't:

private IObservable<Unit> MyMethod() => MyApi
            .DoSomething()
            .Select(result => result
                .OnSuccess(() => { _myVariable = result.Value; })
                .OnSuccess(() => NavigationService.GoBack())
                .OnFailure(async error => await NavigationService.DisplayAlert(error))
                .OnBoth(_ => Unit.Default));

On the one that fails, R# complains that the first OnSuccess is missing a return statement; Note that even on the first version I have to add ugly braces otherwise it thinks my Action is a Func.

FrancoisM avatar Aug 03 '18 09:08 FrancoisM