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 static async Task <IVariableInformation[]> GetAllChildrenAsync(
            this IVariableInformation varInfo)
        {
            IChildAdapter childAdapter = varInfo.GetChildAdapter();

            return((await childAdapter.GetChildrenAsync(0, await childAdapter.CountChildrenAsync()))
                   .ToArray());
        }
Esempio n. 3
0
 ChildrenProvider(CreateDebugPropertyDelegate createPropertyDelegate,
                  IChildAdapter childAdapter, enum_DEBUGPROP_INFO_FLAGS debugInfoFlags,
                  uint radix)
 {
     _createPropertyDelegate = createPropertyDelegate;
     _childAdapter           = childAdapter;
     _debugInfoFlags         = debugInfoFlags;
     _radix = radix;
 }
Esempio n. 4
0
        async Task InitChildAdapterAsync()
        {
            if (_childAdapter == null)
            {
                IVariableInformation expandInfo = await _evaluator.EvaluateExpressionAsync(
                    _expandedItem.Value, _variable, _natvisScope, null);

                _childAdapter = expandInfo.GetChildAdapter();
            }
        }
 SmartPointerEntity(NatvisExpressionEvaluator evaluator, NatvisDiagnosticLogger logger,
                    IVariableInformation variable, SmartPointerType smartPointerItem,
                    NatvisScope natvisScope, IChildAdapter fallbackAdapter)
 {
     _evaluator        = evaluator;
     _logger           = logger;
     _variable         = variable;
     _smartPointerItem = smartPointerItem;
     _natvisScope      = natvisScope;
     _fallbackAdapter  = fallbackAdapter;
 }
Esempio n. 6
0
            public virtual IChildrenProvider Create(IChildAdapter childAdapter,
                                                    enum_DEBUGPROP_INFO_FLAGS debugInfoFlags,
                                                    uint radix)
            {
                if (_createPropertyDelegate == null)
                {
                    throw new NullReferenceException(
                              $"{nameof(_createPropertyDelegate)} has to be initialized.");
                }

                return(new ChildrenProvider(_createPropertyDelegate, childAdapter, debugInfoFlags,
                                            radix));
            }
Esempio n. 7
0
        internal IChildAdapter GetChildAdapter(IVariableInformation variable)
        {
            VisualizerInfo visualizer = VisualizerScanner.FindType(variable);

            if (visualizer?.Visualizer.Items == null)
            {
                return(variable.GetChildAdapter());
            }

            IChildAdapter childAdapter = CreateNatvisChildAdapter(visualizer, variable);

            // Special case for SSE registers. VS calls VariableInformationEnum.Count, even if
            // the SSE registers are not visible. Without this, we would have to expand all
            // children just to get the count, which slows down the register window a lot.
            if (variable.CustomVisualizer == CustomVisualizer.SSE ||
                variable.CustomVisualizer == CustomVisualizer.SSE2)
            {
                return(new SseAdapter(visualizer.GetExpandType().Items.Length, childAdapter));
            }

            return(childAdapter);
        }
Esempio n. 8
0
 async Task <string[]> GetAllChildFormatSpecifiersAsync(IChildAdapter childAdapter)
 {
     return((await childAdapter.GetChildrenAsync(0, await childAdapter.CountChildrenAsync()))
            .Select(child => child.FormatSpecifier)
            .ToArray());
 }
Esempio n. 9
0
 async Task <string[]> GetAllChildNamesAsync(IChildAdapter childAdapter)
 {
     return((await childAdapter.GetChildrenAsync(0, await childAdapter.CountChildrenAsync()))
            .Select(child => child.DisplayName)
            .ToArray());
 }
Esempio n. 10
0
 async Task <string[]> GetChildNamesAsync(IChildAdapter childAdapter, int offset, int count)
 {
     return((await childAdapter.GetChildrenAsync(offset, count))
            .Select(child => child.DisplayName)
            .ToArray());
 }
Esempio n. 11
0
 public MoreVariableInformation(IChildAdapter childAdapter)
 {
     _childAdapter = childAdapter;
 }
Esempio n. 12
0
 public SmartPointerEntity Create(IVariableInformation variable,
                                  SmartPointerType smartPointerItem,
                                  NatvisScope natvisScope,
                                  IChildAdapter fallbackAdapter) =>
 new SmartPointerEntity(_evaluator, _logger, variable, smartPointerItem, natvisScope,
                        fallbackAdapter);
Esempio n. 13
0
        static async Task <string> FormatChildrenListAsync(IVariableInformation varInfo,
                                                           int charactersLeft,
                                                           string noChildrenMarker = "")
        {
            IChildAdapter children = varInfo.GetChildAdapter();

            if (children is INatvisEntity)
            {
                return("");
            }

            int childrenCount = await children.CountChildrenAsync();

            const int     maxChildren = 3;
            StringBuilder sb          = new StringBuilder();

            sb.Append("{");
            for (int i = 0; i < childrenCount; i++)
            {
                try
                {
                    IVariableInformation currentChild =
                        (await children.GetChildrenAsync(i, 1)).ElementAt(0).GetCachedView();

                    // For array elements or pointers, we do not display the child name.
                    // Also array elements are separated by commas. We detect the array elements
                    // using a somewhat hacky way - we check if their name is the index in
                    // square brackets.
                    bool isArrayElementOrPointee =
                        currentChild.DisplayName == $"[{i}]" || currentChild.DisplayName == "";

                    if (i != 0)
                    {
                        sb.Append(isArrayElementOrPointee ? ", " : " ");
                    }

                    // If we are over the limit, let us just display the dots and exit.
                    if (!isArrayElementOrPointee && i >= maxChildren)
                    {
                        sb.Append("...");
                        break;
                    }

                    string childValue =
                        await BuildAsync(currentChild, charactersLeft - sb.Length - 1);

                    if (string.IsNullOrEmpty(childValue) && currentChild.GetChildAdapter()
                        is INatvisEntity)
                    {
                        childValue = "{...}";
                    }
                    else if (childValue == "..." || string.IsNullOrEmpty(childValue))
                    {
                        sb.Append(childValue);
                        break;
                    }

                    if (!isArrayElementOrPointee)
                    {
                        sb.Append($"{currentChild.DisplayName}=");
                    }
                    sb.Append(childValue);
                }
                catch (ArgumentOutOfRangeException)
                {
                    break;
                }
            }
            if (childrenCount == 0)
            {
                sb.Append(noChildrenMarker);
            }
            sb.Append("}");
            return(sb.ToString());
        }
 protected RangedChildAdapterDecorator(IChildAdapter entity, int maxChildren, int offset)
 {
     _entity      = entity;
     _maxChildren = maxChildren;
     _offset      = offset;
 }
Esempio n. 15
0
 public SseAdapter(int count, IChildAdapter childAdapter)
 {
     _count        = count;
     _childAdapter = childAdapter;
 }