protected async Task EvaluateUpToAsync(int to)
        {
            if (_store.ValidationError != null || _hasEvaluationError)
            {
                return;
            }

            try
            {
                await InitContextAsync();

                while (_lastIndex < to && _blocks.State != BlockState.Done)
                {
                    EvaluateResult result = await _blocks.EvaluateAsync();

                    if (result.Type == ResultType.Var)
                    {
                        _store.SaveVariable(_lastIndex, result.Data);
                        _lastIndex++;
                    }
                }
            }
            catch (ExpressionEvaluationFailed ex)
            {
                ErrorVariableInformation error =
                    NatvisErrorUtils.LogAndGetExpandChildrenValidationError(
                        Optional ? NatvisLoggingLevel.WARNING : NatvisLoggingLevel.ERROR, _logger,
                        VisualizerName, _variable?.TypeName, ex.Message);

                _hasEvaluationError = true;

                if (_lastIndex != 0 || !Optional)
                {
                    _store.SaveVariable(_lastIndex, error);
                    _lastIndex++;
                }
            }
        }
Beispiel #2
0
        public async Task <EvaluateResult> EvaluateAsync()
        {
            if (_position >= _blocks.Count)
            {
                State = BlockState.Done;
                return(EvaluateResult.None());
            }

            State = BlockState.InProgress;

            ICodeBlock     currentBlock = _blocks[_position];
            EvaluateResult result       = await currentBlock.EvaluateAsync();

            if (result.Type == ResultType.Break)
            {
                State = BlockState.Done;
            }
            else if (currentBlock.State == BlockState.Done)
            {
                _position++;
            }

            return(result);
        }