예제 #1
0
        void FormatCore(DbgEvaluationInfo evalInfo, IDbgValueNodeFormatParameters options, CultureInfo?cultureInfo)
        {
            evalInfo.Runtime.GetDotNetRuntime().Dispatcher.VerifyAccess();
            DbgValueFormatterOptions     formatterOptions;
            DbgValueFormatterTypeOptions typeFormatterOptions;
            var formatter = owner.Formatter;
            var dnValue   = value?.DotNetValue;

            if (!(options.NameOutput is null))
            {
                formatterOptions = PredefinedFormatSpecifiers.GetValueFormatterOptions(dnValueNode.FormatSpecifiers, options.NameFormatterOptions);
                if (dnValueNode.FormatName(evalInfo, options.NameOutput, formatter, formatterOptions, cultureInfo))
                {
                    // Nothing
                }
                else
                {
                    dnValueNode.Name.WriteTo(options.NameOutput);
                }
                evalInfo.CancellationToken.ThrowIfCancellationRequested();
            }
            if (!(options.ExpectedTypeOutput is null))
            {
                formatterOptions     = PredefinedFormatSpecifiers.GetValueFormatterOptions(dnValueNode.FormatSpecifiers, options.TypeFormatterOptions);
                typeFormatterOptions = PredefinedFormatSpecifiers.GetValueFormatterTypeOptions(dnValueNode.FormatSpecifiers, options.ExpectedTypeFormatterOptions);
                if (dnValueNode.FormatExpectedType(evalInfo, options.ExpectedTypeOutput, formatter, typeFormatterOptions, formatterOptions, cultureInfo))
                {
                    // Nothing
                }
                else if (dnValueNode.ExpectedType is DmdType expectedType)
                {
                    formatter.FormatType(evalInfo, options.ExpectedTypeOutput, expectedType, null, typeFormatterOptions, cultureInfo);
                }
                evalInfo.CancellationToken.ThrowIfCancellationRequested();
            }
            if (!(options.ActualTypeOutput is null))
            {
                formatterOptions     = PredefinedFormatSpecifiers.GetValueFormatterOptions(dnValueNode.FormatSpecifiers, options.TypeFormatterOptions);
                typeFormatterOptions = PredefinedFormatSpecifiers.GetValueFormatterTypeOptions(dnValueNode.FormatSpecifiers, options.ActualTypeFormatterOptions);
                if (dnValueNode.FormatActualType(evalInfo, options.ActualTypeOutput, formatter, typeFormatterOptions, formatterOptions, cultureInfo))
                {
                    // Nothing
                }
                else if (dnValueNode.ActualType is DmdType actualType)
                {
                    formatter.FormatType(evalInfo, options.ActualTypeOutput, actualType, dnValue, typeFormatterOptions, cultureInfo);
                }
                evalInfo.CancellationToken.ThrowIfCancellationRequested();
            }
            if (!(options.ValueOutput is null))
            {
                formatterOptions = PredefinedFormatSpecifiers.GetValueFormatterOptions(dnValueNode.FormatSpecifiers, options.ValueFormatterOptions);
                if (dnValueNode.FormatValue(evalInfo, options.ValueOutput, formatter, formatterOptions, cultureInfo))
                {
                    // Nothing
                }
                else if (!(dnValue is null))
                {
                    formatter.FormatValue(evalInfo, options.ValueOutput, dnValue, formatterOptions, cultureInfo);
                }
예제 #2
0
        void FormatCore(DbgEvaluationContext context, DbgStackFrame frame, IDbgValueNodeFormatParameters options, CultureInfo cultureInfo, CancellationToken cancellationToken)
        {
            context.Runtime.GetDotNetRuntime().Dispatcher.VerifyAccess();
            if (options.NameOutput != null)
            {
                dnValueNode.Name.WriteTo(options.NameOutput);
            }
            var formatter = owner.Formatter;
            var dnValue   = value?.DotNetValue;

            if (options.ExpectedTypeOutput != null)
            {
                if (dnValueNode.FormatExpectedType(context, frame, options.ExpectedTypeOutput, cultureInfo, cancellationToken))
                {
                    // Nothing
                }
                else if (dnValueNode.ExpectedType is DmdType expectedType)
                {
                    formatter.FormatType(context, options.ExpectedTypeOutput, expectedType, null, options.ExpectedTypeFormatterOptions, cultureInfo);
                }
                cancellationToken.ThrowIfCancellationRequested();
            }
            if (options.ActualTypeOutput != null)
            {
                if (dnValueNode.FormatActualType(context, frame, options.ActualTypeOutput, cultureInfo, cancellationToken))
                {
                    // Nothing
                }
                else if (dnValueNode.ActualType is DmdType actualType)
                {
                    formatter.FormatType(context, options.ActualTypeOutput, actualType, dnValue, options.ActualTypeFormatterOptions, cultureInfo);
                }
                cancellationToken.ThrowIfCancellationRequested();
            }
            if (options.ValueOutput != null)
            {
                if (dnValueNode.FormatValue(context, frame, options.ValueOutput, cultureInfo, cancellationToken))
                {
                    // Nothing
                }
                else if (dnValue != null)
                {
                    formatter.FormatValue(context, options.ValueOutput, frame, dnValue, options.ValueFormatterOptions, cultureInfo, cancellationToken);
                }
                else if (ErrorMessage is string errorMessage)
                {
                    options.ValueOutput.Write(BoxedTextColor.Error, owner.ErrorMessagesHelper.GetErrorMessage(errorMessage));
                }
                cancellationToken.ThrowIfCancellationRequested();
            }
        }