예제 #1
0
        public void GetPropertyInfoWhenFullNameExists()
        {
            var varName = "list.head->value";

            mockVarInfo.Fullname().Returns(varName);

            DEBUG_PROPERTY_INFO propertyInfo;

            GetPropertyInfo(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_FULLNAME, out propertyInfo);

            Assert.That(
                propertyInfo.dwFields.HasFlag(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_FULLNAME));

            Assert.That(propertyInfo.bstrFullName, Is.EqualTo(varName));
        }
예제 #2
0
        public int SetValueAsStringWithError(string value, uint radix, uint timeout,
                                             out string error)
        {
            string outError = null;
            int    status   = _taskExecutor.Run(() =>
            {
                if (_varInfo.Assign(value, out outError))
                {
                    return(VSConstants.S_OK);
                }

                string logName = _varInfo.Fullname();
                if (string.IsNullOrWhiteSpace(logName))
                {
                    logName = _varInfo.DisplayName;
                }

                Trace.WriteLine($"Unable to set var '{logName}'='{value}'. Error: '{outError}'");
                return(AD7Constants.E_SETVALUE_VALUE_CANNOT_BE_SET);
            });

            error = outError;
            return(status);
        }
예제 #3
0
        public async Task <int> GetPropertyInfoAsync(enum_DEBUGPROP_INFO_FLAGS fields, uint radix,
                                                     uint timeout, IDebugReference2[] args,
                                                     uint argCount,
                                                     DEBUG_PROPERTY_INFO[] propertyInfo)
        {
            var info = new DEBUG_PROPERTY_INFO();

            _varInfo.FallbackValueFormat = GetFallbackValueFormat(radix);
            IVariableInformation cachedVarInfo = _varInfo.GetCachedView();

            if ((enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_FULLNAME & fields) != 0)
            {
                string fullname = cachedVarInfo.Fullname();
                if (!string.IsNullOrWhiteSpace(fullname))
                {
                    info.bstrFullName = _vsExpressionCreator
                                        .Create(fullname, cachedVarInfo.FormatSpecifier)
                                        .ToString();

                    info.dwFields |= enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_FULLNAME;
                }
            }

            if ((enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_NAME & fields) != 0)
            {
                info.bstrName  = cachedVarInfo.DisplayName;
                info.dwFields |= enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_NAME;
            }

            if ((enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_TYPE & fields) != 0)
            {
                info.bstrType  = cachedVarInfo.TypeName;
                info.dwFields |= enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_TYPE;
            }

            if ((enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_VALUE & fields) != 0)
            {
                if ((enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_VALUE_AUTOEXPAND & fields) != 0)
                {
                    // The value field is in read-only mode, so we can display additional
                    // information that would normally fail to parse as a proper expression.
                    info.dwFields |= enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_VALUE_AUTOEXPAND;

                    info.bstrValue = await ValueStringBuilder.BuildAsync(cachedVarInfo);
                }
                else
                {
                    // The value field is in editing mode, so only display the assignment value.
                    info.bstrValue = cachedVarInfo.AssignmentValue;
                }

                info.dwFields |= enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_VALUE;
            }

            if ((enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_PROP & fields) != 0)
            {
                info.pProperty = Self;
                info.dwFields |= enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_PROP;
            }

            if ((enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_ATTRIB & fields) != 0)
            {
                if (cachedVarInfo.Error)
                {
                    info.dwAttrib |= enum_DBG_ATTRIB_FLAGS.DBG_ATTRIB_VALUE_ERROR;
                }

                if (cachedVarInfo.MightHaveChildren())
                {
                    info.dwAttrib |= enum_DBG_ATTRIB_FLAGS.DBG_ATTRIB_OBJ_IS_EXPANDABLE;
                }

                if (cachedVarInfo.IsReadOnly)
                {
                    info.dwAttrib |= enum_DBG_ATTRIB_FLAGS.DBG_ATTRIB_VALUE_READONLY;
                }

                if (!string.IsNullOrEmpty(cachedVarInfo.StringView))
                {
                    // Causes Visual Studio to show the text visualizer selector. i.e. the
                    // magnifying glass with Text Visualizer, XML Visualizer, etc.
                    info.dwAttrib |= enum_DBG_ATTRIB_FLAGS.DBG_ATTRIB_VALUE_RAW_STRING;
                }

                info.dwFields |= enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_ATTRIB;
            }

            propertyInfo[0] = info;
            return(VSConstants.S_OK);
        }