Exemple #1
0
 private EvalResult CreateRawViewRow(
     ResultProvider resultProvider,
     DkmInspectionContext inspectionContext,
     EvalResultDataItem parent,
     DkmClrValue value
 )
 {
     var displayName = Resources.RawView;
     var displayValue = value.GetValueString(
         inspectionContext,
         Formatter.NoFormatSpecifiers
     );
     var displayType = ResultProvider.GetTypeName(
         inspectionContext,
         value,
         _typeAndInfo.ClrType,
         _typeAndInfo.Info,
         isPointerDereference: false
     );
     var expansion = new TupleExpansion(_typeAndInfo, _cardinality, useRawView: true);
     return new EvalResult(
         ExpansionKind.Explicit,
         displayName,
         default(TypeAndCustomInfo),
         _typeAndInfo,
         useDebuggerDisplay: false,
         value: value,
         displayValue: displayValue,
         expansion: expansion,
         childShouldParenthesize: parent.ChildShouldParenthesize,
         fullName: parent.FullNameWithoutFormatSpecifiers,
         childFullNamePrefixOpt: parent.ChildFullNamePrefix,
         formatSpecifiers: Formatter.AddFormatSpecifier(parent.FormatSpecifiers, "raw"),
         category: DkmEvaluationResultCategory.Data,
         flags: DkmEvaluationResultFlags.ReadOnly,
         editableValue: null,
         inspectionContext: inspectionContext,
         displayName: displayName,
         displayType: displayType
     );
 }
Exemple #2
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, parenthesizeArgument: false, parenthesizeEntireExpression: true);
                }
            }

            // 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);
        }
Exemple #3
0
 private EvalResult CreateRawViewRow(
     ResultProvider resultProvider,
     DkmInspectionContext inspectionContext,
     EvalResultDataItem parent,
     DkmClrValue value)
 {
     var displayName = Resources.RawView;
     var displayValue = value.GetValueString(inspectionContext, Formatter.NoFormatSpecifiers);
     var displayType = ResultProvider.GetTypeName(
         inspectionContext,
         value,
         _typeAndInfo.ClrType,
         _typeAndInfo.Info,
         isPointerDereference: false);
     var expansion = new TupleExpansion(_typeAndInfo, _cardinality, useRawView: true);
     return new EvalResult(
         ExpansionKind.Explicit,
         displayName,
         default(TypeAndCustomInfo),
         _typeAndInfo,
         useDebuggerDisplay: false,
         value: value,
         displayValue: displayValue,
         expansion: expansion,
         childShouldParenthesize: parent.ChildShouldParenthesize,
         fullName: parent.FullNameWithoutFormatSpecifiers,
         childFullNamePrefixOpt: parent.ChildFullNamePrefix,
         formatSpecifiers: Formatter.AddFormatSpecifier(parent.FormatSpecifiers, "raw"),
         category: DkmEvaluationResultCategory.Data,
         flags: DkmEvaluationResultFlags.ReadOnly,
         editableValue: null,
         inspectionContext: inspectionContext,
         displayName: displayName,
         displayType: displayType);
 }
Exemple #4
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));
        }
Exemple #5
0
        internal Expansion GetTypeExpansion(
            DkmInspectionContext inspectionContext,
            TypeAndCustomInfo declaredTypeAndInfo,
            DkmClrValue value,
            ExpansionFlags flags)
        {
            var declaredType = declaredTypeAndInfo.Type;

            Debug.Assert(!declaredType.IsTypeVariables());

            if ((inspectionContext.EvaluationFlags & DkmEvaluationFlags.NoExpansion) != 0)
            {
                return(null);
            }

            var runtimeType = value.Type.GetLmrType();

            // If the value is an array, expand the array elements.
            if (runtimeType.IsArray)
            {
                var sizes = value.ArrayDimensions;
                if (sizes == null)
                {
                    // Null array. No expansion.
                    return(null);
                }
                var lowerBounds = value.ArrayLowerBounds;

                Type elementType;
                DkmClrCustomTypeInfo elementTypeInfo;
                if (declaredType.IsArray)
                {
                    elementType     = declaredType.GetElementType();
                    elementTypeInfo = CustomTypeInfo.SkipOne(declaredTypeAndInfo.Info);
                }
                else
                {
                    elementType     = runtimeType.GetElementType();
                    elementTypeInfo = null;
                }

                return(ArrayExpansion.CreateExpansion(new TypeAndCustomInfo(DkmClrType.Create(declaredTypeAndInfo.ClrType.AppDomain, elementType), elementTypeInfo), sizes, lowerBounds));
            }

            if (this.IsPrimitiveType(runtimeType))
            {
                return(null);
            }

            if (declaredType.IsFunctionPointer())
            {
                // Function pointers have no expansion
                return(null);
            }

            if (declaredType.IsPointer)
            {
                // If this assert fails, the element type info is just .SkipOne().
                Debug.Assert(declaredTypeAndInfo.Info?.PayloadTypeId != CustomTypeInfo.PayloadTypeId);
                var elementType = declaredType.GetElementType();
                return(value.IsNull || elementType.IsVoid()
                    ? null
                    : new PointerDereferenceExpansion(new TypeAndCustomInfo(DkmClrType.Create(declaredTypeAndInfo.ClrType.AppDomain, elementType))));
            }

            if (value.EvalFlags.Includes(DkmEvaluationResultFlags.ExceptionThrown) &&
                runtimeType.IsEmptyResultsViewException())
            {
                // The value is an exception thrown expanding an empty
                // IEnumerable. Use the runtime type of the exception and
                // skip base types. (This matches the native EE behavior
                // to expose a single property from the exception.)
                flags &= ~ExpansionFlags.IncludeBaseMembers;
            }

            int cardinality;

            if (runtimeType.IsTupleCompatible(out cardinality))
            {
                return(TupleExpansion.CreateExpansion(value, declaredTypeAndInfo, cardinality));
            }

            return(MemberExpansion.CreateExpansion(inspectionContext, declaredTypeAndInfo, value, flags, TypeHelpers.IsVisibleMember, this));
        }