Esempio n. 1
0
 public DbgDotNetValueNodeImpl(LanguageValueNodeFactory valueNodeFactory, DbgDotNetValueNodeProvider childNodeProvider, DbgDotNetText name, DbgDotNetValueNodeInfo nodeInfo, string expression, string imageName, bool isReadOnly, bool causesSideEffects, DmdType expectedType, DmdType actualType, string errorMessage, DbgDotNetText valueText, ReadOnlyCollection <string> formatSpecifiers, ColumnFormatter columnFormatter)
 {
     if (name.Parts == null && columnFormatter == null)
     {
         throw new ArgumentException();
     }
     this.valueNodeFactory  = valueNodeFactory ?? throw new ArgumentNullException(nameof(valueNodeFactory));
     this.childNodeProvider = childNodeProvider;
     this.nodeInfo          = nodeInfo;
     Name                  = name;
     Value                 = nodeInfo?.DisplayValue;
     Expression            = expression ?? throw new ArgumentNullException(nameof(expression));
     ImageName             = imageName ?? throw new ArgumentNullException(nameof(imageName));
     IsReadOnly            = isReadOnly;
     CausesSideEffects     = causesSideEffects;
     ExpectedType          = expectedType;
     ActualType            = actualType;
     ErrorMessage          = errorMessage;
     this.valueText        = valueText;
     this.formatSpecifiers = formatSpecifiers;
     this.columnFormatter  = columnFormatter;
 }
Esempio n. 2
0
        DbgDotNetValueNode CreateValue(DbgEvaluationInfo evalInfo, DbgDotNetText name, DbgDotNetValue value, ReadOnlyCollection <string> formatSpecifiers, DbgValueNodeEvaluationOptions options, string expression, string imageName, bool isReadOnly, bool causesSideEffects, DmdType expectedType, bool isRootExpression, ColumnFormatter columnFormatter)
        {
            // Could be a by-ref property, local, or parameter.
            if (expectedType.IsByRef)
            {
                if (value.Type.IsByRef)
                {
                    var newValue = value.LoadIndirect();
                    value.Dispose();
                    if (newValue.HasError)
                    {
                        return(CreateError(evalInfo, name, newValue.ErrorMessage, expression, causesSideEffects));
                    }
                    value = newValue.Value;
                }
                expectedType = expectedType.GetElementType();
            }

            options = PredefinedFormatSpecifiers.GetValueNodeEvaluationOptions(formatSpecifiers, options);
            var  nodeInfo  = new DbgDotNetValueNodeInfo(value, expression);
            bool addParens = isRootExpression && NeedsParentheses(expression);
            DbgDotNetValueNodeProviderResult info;
            bool useProvider        = false;
            var  specialViewOptions = (options & ~(DbgValueNodeEvaluationOptions.ResultsView | DbgValueNodeEvaluationOptions.DynamicView));

            if ((options & DbgValueNodeEvaluationOptions.ResultsView) != 0)
            {
                info        = valueNodeProviderFactory.CreateResultsView(evalInfo, addParens, expectedType, nodeInfo, specialViewOptions);
                useProvider = info.ErrorMessage != null;
            }
            else if ((options & DbgValueNodeEvaluationOptions.DynamicView) != 0)
            {
                info        = valueNodeProviderFactory.CreateDynamicView(evalInfo, addParens, expectedType, nodeInfo, specialViewOptions);
                useProvider = true;
            }
            else
            {
                info = valueNodeProviderFactory.Create(evalInfo, addParens, expectedType, nodeInfo, options);
            }
            if (useProvider)
            {
                if (info.ErrorMessage != null)
                {
                    return(new DbgDotNetValueNodeImpl(this, info.Provider, name, nodeInfo, expression, PredefinedDbgValueNodeImageNames.Error, true, false, null, null, info.ErrorMessage, new DbgDotNetText(new DbgDotNetTextPart(DbgTextColor.Error, info.ErrorMessage)), formatSpecifiers, columnFormatter));
                }
                Debug.Assert(info.Provider != null);
                return(new DbgDotNetValueNodeImpl(this, info.Provider, name, nodeInfo, expression, info.Provider?.ImageName ?? imageName, true, false, null, null, info.ErrorMessage, info.Provider?.ValueText ?? default, formatSpecifiers, columnFormatter));
            }
            return(new DbgDotNetValueNodeImpl(this, info.Provider, name, nodeInfo, expression, imageName, isReadOnly, causesSideEffects, expectedType, value.Type, info.ErrorMessage, default, formatSpecifiers, columnFormatter));