public ProcessResult Finished()

in TeamCity.CSharpInteractive/ProcessMonitor.cs [49:87]


    public ProcessResult Finished(IStartInfo startInfo, long elapsedMilliseconds, ProcessState state, int? exitCode = default, Exception? error = default) => 
        new(
            startInfo,
            _processId,
            state,
            elapsedMilliseconds,
            GetFooter(startInfo,exitCode, elapsedMilliseconds, state).ToArray(),
            exitCode,
            error);

    private IEnumerable<Text> GetFooter(IStartInfo startInfo, int? exitCode, long elapsedMilliseconds, ProcessState? state)
    {
        string? stateText;
        // ReSharper disable once SwitchStatementHandlesSomeKnownEnumValuesWithDefault
        switch (state)
        {
            case ProcessState.Failed:
                stateText = exitCode.HasValue ? "failed" : "failed to start";
                break;

            case ProcessState.Canceled:
                stateText = "canceled";
                break;

            default:
                stateText = "finished";
                break;
        }

        yield return new Text($"{startInfo.GetDescription(_processId)} process ", Color.Highlighted);
        yield return new Text(stateText, Color.Highlighted);
        yield return new Text($" (in {elapsedMilliseconds} ms)");
        if (exitCode.HasValue)
        {
            yield return new Text($" with exit code {exitCode}");
        }

        yield return new Text(".");
    }