Skip to content

Change IRemoteServiceInvoker.TryInvokeAsync(...) to all callers to handle failures gracefully #11431

@DustinCampbell

Description

@DustinCampbell

Currently, the IRemoteServiceInvoker is defined like so:

internal interface IRemoteServiceInvoker
{
    ValueTask<TResult?> TryInvokeAsync<TService, TResult>(
        Solution solution,
        Func<TService, RazorPinnedSolutionInfoWrapper, CancellationToken, ValueTask<TResult>> invocation,
        CancellationToken cancellationToken,
        [CallerFilePath] string? callerFilePath = null,
        [CallerMemberName] string? callerMemberName = null)
        where TService : class;
}

By returning TResult?, it's impossible for a caller to tell the difference between null as a valid result and null because the remote service call failed. This issue tracks changing this method to return Optional<TResult> and updating callers to handle the result gracefully.

Alternatively, the implementation of IRemoteServiceInvoker could be changed to throw on failures rather than returning default.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions