async Task InitAsync() { if (_initialized) { return; } _initialized = true; if (string.IsNullOrWhiteSpace(_smartPointerItem?.Value) || !NatvisViewsUtil.IsViewVisible(_variable.FormatSpecifier, _smartPointerItem.IncludeView, _smartPointerItem.ExcludeView)) { _adapter = _fallbackAdapter; return; } try { IVariableInformation expandInfo = await _evaluator.EvaluateExpressionAsync( _smartPointerItem.Value, _variable, _natvisScope, null); _adapter = expandInfo.GetChildAdapter(); } catch (ExpressionEvaluationFailed ex) { NatvisErrorUtils.LogExpandChildrenValidationError( NatvisLoggingLevel.WARNING, _logger, "<SmartPointer>", _variable.TypeName, ex.Message); _adapter = _fallbackAdapter; } }
public Task <IList <IVariableInformation> > GetChildrenAsync(int from, int count) { ErrorVariableInformation errInfo = NatvisErrorUtils.LogAndGetExpandChildrenValidationError( NatvisLoggingLevel.WARNING, _logger, _entityType.ToString(), _variable.TypeName, $"Encountered unsupported tag: {_entityType}."); return(Task.FromResult <IList <IVariableInformation> >(new List <IVariableInformation> { errInfo })); }
/// <summary> /// Invokes GetExpressionValue, but returns error variable in case of evaluation error. /// </summary> public async Task <IVariableInformation> GetExpressionValueOrErrorAsync( string expression, IVariableInformation variable, NatvisScope natvisScope, string displayName, string natvisType) { try { return(await EvaluateExpressionAsync(expression, variable, natvisScope, displayName)); } catch (ExpressionEvaluationFailed e) { return(NatvisErrorUtils.LogAndGetEvaluationError( _logger, natvisType, variable?.TypeName, displayName, e.Message)); } }
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++; } } }