static IRemoteValueFormat ParseFormat(string formatSpecifier, uint?evaluatedSize = null)
        {
            // Empty specifier is not accepted.
            if (string.IsNullOrEmpty(formatSpecifier))
            {
                return(null);
            }

            // Split the expression into a size specifier, a raw formatter specifier and a value
            // format.
            if (!FormatSpecifierUtil.TrySplitSpecifier(formatSpecifier, out string size,
                                                       out string raw, out string baseSpecifier) ||
                !_formatLookup.ContainsKey(baseSpecifier))
            {
                return(null);
            }
            ISingleValueFormat valueFormat = _formatLookup[baseSpecifier];

            if (string.IsNullOrEmpty(size))
            {
                return(new RemoteValueFormat(valueFormat));
            }
            uint?parsedSize = TryParseSizeFormat(size, evaluatedSize);

            if (parsedSize != null)
            {
                return(new RemoteValueFormat(valueFormat, parsedSize));
            }
            return(null);
        }
        /// <summary>
        /// Checks whether we are dealing with a pointer or not.
        /// For pointers, it assignes values as Native Visual Studio would do.
        /// If we have a pointer to a struct, it calls ExtractChildren(),
        /// since the childValue is an empty string.
        /// </summary>
        static async Task <string> UnwrapPointerValueAsync(IVariableInformation varInfo,
                                                           int charactersLeft)
        {
            string value = await varInfo.ValueAsync();

            if (!varInfo.IsPointer)
            {
                return(value);
            }

            // For pointers, the assignment value is equal to the memory address and the
            // value is the content stored at that location.
            string plainValue    = varInfo.AssignmentValue;
            string memoryAddress = varInfo.GetMemoryAddressAsHex();
            string addressPrefix =
                FormatSpecifierUtil.SuppressMemoryAddress(varInfo.FormatSpecifier)
                    ? ""
                    : memoryAddress + " ";

            if (value != "" && plainValue != value)
            {
                return(addressPrefix + value);
            }

            if (varInfo.IsNullPointer())
            {
                return(addressPrefix + "<NULL>");
            }

            return(addressPrefix +
                   await FormatChildrenListAsync(
                       varInfo, charactersLeft - $"{addressPrefix}{{}}".Length, "???"));
        }
Exemple #3
0
        // TODO Convert RemoteValueChildAdapter to async.
        public Task <IList <IVariableInformation> > GetChildrenAsync(int from, int count)
        {
            string childFormatSpecifier =
                FormatSpecifierUtil.GetChildFormatSpecifier(_formatSpecifier, _remoteValueFormat);

            IList <IVariableInformation> result =
                _remoteValueFormat.GetChildren(_remoteValue, from, count)
                .Select(v => _varInfoBuilder.Create(
                            v, formatSpecifier: new FormatSpecifier(childFormatSpecifier)))
                .ToList();

            return(Task.FromResult(result));
        }
 public static bool IsValidSizeSpecifierSuffix(string suffix)
 {
     suffix = FormatSpecifierUtil.RemoveRawFormatSpecifierPrefix(suffix);
     return(_formatLookup.ContainsKey(suffix));
 }