private async Task RequestCompilationAsync()

in src/dotnet/ReSharperPlugin.DotNetDisassembler/AsmViewerHost.cs [167:212]


    private async Task RequestCompilationAsync(SequentialLifetimes compilationLifetimes)
    {
        var configuration = _model.Configuration.Maybe;
        if (!configuration.HasValue)
        {
            _logger.Verbose("Configuration not initialized, skipping");
            return;
        }

        var textControl = _currentTextControl;
        if (textControl == null || !textControl.Lifetime.IsAlive)
        {
            _logger.Verbose("No text control or text control is no longer alive, clearing UI");
            _model.SendResult(new CompilationResult(null, new ErrorInfo(ErrorCode.SourceFileNotFound, null)));
            return;
        }

        var compilationLifetime = compilationLifetimes.Next();
        _logger.Info("Starting compilation");

        var result = await _updateCoordinator.CompileAsync(textControl, configuration.Value, compilationLifetime);

        if (!compilationLifetime.IsAlive || result.FailValue is { Code: AsmViewerErrorCode.UpdateCancelled })
        {
            _logger.Verbose("Compilation cancelled");
            return;
        }

        if (!textControl.Lifetime.IsAlive)
        {
            _logger.Verbose("Text control closed during compilation, discarding result");
            return;
        }

        if (!result.Succeed)
        {
            _logger.Warn("Compilation failed: {0} - {1}", result.FailValue.Code, result.FailValue.Details);
            _usageCollector.LogError(result.FailValue.Code);
            _model.SendResult(new CompilationResult(null, new ErrorInfo(result.FailValue.Code.ToRdErrorCode(), result.FailValue.Details)));
            return;
        }

        _logger.Info("Compilation succeeded, result length: {0}", result.Value.Length);
        _usageCollector.LogDisassemblySucceeded();
        _model.SendResult(new CompilationResult(result.Value, null));
    }