Beispiel #1
0
 string IDkmClrFormatter.GetValueString(
     DkmClrValue clrValue,
     DkmInspectionContext inspectionContext,
     ReadOnlyCollection <string> formatSpecifiers
     )
 {
     return(clrValue.GetValueString(inspectionContext, formatSpecifiers));
 }
Beispiel #2
0
 string IDkmClrFormatter2.GetValueString(
     DkmClrValue value,
     DkmClrCustomTypeInfo customTypeInfo,
     DkmInspectionContext inspectionContext,
     ReadOnlyCollection <string> formatSpecifiers
     )
 {
     return(value.GetValueString(inspectionContext, formatSpecifiers));
 }
Beispiel #3
0
        internal string FormatValue(DkmClrValue clrValue, bool useHexadecimal = false)
        {
            var inspectionContext = CreateDkmInspectionContext(
                _inspectionSession,
                DkmEvaluationFlags.None,
                radix: useHexadecimal ? 16u : 10u
                );

            return(clrValue.GetValueString(inspectionContext, Formatter.NoFormatSpecifiers));
        }
        /// <summary>
        /// This method is called by the debug engine to populate the text representing the value
        /// of an expression.
        /// </summary>
        /// <param name="clrValue">The raw value to get the text for</param>
        /// <param name="inspectionContext">Context of the evaluation.  This contains options/flags
        /// to be used during compilation. It also contains the InspectionSession.  The inspection
        /// session is the object that provides lifetime management for our objects.  When the user
        /// steps or continues the process, the debug engine will dispose of the inspection session</param>
        /// <param name="formatSpecifiers"></param>
        /// <returns>The text representing the given value</returns>
        string IDkmClrFormatter.GetValueString(DkmClrValue clrValue, DkmInspectionContext inspectionContext, ReadOnlyCollection <string> formatSpecifiers)
        {
            DkmClrType clrType = clrValue.Type;

            if (clrType == null)
            {
                // This can be null in some error cases
                return(string.Empty);
            }

            // Try to format the value.  If we can't format the value, delegate to the C# Formatter.
            string value = TryFormatValue(clrValue, inspectionContext);

            return(value ?? clrValue.GetValueString(inspectionContext, formatSpecifiers));
        }
        private string TryFormatValue(DkmClrValue value, DkmInspectionContext inspectionContext)
        {
            if (value.ValueFlags.HasFlag(DkmClrValueFlags.Error))
            {
                // Error message.  Just show the error.
                return(value.HostObjectValue as string);
            }

            Type lmrType = value.Type.GetLmrType();

            if (lmrType.IsEnum)
            {
                return(value.GetValueString(inspectionContext, null));
            }
            XSharpType xType = Utility.GetXSharpTypeForLmrType(lmrType);

            if (xType == XSharpType.Invalid)
            {
                // We don't know how to format this value
                return(null);
            }
            uint   radix           = inspectionContext.Radix;
            object hostObjectValue = value.HostObjectValue;

            if (hostObjectValue != null)
            {
                // If the value can be marshalled into the debugger process, HostObjectValue is the
                // equivalent value in the debugger process.
                switch (System.Type.GetTypeCode(hostObjectValue.GetType()))
                {
                case TypeCode.Int32:
                    return(FormatInteger((int)hostObjectValue, radix));

                case TypeCode.Boolean:
                    return((bool)hostObjectValue ? "TRUE" : "FALSE");

                case TypeCode.String:
                    return(FormatString(hostObjectValue.ToString(), inspectionContext.EvaluationFlags));
                }
            }

            return(null);
        }
Beispiel #6
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
     );
 }