Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
DustinCampbell opened this issue Jan 31, 2025 · 0 comments

Comments

@DustinCampbell
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants