Example #1
0
        private static EvalResult GetMemberRow(
            ResultProvider resultProvider,
            DkmInspectionContext inspectionContext,
            DkmClrValue value,
            Field field,
            EvalResultDataItem parent,
            int cardinality)
        {
            var fullNameProvider = resultProvider.FullNameProvider;
            var parentFullName   = parent.ChildFullNamePrefix;

            if (parentFullName != null)
            {
                if (parent.ChildShouldParenthesize)
                {
                    parentFullName = parentFullName.Parenthesize();
                }
                var parentRuntimeType = parent.Value.Type;
                if (!parent.DeclaredTypeAndInfo.Type.Equals(parentRuntimeType.GetLmrType()))
                {
                    parentFullName = fullNameProvider.GetClrCastExpression(
                        inspectionContext,
                        parentFullName,
                        parentRuntimeType,
                        customTypeInfo: null,
                        castExpressionOptions: DkmClrCastExpressionOptions.ParenthesizeEntireExpression);
                }
            }

            // Ideally if the caller requests multiple items in a nested tuple
            // we should only evaluate Rest once, and should only calculate
            // the full name for Rest once.
            string fullName;
            var    fieldValue = GetValueAndFullName(
                fullNameProvider,
                inspectionContext,
                value,
                field,
                parentFullName,
                out fullName);
            var name = field.Name;
            var typeDeclaringMemberAndInfo = default(TypeAndCustomInfo);
            var declaredTypeAndInfo        = field.FieldTypeAndInfo;
            var flags            = fieldValue.EvalFlags;
            var formatSpecifiers = Formatter.NoFormatSpecifiers;

            if (field.IsRest)
            {
                var displayValue = fieldValue.GetValueString(inspectionContext, Formatter.NoFormatSpecifiers);
                var displayType  = ResultProvider.GetTypeName(
                    inspectionContext,
                    fieldValue,
                    declaredTypeAndInfo.ClrType,
                    declaredTypeAndInfo.Info,
                    isPointerDereference: false);
                var expansion = new TupleExpansion(declaredTypeAndInfo, cardinality - (TypeHelpers.TupleFieldRestPosition - 1), useRawView: true);
                return(new EvalResult(
                           ExpansionKind.Explicit,
                           name,
                           typeDeclaringMemberAndInfo,
                           declaredTypeAndInfo,
                           useDebuggerDisplay: false,
                           value: fieldValue,
                           displayValue: displayValue,
                           expansion: expansion,
                           childShouldParenthesize: false,
                           fullName: fullName,
                           childFullNamePrefixOpt: flags.Includes(DkmEvaluationResultFlags.ExceptionThrown) ? null : fullName,
                           formatSpecifiers: Formatter.AddFormatSpecifier(formatSpecifiers, "raw"),
                           category: DkmEvaluationResultCategory.Other,
                           flags: flags,
                           editableValue: null,
                           inspectionContext: inspectionContext,
                           displayName: name,
                           displayType: displayType));
            }

            return(resultProvider.CreateDataItem(
                       inspectionContext,
                       name,
                       typeDeclaringMemberAndInfo: typeDeclaringMemberAndInfo,
                       declaredTypeAndInfo: declaredTypeAndInfo,
                       value: fieldValue,
                       useDebuggerDisplay: false,
                       expansionFlags: ExpansionFlags.All,
                       childShouldParenthesize: false,
                       fullName: fullName,
                       formatSpecifiers: formatSpecifiers,
                       category: DkmEvaluationResultCategory.Other,
                       flags: flags,
                       evalFlags: DkmEvaluationFlags.None,
                       canFavorite: false,
                       isFavorite: false,
                       supportsFavorites: true));
        }