Exemplo n.º 1
0
 public VisualizerInfo(VisualizerType viz, TypeName name)
 {
     Visualizer = viz;
     // add the template parameter macro values
     NatvisScope = new NatvisScope();
     for (int i = 0; i < name.Args.Count; ++i)
     {
         NatvisScope.AddScopedName($"$T{i + 1}", name.Args[i].FullyQualifiedName);
     }
 }
Exemplo n.º 2
0
        public override async Task <IList <IVariableInformation> > GetChildrenAsync(
            int from, int count)
        {
            await InitAsync();

            var result = new List <IVariableInformation>();

            if (_store.ValidationError != null)
            {
                result.Add(_store.ValidationError);
                return(result.GetRange(from, count));
            }

            var indexDic = new NatvisScope(_natvisScope);

            for (int index = from; index < from + count; index++)
            {
                IVariableInformation varInfo = await _store.GetOrEvaluateAsync(index, async i => {
                    indexDic.AddScopedName("$i", $"{i}U");
                    string displayName = $"[{i}]";

                    // From the list of all <ValueNode> children, filter all with non-empty body
                    // and return the first which Condition evaluates to true.
                    IndexNodeType valueNode =
                        await _indexListItems
                        .ValueNode?.Where(v => !string.IsNullOrWhiteSpace(v.Value))
                        .FirstOrDefaultAsync(v => _evaluator.EvaluateConditionAsync(
                                                 v.Condition, _variable, indexDic));

                    if (valueNode == null)
                    {
                        // For the current index $i, there is no <ValueNode> which passes the
                        // Condition check.
                        return(new ErrorVariableInformation(
                                   displayName, "<Error> No valid <ValueNode> found."));
                    }

                    return(await _evaluator.GetExpressionValueOrErrorAsync(
                               valueNode.Value, _variable, indexDic, displayName, "IndexListItems"));
                });

                result.Add(varInfo);
            }

            return(result);
        }