private EvalResultDataItem GetRow( ResultProvider resultProvider, DkmInspectionContext inspectionContext, DkmClrValue value, int index, EvalResultDataItem parent) { var indices = GetIndices(index); var formatter = resultProvider.Formatter; var name = formatter.GetArrayIndexExpression(indices); var element = value.GetArrayElement(indices, inspectionContext); var fullName = GetFullName(parent, name, formatter); return(resultProvider.CreateDataItem( inspectionContext, name, typeDeclaringMemberAndInfo: default(TypeAndCustomInfo), declaredTypeAndInfo: _elementTypeAndInfo, value: element, parent: parent, expansionFlags: ExpansionFlags.IncludeBaseMembers, childShouldParenthesize: false, fullName: fullName, formatSpecifiers: Formatter.NoFormatSpecifiers, category: DkmEvaluationResultCategory.Other, flags: element.EvalFlags, evalFlags: inspectionContext.EvaluationFlags)); }
internal override void GetRows( ResultProvider resultProvider, ArrayBuilder<EvalResult> rows, DkmInspectionContext inspectionContext, EvalResultDataItem parent, DkmClrValue value, int startIndex, int count, bool visitAll, ref int index) { var fields = GetFields(); int startIndex2; int count2; GetIntersection(startIndex, count, index, fields.Count, out startIndex2, out count2); int offset = startIndex2 - index; for (int i = 0; i < count2; i++) { var row = GetMemberRow(resultProvider, inspectionContext, value, fields[i + offset], parent); rows.Add(row); } index += fields.Count; }
private void GetItemsAndContinue(EvalResultDataItem dataItem, DkmWorkList workList, int startIndex, int count, DkmInspectionContext inspectionContext, DkmCompletionRoutine <DkmEvaluationEnumAsyncResult> completionRoutine) { var expansion = dataItem.Expansion; var value = dataItem.Value; var rows = ArrayBuilder <EvalResultDataItem> .GetInstance(); if (expansion != null) { int index = 0; expansion.GetRows(this, rows, inspectionContext, dataItem, value, startIndex, count, visitAll: false, index: ref index); } var numRows = rows.Count; Debug.Assert(count >= numRows); var results = new DkmEvaluationResult[numRows]; GetEvaluationResultsAndContinue(rows, results, 0, numRows, workList, inspectionContext, value.StackFrame, () => ContinueWithExceptionHandling( () => { completionRoutine(new DkmEvaluationEnumAsyncResult(results)); rows.Free(); }, e => completionRoutine(DkmEvaluationEnumAsyncResult.CreateErrorResult(e)))); }
private static DkmEvaluationResult GetRow( ResultProvider resultProvider, Type declaredType, DkmClrValue value, Expansion expansion, EvalResultDataItem parent) { var dataItem = new EvalResultDataItem( name: null, typeDeclaringMember: null, declaredType: declaredType, value: value, expansion: expansion, childShouldParenthesize: parent.ChildShouldParenthesize, fullName: parent.FullNameWithoutFormatSpecifiers, childFullNamePrefixOpt: parent.ChildFullNamePrefix, formatSpecifiers: HiddenFormatSpecifiers, category: DkmEvaluationResultCategory.Data, flags: DkmEvaluationResultFlags.ReadOnly, editableValue: null); return(ResultProvider.CreateEvaluationResult( value, Resources.NonPublicMembers, typeName: "", display: null, dataItem: dataItem)); }
internal override void GetRows( ResultProvider resultProvider, ArrayBuilder <EvalResult> rows, DkmInspectionContext inspectionContext, EvalResultDataItem parent, DkmClrValue value, int startIndex, int count, bool visitAll, ref int index) { int startIndex2; int count2; GetIntersection(startIndex, count, index, _members.Length, out startIndex2, out count2); int offset = startIndex2 - index; for (int i = 0; i < count2; i++) { rows.Add(GetMemberRow(resultProvider, inspectionContext, value, _members[i + offset], parent, _customTypeInfoMap)); } index += _members.Length; }
internal override void GetRows( ResultProvider resultProvider, ArrayBuilder <EvalResult> rows, DkmInspectionContext inspectionContext, EvalResultDataItem parent, DkmClrValue value, int startIndex, int count, bool visitAll, ref int index ) { if (InRange(startIndex, count, index)) { rows.Add( CreateDynamicViewRow( inspectionContext, Resources.DynamicView, parent, resultProvider.FullNameProvider ) ); } index++; }
private DebuggerTypeProxyExpansion( DkmInspectionContext inspectionContext, DkmClrValue proxyValue, string name, Type typeDeclaringMemberOpt, Type declaredType, DkmClrValue value, bool childShouldParenthesize, string fullName, string childFullNamePrefix, ReadOnlyCollection <string> formatSpecifiers, DkmEvaluationResultFlags flags, string editableValue, Formatter formatter) { Debug.Assert(proxyValue != null); var proxyType = proxyValue.Type.GetLmrType(); var proxyMembers = MemberExpansion.CreateExpansion( inspectionContext, proxyType, proxyValue, ExpansionFlags.IncludeBaseMembers, TypeHelpers.IsPublic, formatter); if (proxyMembers != null) { var proxyMemberFullNamePrefix = (childFullNamePrefix == null) ? null : formatter.GetObjectCreationExpression(formatter.GetTypeName(proxyType, escapeKeywordIdentifiers: true), childFullNamePrefix); _proxyItem = new EvalResultDataItem( ExpansionKind.Default, name: string.Empty, typeDeclaringMember: null, declaredType: proxyType, parent: null, value: proxyValue, displayValue: null, expansion: proxyMembers, childShouldParenthesize: false, fullName: null, childFullNamePrefixOpt: proxyMemberFullNamePrefix, formatSpecifiers: Formatter.NoFormatSpecifiers, category: default(DkmEvaluationResultCategory), flags: default(DkmEvaluationResultFlags), editableValue: null, inspectionContext: inspectionContext); } _name = name; _typeDeclaringMemberOpt = typeDeclaringMemberOpt; _declaredType = declaredType; _value = value; _childShouldParenthesize = childShouldParenthesize; _fullName = fullName; _childFullNamePrefix = childFullNamePrefix; _formatSpecifiers = formatSpecifiers; _flags = flags; _editableValue = editableValue; }
internal override void GetRows( ResultProvider resultProvider, ArrayBuilder <EvalResult> rows, DkmInspectionContext inspectionContext, EvalResultDataItem parent, DkmClrValue value, int startIndex, int count, bool visitAll, ref int index) { var fields = GetFields(); int startIndex2; int count2; GetIntersection(startIndex, count, index, fields.Count, out startIndex2, out count2); int offset = startIndex2 - index; for (int i = 0; i < count2; i++) { var row = GetMemberRow(resultProvider, inspectionContext, value, fields[i + offset], parent); rows.Add(row); } index += fields.Count; }
private static string GetFullName(EvalResultDataItem parent, string name, Formatter formatter) { var parentFullName = parent.ChildFullNamePrefix; if (parentFullName == null) { return(null); } if (parent.ChildShouldParenthesize) { parentFullName = $"({parentFullName})"; } var parentRuntimeType = parent.Value.Type.GetLmrType(); if (!parent.DeclaredTypeAndInfo.Type.Equals(parentRuntimeType)) { bool sawInvalidIdentifier; var parentTypeName = formatter.GetTypeName(new TypeAndCustomInfo(parentRuntimeType), escapeKeywordIdentifiers: true, sawInvalidIdentifier: out sawInvalidIdentifier); if (sawInvalidIdentifier) { return(null); // Wouldn't be parseable. } parentFullName = formatter.GetCastExpression(parentFullName, parentTypeName, parenthesizeEntireExpression: true); } return(parentFullName + name); }
internal override void GetRows( ResultProvider resultProvider, ArrayBuilder <EvalResult> rows, DkmInspectionContext inspectionContext, EvalResultDataItem parent, DkmClrValue value, int startIndex, int count, bool visitAll, ref int index ) { foreach (var expansion in _expansions) { expansion.GetRows( resultProvider, rows, inspectionContext, parent, value, startIndex, count, visitAll, ref index ); if (!visitAll && (index >= startIndex + count)) { return; } } }
internal override void GetRows( ResultProvider resultProvider, ArrayBuilder <EvalResultDataItem> rows, DkmInspectionContext inspectionContext, EvalResultDataItem parent, DkmClrValue value, int startIndex, int count, bool visitAll, ref int index) { int startIndex2; int count2; GetIntersection(startIndex, count, index, _count, out startIndex2, out count2); int offset = startIndex2 - index; for (int i = 0; i < count2; i++) { rows.Add(GetRow(resultProvider, inspectionContext, value, i + offset, parent)); } index += _count; }
private static DkmEvaluationResult GetRow( ResultProvider resultProvider, Type declaredType, DkmClrValue value, Expansion expansion) { var formatter = resultProvider.Formatter; var fullName = formatter.GetTypeName(declaredType, escapeKeywordIdentifiers: true); var dataItem = new EvalResultDataItem( name: null, typeDeclaringMember: null, declaredType: declaredType, value: value, expansion: expansion, childShouldParenthesize: false, fullName: fullName, childFullNamePrefixOpt: fullName, formatSpecifiers: Formatter.NoFormatSpecifiers, category: DkmEvaluationResultCategory.Class, flags: DkmEvaluationResultFlags.ReadOnly, editableValue: null); return(ResultProvider.CreateEvaluationResult( value, formatter.StaticMembersString, typeName: "", display: null, dataItem: dataItem)); }
private EvalResult CreateResultsViewRow( DkmInspectionContext inspectionContext, EvalResultDataItem parent, IDkmClrFullNameProvider fullNameProvider) { Debug.Assert(parent != null); var proxyTypeAndInfo = new TypeAndCustomInfo(_proxyValue.Type); var fullName = parent.ChildFullNamePrefix; var childFullNamePrefix = (fullName == null) ? null : fullNameProvider.GetClrObjectCreationExpression( inspectionContext, proxyTypeAndInfo.ClrType, proxyTypeAndInfo.Info, new[] { fullName }); return(new EvalResult( ExpansionKind.ResultsView, Resources.ResultsView, typeDeclaringMemberAndInfo: default(TypeAndCustomInfo), declaredTypeAndInfo: proxyTypeAndInfo, useDebuggerDisplay: false, value: _proxyValue, displayValue: Resources.ResultsViewValueWarning, expansion: _proxyMembers, childShouldParenthesize: false, fullName: fullName, childFullNamePrefixOpt: childFullNamePrefix, formatSpecifiers: Formatter.AddFormatSpecifier(parent.FormatSpecifiers, ResultsFormatSpecifier), category: DkmEvaluationResultCategory.Method, flags: DkmEvaluationResultFlags.ReadOnly, editableValue: null, inspectionContext: inspectionContext)); }
private EvalResult GetRow( DkmInspectionContext inspectionContext, DkmClrValue value, int index, EvalResultDataItem parent) { var typeParameter = _typeParameters[index]; var typeArgument = _typeArguments[index]; var typeArgumentInfo = _customTypeInfoMap.SubstituteCustomTypeInfo(typeParameter, customInfo: null); var formatSpecifiers = Formatter.NoFormatSpecifiers; return new EvalResult( ExpansionKind.TypeVariable, typeParameter.Name, typeDeclaringMemberAndInfo: default(TypeAndCustomInfo), declaredTypeAndInfo: new TypeAndCustomInfo(DkmClrType.Create(value.Type.AppDomain, typeArgument), typeArgumentInfo), useDebuggerDisplay: parent != null, value: value, displayValue: inspectionContext.GetTypeName(DkmClrType.Create(value.Type.AppDomain, typeArgument), typeArgumentInfo, formatSpecifiers), expansion: null, childShouldParenthesize: false, fullName: null, childFullNamePrefixOpt: null, formatSpecifiers: formatSpecifiers, category: DkmEvaluationResultCategory.Data, flags: DkmEvaluationResultFlags.ReadOnly, editableValue: null, inspectionContext: inspectionContext); }
internal override void GetRows( ResultProvider resultProvider, ArrayBuilder <EvalResult> rows, DkmInspectionContext inspectionContext, EvalResultDataItem parent, DkmClrValue value, int startIndex, int count, bool visitAll, ref int index ) { if (InRange(startIndex, count, index)) { rows.Add( GetRow( resultProvider, inspectionContext, new TypeAndCustomInfo(_type), value, _members ) ); } index++; }
private DkmEvaluationResult CreateRawViewRow( ResultProvider resultProvider, DkmInspectionContext inspectionContext) { var dataItem = new EvalResultDataItem( this.name, this.typeDeclaringMemberOpt, _declaredType, this.value, CreateRawView(resultProvider, inspectionContext, _declaredType, this.value), this.childShouldParenthesize, this.fullName, this.childFullNamePrefix, Formatter.AddFormatSpecifier(this.formatSpecifiers, "raw"), DkmEvaluationResultCategory.Data, this.flags | DkmEvaluationResultFlags.ReadOnly, this.editableValue); return(ResultProvider.CreateEvaluationResult( value, Resources.RawView, typeName: "", display: null, dataItem: dataItem)); }
internal override void GetRows( ResultProvider resultProvider, ArrayBuilder <EvalResult> rows, DkmInspectionContext inspectionContext, EvalResultDataItem parent, DkmClrValue value, int startIndex, int count, bool visitAll, ref int index ) { if (_proxyItem != null) { _proxyItem.Expansion.GetRows( resultProvider, rows, inspectionContext, _proxyItem.ToDataItem(), _proxyItem.Value, startIndex, count, visitAll, ref index ); } if (InRange(startIndex, count, index)) { rows.Add(this.CreateRawViewRow(resultProvider, inspectionContext)); } index++; }
private static EvalResult GetRow( DkmInspectionContext inspectionContext, DkmClrValue value, Expansion expansion, EvalResultDataItem parent ) { return(new EvalResult( ExpansionKind.NonPublicMembers, name: Resources.NonPublicMembers, typeDeclaringMemberAndInfo: default(TypeAndCustomInfo), declaredTypeAndInfo: default(TypeAndCustomInfo), useDebuggerDisplay: false, value: value, displayValue: null, expansion: expansion, childShouldParenthesize: parent.ChildShouldParenthesize, fullName: parent.FullNameWithoutFormatSpecifiers, childFullNamePrefixOpt: parent.ChildFullNamePrefix, formatSpecifiers: s_hiddenFormatSpecifiers, category: DkmEvaluationResultCategory.Data, flags: DkmEvaluationResultFlags.ReadOnly, editableValue: null, inspectionContext: inspectionContext )); }
private EvalResult GetRow( ResultProvider resultProvider, DkmInspectionContext inspectionContext, DkmClrValue value, int index, EvalResultDataItem parent) { var indices = GetIndices(index); var fullNameProvider = resultProvider.FullNameProvider; var name = fullNameProvider.GetClrArrayIndexExpression(inspectionContext, indices); var element = value.GetArrayElement(indices, inspectionContext); var fullName = GetFullName(inspectionContext, parent, name, fullNameProvider); return resultProvider.CreateDataItem( inspectionContext, name, typeDeclaringMemberAndInfo: default(TypeAndCustomInfo), declaredTypeAndInfo: _elementTypeAndInfo, value: element, useDebuggerDisplay: parent != null, expansionFlags: ExpansionFlags.IncludeBaseMembers, childShouldParenthesize: false, fullName: fullName, formatSpecifiers: Formatter.NoFormatSpecifiers, category: DkmEvaluationResultCategory.Other, flags: element.EvalFlags, evalFlags: inspectionContext.EvaluationFlags); }
private EvalResult GetRow( DkmInspectionContext inspectionContext, DkmClrValue value, int index, EvalResultDataItem parent) { var typeParameter = _typeParameters[index]; var typeArgument = _typeArguments[index]; var typeArgumentInfo = _customTypeInfoMap.SubstituteCustomTypeInfo(typeParameter, customInfo: null); var formatSpecifiers = Formatter.NoFormatSpecifiers; return(new EvalResult( ExpansionKind.TypeVariable, typeParameter.Name, typeDeclaringMemberAndInfo: default(TypeAndCustomInfo), declaredTypeAndInfo: new TypeAndCustomInfo(DkmClrType.Create(value.Type.AppDomain, typeArgument), typeArgumentInfo), useDebuggerDisplay: parent != null, value: value, displayValue: inspectionContext.GetTypeName(DkmClrType.Create(value.Type.AppDomain, typeArgument), typeArgumentInfo, formatSpecifiers), expansion: null, childShouldParenthesize: false, fullName: null, childFullNamePrefixOpt: null, formatSpecifiers: formatSpecifiers, category: DkmEvaluationResultCategory.Data, flags: DkmEvaluationResultFlags.ReadOnly, editableValue: null, inspectionContext: inspectionContext)); }
internal void GetResultAndContinue(EvalResultDataItem dataItem, DkmWorkList workList, DkmClrType declaredType, DkmInspectionContext inspectionContext, EvalResultDataItem parent, CompletionRoutine <DkmEvaluationResult> completionRoutine) { var value = dataItem.Value; // Value may have been replaced (specifically, for Nullable<T>). DebuggerDisplayInfo displayInfo; if (value.TryGetDebuggerDisplayInfo(out displayInfo)) { var targetType = displayInfo.TargetType; var attribute = displayInfo.Attribute; CompletionRoutine <Exception> onException = e => completionRoutine(CreateEvaluationResultFromException(e, dataItem, inspectionContext)); value.EvaluateDebuggerDisplayStringAndContinue(workList, inspectionContext, targetType, attribute.Name, displayName => ContinueWithExceptionHandling( () => value.EvaluateDebuggerDisplayStringAndContinue(workList, inspectionContext, targetType, attribute.Value, displayValue => ContinueWithExceptionHandling( () => value.EvaluateDebuggerDisplayStringAndContinue(workList, inspectionContext, targetType, attribute.TypeName, displayType => ContinueWithExceptionHandling( () => completionRoutine(GetResult(inspectionContext, dataItem, declaredType, displayName.Result, displayValue.Result, displayType.Result, parent)), onException)), onException)), onException)); } else { completionRoutine(GetResult(inspectionContext, dataItem, declaredType, displayName: null, displayValue: null, displayType: null, parent: parent)); } }
private void GetChildrenAndContinue(EvalResultDataItem dataItem, DkmWorkList workList, DkmStackWalkFrame stackFrame, int initialRequestSize, DkmInspectionContext inspectionContext, DkmCompletionRoutine <DkmGetChildrenAsyncResult> completionRoutine) { var expansion = dataItem.Expansion; var rows = ArrayBuilder <EvalResultDataItem> .GetInstance(); int index = 0; if (expansion != null) { expansion.GetRows(this, rows, inspectionContext, dataItem, dataItem.Value, 0, initialRequestSize, visitAll: true, index: ref index); } var numRows = rows.Count; Debug.Assert(index >= numRows); Debug.Assert(initialRequestSize >= numRows); var initialChildren = new DkmEvaluationResult[numRows]; GetEvaluationResultsAndContinue(rows, initialChildren, 0, numRows, workList, inspectionContext, stackFrame, () => ContinueWithExceptionHandling( () => { var enumContext = DkmEvaluationResultEnumContext.Create(index, stackFrame, inspectionContext, new EnumContextDataItem(dataItem)); completionRoutine(new DkmGetChildrenAsyncResult(initialChildren, enumContext)); rows.Free(); }, e => completionRoutine(DkmGetChildrenAsyncResult.CreateErrorResult(e)))); }
private DkmEvaluationResult GetRow( ResultProvider resultProvider, DkmInspectionContext inspectionContext, DkmClrValue value, int index, EvalResultDataItem parent) { var indices = GetIndices(index); var formatter = resultProvider.Formatter; var name = formatter.GetArrayIndexExpression(indices); var elementType = value.Type.ElementType; var element = value.GetArrayElement(indices); var fullName = GetFullName(parent, name, formatter); var dataItem = resultProvider.CreateDataItem( inspectionContext, name, typeDeclaringMember: null, declaredType: elementType.GetLmrType(), value: element, parent: parent, expansionFlags: ExpansionFlags.IncludeBaseMembers, childShouldParenthesize: false, fullName: fullName, formatSpecifiers: Formatter.NoFormatSpecifiers, category: DkmEvaluationResultCategory.Other, flags: element.EvalFlags, evalFlags: inspectionContext.EvaluationFlags); return resultProvider.GetResult(dataItem, element.Type, elementType, parent); }
private static EvalResultDataItem GetRow( ResultProvider resultProvider, DkmInspectionContext inspectionContext, Type declaredType, DkmClrValue value, Expansion expansion, EvalResultDataItem parent) { return(new EvalResultDataItem( ExpansionKind.NonPublicMembers, name: Resources.NonPublicMembers, typeDeclaringMember: null, declaredType: declaredType, parent: null, value: value, displayValue: null, expansion: expansion, childShouldParenthesize: parent.ChildShouldParenthesize, fullName: parent.FullNameWithoutFormatSpecifiers, childFullNamePrefixOpt: parent.ChildFullNamePrefix, formatSpecifiers: s_hiddenFormatSpecifiers, category: DkmEvaluationResultCategory.Data, flags: DkmEvaluationResultFlags.ReadOnly, editableValue: null, inspectionContext: inspectionContext)); }
private static string GetFullName(DkmInspectionContext inspectionContext, EvalResultDataItem parent, string name, IDkmClrFullNameProvider fullNameProvider) { var parentFullName = parent.ChildFullNamePrefix; if (parentFullName == null) { return(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); if (parentFullName == null) { return(null); // Contains invalid identifier. } } return(parentFullName + name); }
private static DkmEvaluationResult CreateEvaluationResult( DkmInspectionContext inspectionContext, DkmClrValue value, string name, string typeName, string display, EvalResultDataItem dataItem) { if (value.IsError()) { // Evaluation failed return(DkmFailedEvaluationResult.Create( InspectionContext: inspectionContext, StackFrame: value.StackFrame, Name: name, FullName: dataItem.FullName, ErrorMessage: display, Flags: dataItem.Flags, Type: typeName, DataItem: dataItem)); } else { ReadOnlyCollection <DkmCustomUIVisualizerInfo> customUIVisualizers = null; if (!value.IsNull) { DkmCustomUIVisualizerInfo[] customUIVisualizerInfo = value.Type.GetDebuggerCustomUIVisualizerInfo(); if (customUIVisualizerInfo != null) { customUIVisualizers = new ReadOnlyCollection <DkmCustomUIVisualizerInfo>(customUIVisualizerInfo); } } // If the EvalResultData item doesn't specify a particular category, we'll just propagate DkmClrValue.Category, // which typically appears to be set to the default value ("Other"). var category = (dataItem.Category != DkmEvaluationResultCategory.Other) ? dataItem.Category : value.Category; // Valid value return(DkmSuccessEvaluationResult.Create( InspectionContext: inspectionContext, StackFrame: value.StackFrame, Name: name, FullName: dataItem.FullName, Flags: dataItem.Flags, Value: display, EditableValue: dataItem.EditableValue, Type: typeName, Category: category, Access: value.Access, StorageType: value.StorageType, TypeModifierFlags: value.TypeModifierFlags, Address: value.Address, CustomUIVisualizers: customUIVisualizers, ExternalModules: null, DataItem: dataItem)); } }
internal static EvalResult CreateMemberDataItem( ResultProvider resultProvider, DkmInspectionContext inspectionContext, MemberAndDeclarationInfo member, DkmClrValue memberValue, EvalResultDataItem parent, CustomTypeInfoTypeArgumentMap customTypeInfoMap, ExpansionFlags flags, bool supportsFavorites) { var fullNameProvider = resultProvider.FullNameProvider; var declaredType = member.Type; var declaredTypeInfo = customTypeInfoMap.SubstituteCustomTypeInfo(member.OriginalDefinitionType, member.TypeInfo); string memberName; // Considering, we're not handling the case of a member inherited from a generic base type. var typeDeclaringMember = member.GetExplicitlyImplementedInterface(out memberName) ?? member.DeclaringType; var typeDeclaringMemberInfo = typeDeclaringMember.IsInterface ? customTypeInfoMap.SubstituteCustomTypeInfo(typeDeclaringMember.GetInterfaceListEntry(member.DeclaringType), customInfo: null) : null; var memberNameForFullName = fullNameProvider.GetClrValidIdentifier(inspectionContext, memberName); var appDomain = memberValue.Type.AppDomain; string fullName; if (memberNameForFullName == null) { fullName = null; } else { memberName = memberNameForFullName; fullName = MakeFullName( fullNameProvider, inspectionContext, memberNameForFullName, new TypeAndCustomInfo(DkmClrType.Create(appDomain, typeDeclaringMember), typeDeclaringMemberInfo), // Note: Won't include DynamicAttribute. member.RequiresExplicitCast, member.IsStatic, parent); } return(resultProvider.CreateDataItem( inspectionContext, memberName, typeDeclaringMemberAndInfo: (member.IncludeTypeInMemberName || typeDeclaringMember.IsInterface) ? new TypeAndCustomInfo(DkmClrType.Create(appDomain, typeDeclaringMember), typeDeclaringMemberInfo) : default(TypeAndCustomInfo), // Note: Won't include DynamicAttribute. declaredTypeAndInfo: new TypeAndCustomInfo(DkmClrType.Create(appDomain, declaredType), declaredTypeInfo), value: memberValue, useDebuggerDisplay: parent != null, expansionFlags: flags, childShouldParenthesize: false, fullName: fullName, formatSpecifiers: Formatter.NoFormatSpecifiers, category: DkmEvaluationResultCategory.Other, flags: memberValue.EvalFlags, evalFlags: DkmEvaluationFlags.None, canFavorite: member.CanFavorite, isFavorite: member.IsFavorite, supportsFavorites: supportsFavorites)); }
/// <summary> /// Get the rows within the given range. 'index' is advanced /// to the end of the range, or if 'visitAll' is true, 'index' is /// advanced to the end of the expansion. /// </summary> internal abstract void GetRows( ResultProvider resultProvider, ArrayBuilder<DkmEvaluationResult> rows, DkmInspectionContext inspectionContext, EvalResultDataItem parent, DkmClrValue value, int startIndex, int count, bool visitAll, ref int index);
/// <summary> /// Get the rows within the given range. 'index' is advanced /// to the end of the range, or if 'visitAll' is true, 'index' is /// advanced to the end of the expansion. /// </summary> internal abstract void GetRows( ResultProvider resultProvider, ArrayBuilder <EvalResult> rows, DkmInspectionContext inspectionContext, EvalResultDataItem parent, DkmClrValue value, int startIndex, int count, bool visitAll, ref int index);
internal override void GetRows( ResultProvider resultProvider, ArrayBuilder<EvalResult> rows, DkmInspectionContext inspectionContext, EvalResultDataItem parent, DkmClrValue value, int startIndex, int count, bool visitAll, ref int index ) { var fields = GetFields(); var defaultView = fields.DefaultView; int startIndex2; int count2; GetIntersection( startIndex, count, index, defaultView.Count, out startIndex2, out count2 ); int offset = startIndex2 - index; for (int i = 0; i < count2; i++) { var row = GetMemberRow( resultProvider, inspectionContext, value, defaultView[i + offset], parent, _cardinality ); rows.Add(row); } index += defaultView.Count; if (fields.IncludeRawView) { if (InRange(startIndex, count, index)) { rows.Add( this.CreateRawViewRow(resultProvider, inspectionContext, parent, value) ); } index++; } }
private static EvalResult GetRow( ResultProvider resultProvider, DkmInspectionContext inspectionContext, DkmClrValue pointer, TypeAndCustomInfo elementTypeAndInfo, EvalResultDataItem parent ) { var value = pointer.Dereference(inspectionContext); var wasExceptionThrown = value.EvalFlags.Includes( DkmEvaluationResultFlags.ExceptionThrown ); var expansion = wasExceptionThrown ? null : resultProvider.GetTypeExpansion( inspectionContext, elementTypeAndInfo, value, ExpansionFlags.None, supportsFavorites: false ); var parentFullName = parent.ChildFullNamePrefix; var fullName = parentFullName == null ? null : $"*{parentFullName}"; var editableValue = resultProvider.Formatter2.GetEditableValueString( value, inspectionContext, elementTypeAndInfo.Info ); // NB: Full name is based on the real (i.e. not DebuggerDisplay) name. This is a change from dev12, // which used the DebuggerDisplay name, causing surprising results in "Add Watch" scenarios. return(new EvalResult( ExpansionKind.PointerDereference, name: fullName ?? $"*{parent.Name}", typeDeclaringMemberAndInfo: default(TypeAndCustomInfo), declaredTypeAndInfo: elementTypeAndInfo, useDebuggerDisplay: false, value: value, displayValue: wasExceptionThrown ? string.Format(Resources.InvalidPointerDereference, fullName ?? parent.Name) : null, expansion: expansion, childShouldParenthesize: true, fullName: fullName, childFullNamePrefixOpt: fullName, formatSpecifiers: Formatter.NoFormatSpecifiers, category: DkmEvaluationResultCategory.Other, flags: DkmEvaluationResultFlags.None, editableValue: editableValue, inspectionContext: inspectionContext )); }
private static DkmEvaluationResult GetRow( ResultProvider resultProvider, DkmInspectionContext inspectionContext, DkmClrValue pointer, Type elementType, EvalResultDataItem parent) { var value = pointer.Dereference(); var valueType = value.Type.GetLmrType(); var wasExceptionThrown = value.EvalFlags.Includes(DkmEvaluationResultFlags.ExceptionThrown); string debuggerDisplayName; string debuggerDisplayValue; string debuggerDisplayType; value.GetDebuggerDisplayStrings(out debuggerDisplayName, out debuggerDisplayValue, out debuggerDisplayType); var declaredType = elementType; var typeName = debuggerDisplayType ?? pointer.InspectionContext.GetTypeName(DkmClrType.Create(pointer.Type.AppDomain, declaredType)); var expansion = wasExceptionThrown ? null : resultProvider.GetTypeExpansion(inspectionContext, declaredType, value, ExpansionFlags.None); var fullName = string.Format("*{0}", parent.ChildFullNamePrefix); var editableValue = resultProvider.Formatter.GetEditableValue(value); // NB: Full name is based on the real (i.e. not DebuggerDisplay) name. This is a change from dev12, // which used the DebuggerDisplay name, causing surprising results in "Add Watch" scenarios. var dataItem = new EvalResultDataItem( name: null, // Okay for pointer dereferences. typeDeclaringMember: null, declaredType: declaredType, value: value, expansion: expansion, childShouldParenthesize: true, fullName: fullName, childFullNamePrefixOpt: fullName, formatSpecifiers: Formatter.NoFormatSpecifiers, category: DkmEvaluationResultCategory.Other, flags: DkmEvaluationResultFlags.None, editableValue: editableValue); var name = debuggerDisplayName ?? fullName; var display = debuggerDisplayValue ?? (wasExceptionThrown ? string.Format(Resources.InvalidPointerDereference, fullName) : value.GetValueString()); return(ResultProvider.CreateEvaluationResult( value, name, typeName, display, dataItem)); }
internal override void GetRows( ResultProvider resultProvider, ArrayBuilder <EvalResultDataItem> rows, DkmInspectionContext inspectionContext, EvalResultDataItem parent, DkmClrValue value, int startIndex, int count, bool visitAll, ref int index) { _expansion.GetRows(resultProvider, rows, inspectionContext, parent, _proxyValue, startIndex, count, visitAll, ref index); }
private static DkmEvaluationResult GetRow( ResultProvider resultProvider, DkmInspectionContext inspectionContext, DkmClrValue pointer, Type elementType, EvalResultDataItem parent) { var value = pointer.Dereference(); var valueType = value.Type.GetLmrType(); var wasExceptionThrown = value.EvalFlags.Includes(DkmEvaluationResultFlags.ExceptionThrown); string debuggerDisplayName; string debuggerDisplayValue; string debuggerDisplayType; value.GetDebuggerDisplayStrings(out debuggerDisplayName, out debuggerDisplayValue, out debuggerDisplayType); var declaredType = elementType; var typeName = debuggerDisplayType ?? pointer.InspectionContext.GetTypeName(DkmClrType.Create(pointer.Type.AppDomain, declaredType)); var expansion = wasExceptionThrown ? null : resultProvider.GetTypeExpansion(inspectionContext, declaredType, value, ExpansionFlags.None); var fullName = string.Format("*{0}", parent.ChildFullNamePrefix); var editableValue = resultProvider.Formatter.GetEditableValue(value); // NB: Full name is based on the real (i.e. not DebuggerDisplay) name. This is a change from dev12, // which used the DebuggerDisplay name, causing surprising results in "Add Watch" scenarios. var dataItem = new EvalResultDataItem( name: null, // Okay for pointer dereferences. typeDeclaringMember: null, declaredType: declaredType, value: value, expansion: expansion, childShouldParenthesize: true, fullName: fullName, childFullNamePrefixOpt: fullName, formatSpecifiers: Formatter.NoFormatSpecifiers, category: DkmEvaluationResultCategory.Other, flags: DkmEvaluationResultFlags.None, editableValue: editableValue); var name = debuggerDisplayName ?? fullName; var display = debuggerDisplayValue ?? (wasExceptionThrown ? string.Format(Resources.InvalidPointerDereference, fullName) : value.GetValueString()); return ResultProvider.CreateEvaluationResult( value, name, typeName, display, dataItem); }
private static EvalResult GetMemberRow( ResultProvider resultProvider, DkmInspectionContext inspectionContext, DkmClrValue value, Field field, EvalResultDataItem parent) { 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); return(resultProvider.CreateDataItem( inspectionContext, field.Name, typeDeclaringMemberAndInfo: default(TypeAndCustomInfo), declaredTypeAndInfo: field.FieldTypeAndInfo, value: fieldValue, useDebuggerDisplay: false, expansionFlags: ExpansionFlags.All, childShouldParenthesize: false, fullName: fullName, formatSpecifiers: Formatter.NoFormatSpecifiers, category: DkmEvaluationResultCategory.Other, flags: fieldValue.EvalFlags, evalFlags: DkmEvaluationFlags.None)); }
private static EvalResult GetMemberRow( ResultProvider resultProvider, DkmInspectionContext inspectionContext, DkmClrValue value, Field field, EvalResultDataItem parent) { 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); return resultProvider.CreateDataItem( inspectionContext, field.Name, typeDeclaringMemberAndInfo: default(TypeAndCustomInfo), declaredTypeAndInfo: field.FieldTypeAndInfo, value: fieldValue, useDebuggerDisplay: false, expansionFlags: ExpansionFlags.All, childShouldParenthesize: false, fullName: fullName, formatSpecifiers: Formatter.NoFormatSpecifiers, category: DkmEvaluationResultCategory.Other, flags: fieldValue.EvalFlags, evalFlags: DkmEvaluationFlags.None); }
private static string MakeFullName( IDkmClrFullNameProvider fullNameProvider, DkmInspectionContext inspectionContext, string name, TypeAndCustomInfo typeDeclaringMemberAndInfo, bool memberAccessRequiresExplicitCast, bool memberIsStatic, EvalResultDataItem parent ) { // If the parent is an exception thrown during evaluation, // there is no valid fullname expression for the child. if (parent.Value.EvalFlags.Includes(DkmEvaluationResultFlags.ExceptionThrown)) { return(null); } var parentFullName = parent.ChildFullNamePrefix; if (parentFullName == null) { return(null); } if (parent.ChildShouldParenthesize) { parentFullName = parentFullName.Parenthesize(); } var typeDeclaringMember = typeDeclaringMemberAndInfo.Type; if (typeDeclaringMember.IsInterface) { memberAccessRequiresExplicitCast = !typeDeclaringMember.Equals( parent.DeclaredTypeAndInfo.Type ); } return(fullNameProvider.GetClrMemberName( inspectionContext, parentFullName, typeDeclaringMemberAndInfo.ClrType, typeDeclaringMemberAndInfo.Info, name, memberAccessRequiresExplicitCast, memberIsStatic )); }
internal static DkmEvaluationResult CreateResultsOnly( string name, DkmClrType declaredType, DkmClrValue value, EvalResultDataItem parent, Formatter formatter) { string errorMessage; if (value.IsError()) { errorMessage = (string)value.HostObjectValue; } else if (value.HasExceptionThrown(parent)) { errorMessage = value.GetExceptionMessage(name, formatter); } else { var enumerableType = GetEnumerableType(value); if (enumerableType != null) { var expansion = CreateExpansion(value, enumerableType, formatter); if (expansion != null) { return expansion.CreateEvaluationResult(name, parent, formatter); } errorMessage = Resources.ResultsViewNoSystemCore; } else { errorMessage = Resources.ResultsViewNotEnumerable; } } Debug.Assert(errorMessage != null); return DkmFailedEvaluationResult.Create( InspectionContext: value.InspectionContext, StackFrame: value.StackFrame, Name: name, FullName: null, ErrorMessage: errorMessage, Flags: DkmEvaluationResultFlags.None, Type: null, DataItem: null); }
internal override void GetRows( ResultProvider resultProvider, ArrayBuilder<EvalResult> rows, DkmInspectionContext inspectionContext, EvalResultDataItem parent, DkmClrValue value, int startIndex, int count, bool visitAll, ref int index) { if (InRange(startIndex, count, index)) { rows.Add(CreateDynamicViewRow(inspectionContext, Resources.DynamicView, parent, resultProvider.FullNameProvider)); } index++; }
internal override void GetRows( ResultProvider resultProvider, ArrayBuilder<EvalResultDataItem> rows, DkmInspectionContext inspectionContext, EvalResultDataItem parent, DkmClrValue value, int startIndex, int count, bool visitAll, ref int index) { if (InRange(startIndex, count, index)) { rows.Add(GetRow(resultProvider, inspectionContext, value, _elementTypeAndInfo, parent: parent)); } index++; }
internal override void GetRows( ResultProvider resultProvider, ArrayBuilder<EvalResult> rows, DkmInspectionContext inspectionContext, EvalResultDataItem parent, DkmClrValue value, int startIndex, int count, bool visitAll, ref int index) { var memberValue = value.GetMemberValue(_member, inspectionContext); var isDynamicDebugViewEmptyException = memberValue.Type.GetLmrType().IsDynamicDebugViewEmptyException(); if (isDynamicDebugViewEmptyException || memberValue.IsError()) { if (InRange(startIndex, count, index)) { if (isDynamicDebugViewEmptyException) { var emptyMember = memberValue.Type.GetMemberByName("Empty"); memberValue = memberValue.GetMemberValue(emptyMember, inspectionContext); } var row = new EvalResult(Resources.ErrorName, (string)memberValue.HostObjectValue, inspectionContext); rows.Add(row); } index++; } else { var other = MemberExpansion.CreateMemberDataItem( resultProvider, inspectionContext, _member, memberValue, parent, _dynamicFlagsMap, ExpansionFlags.IncludeBaseMembers | ExpansionFlags.IncludeResultsView); var expansion = other.Expansion; if (expansion != null) { expansion.GetRows(resultProvider, rows, inspectionContext, other.ToDataItem(), other.Value, startIndex, count, visitAll, ref index); } } }
internal override void GetRows( ResultProvider resultProvider, ArrayBuilder<EvalResultDataItem> rows, DkmInspectionContext inspectionContext, EvalResultDataItem parent, DkmClrValue value, int startIndex, int count, bool visitAll, ref int index) { foreach (var expansion in _expansions) { expansion.GetRows(resultProvider, rows, inspectionContext, parent, value, startIndex, count, visitAll, ref index); if (!visitAll && (index >= startIndex + count)) { return; } } }
private DkmEvaluationResult GetRow(ResultProvider resultProvider, DkmClrValue value, int index, EvalResultDataItem parent) { var inspectionContext = value.InspectionContext; var appDomain = value.Type.AppDomain; var typeParameter = _typeParameters[index]; var typeArgument = _typeArguments[index]; var type = DkmClrType.Create(appDomain, typeArgument); var name = typeParameter.Name; var dataItem = new EvalResultDataItem( name, typeDeclaringMember: null, declaredType: typeArgument, value: null, expansion: null, childShouldParenthesize: false, fullName: null, childFullNamePrefixOpt: null, formatSpecifiers: Formatter.NoFormatSpecifiers, category: DkmEvaluationResultCategory.Data, flags: DkmEvaluationResultFlags.ReadOnly, editableValue: null); var typeName = inspectionContext.GetTypeName(DkmClrType.Create(appDomain, typeArgument)); return DkmSuccessEvaluationResult.Create( inspectionContext, value.StackFrame, name, dataItem.FullName, dataItem.Flags, Value: typeName, EditableValue: null, Type: typeName, Category: dataItem.Category, Access: value.Access, StorageType: value.StorageType, TypeModifierFlags: value.TypeModifierFlags, Address: value.Address, CustomUIVisualizers: null, ExternalModules: null, DataItem: dataItem); }
internal override void GetRows( ResultProvider resultProvider, ArrayBuilder<EvalResult> rows, DkmInspectionContext inspectionContext, EvalResultDataItem parent, DkmClrValue value, int startIndex, int count, bool visitAll, ref int index) { int startIndex2; int count2; GetIntersection(startIndex, count, index, _count, out startIndex2, out count2); int offset = startIndex2 - index; for (int i = 0; i < count2; i++) { rows.Add(GetRow(resultProvider, inspectionContext, value, i + offset, parent)); } index += _count; }
private static EvalResultDataItem GetRow( ResultProvider resultProvider, DkmInspectionContext inspectionContext, DkmClrValue pointer, TypeAndCustomInfo elementTypeAndInfo, EvalResultDataItem parent) { var value = pointer.Dereference(inspectionContext); var wasExceptionThrown = value.EvalFlags.Includes(DkmEvaluationResultFlags.ExceptionThrown); var expansion = wasExceptionThrown ? null : resultProvider.GetTypeExpansion(inspectionContext, elementTypeAndInfo, value, ExpansionFlags.None); var parentFullName = parent.ChildFullNamePrefix; var fullName = parentFullName == null ? null : $"*{parentFullName}"; var editableValue = resultProvider.Formatter.GetEditableValue(value, inspectionContext); // NB: Full name is based on the real (i.e. not DebuggerDisplay) name. This is a change from dev12, // which used the DebuggerDisplay name, causing surprising results in "Add Watch" scenarios. return new EvalResultDataItem( ExpansionKind.PointerDereference, name: fullName ?? $"*{parent.Name}", typeDeclaringMemberAndInfo: default(TypeAndCustomInfo), declaredTypeAndInfo: elementTypeAndInfo, parent: null, value: value, displayValue: wasExceptionThrown ? string.Format(Resources.InvalidPointerDereference, fullName ?? parent.Name) : null, expansion: expansion, childShouldParenthesize: true, fullName: fullName, childFullNamePrefixOpt: fullName, formatSpecifiers: Formatter.NoFormatSpecifiers, category: DkmEvaluationResultCategory.Other, flags: DkmEvaluationResultFlags.None, editableValue: editableValue, inspectionContext: inspectionContext); }
internal override void GetRows( ResultProvider resultProvider, ArrayBuilder<EvalResult> rows, DkmInspectionContext inspectionContext, EvalResultDataItem parent, DkmClrValue value, int startIndex, int count, bool visitAll, ref int index) { var fields = GetFields(); var defaultView = fields.DefaultView; int startIndex2; int count2; GetIntersection(startIndex, count, index, defaultView.Count, out startIndex2, out count2); int offset = startIndex2 - index; for (int i = 0; i < count2; i++) { var row = GetMemberRow(resultProvider, inspectionContext, value, defaultView[i + offset], parent, _cardinality); rows.Add(row); } index += defaultView.Count; if (fields.IncludeRawView) { if (InRange(startIndex, count, index)) { rows.Add(this.CreateRawViewRow(resultProvider, inspectionContext, parent, value)); } index++; } }
private EvalResultDataItem GetRow( ResultProvider resultProvider, DkmInspectionContext inspectionContext, DkmClrValue comObject, EvalResultDataItem parent) { try { inspectionContext.RuntimeInstance.Process.GetNativeRuntimeInstance(); } catch (DkmException) { // Native View requires native debugging to be enabled. return new EvalResultDataItem(Resources.NativeView, Resources.NativeViewNotNativeDebugging); } var name = "(IUnknown*)0x" + string.Format(IntPtr.Size == 4 ? "{0:x8}" : "{0:x16}", comObject.NativeComPointer); var fullName = "{C++}" + name; return new EvalResultDataItem( ExpansionKind.NativeView, name: name, typeDeclaringMemberAndInfo: default(TypeAndCustomInfo), declaredTypeAndInfo: new TypeAndCustomInfo(comObject.Type), // DkmClrValue types don't have attributes. parent: null, value: comObject, displayValue: null, expansion: this, childShouldParenthesize: false, fullName: fullName, childFullNamePrefixOpt: fullName, formatSpecifiers: Formatter.NoFormatSpecifiers, category: DkmEvaluationResultCategory.Data, flags: DkmEvaluationResultFlags.ReadOnly, editableValue: null, inspectionContext: inspectionContext); }
private static string MakeFullName( IDkmClrFullNameProvider fullNameProvider, DkmInspectionContext inspectionContext, string name, TypeAndCustomInfo typeDeclaringMemberAndInfo, bool memberAccessRequiresExplicitCast, bool memberIsStatic, EvalResultDataItem parent) { // If the parent is an exception thrown during evaluation, // there is no valid fullname expression for the child. if (parent.Value.EvalFlags.Includes(DkmEvaluationResultFlags.ExceptionThrown)) { return null; } var parentFullName = parent.ChildFullNamePrefix; if (parentFullName == null) { return null; } if (parent.ChildShouldParenthesize) { parentFullName = parentFullName.Parenthesize(); } var typeDeclaringMember = typeDeclaringMemberAndInfo.Type; if (typeDeclaringMember.IsInterface) { memberAccessRequiresExplicitCast = !typeDeclaringMember.Equals(parent.DeclaredTypeAndInfo.Type); } return fullNameProvider.GetClrMemberName( inspectionContext, parentFullName, typeDeclaringMemberAndInfo.ClrType, typeDeclaringMemberAndInfo.Info, name, memberAccessRequiresExplicitCast, memberIsStatic); }
private void GetRootResultAndContinue( DkmClrValue value, WorkList workList, DkmClrType declaredType, DkmClrCustomTypeInfo declaredTypeInfo, DkmInspectionContext inspectionContext, string name, CompletionRoutine<DkmEvaluationResult> completionRoutine) { var type = value.Type.GetLmrType(); if (type.IsTypeVariables()) { Debug.Assert(type.Equals(declaredType.GetLmrType())); var declaredTypeAndInfo = new TypeAndCustomInfo(type, declaredTypeInfo); var expansion = new TypeVariablesExpansion(declaredTypeAndInfo); var dataItem = new EvalResultDataItem( ExpansionKind.Default, name, typeDeclaringMemberAndInfo: default(TypeAndCustomInfo), declaredTypeAndInfo: declaredTypeAndInfo, parent: null, value: value, displayValue: null, expansion: expansion, childShouldParenthesize: false, fullName: null, childFullNamePrefixOpt: null, formatSpecifiers: Formatter.NoFormatSpecifiers, category: DkmEvaluationResultCategory.Data, flags: DkmEvaluationResultFlags.ReadOnly, editableValue: null, inspectionContext: inspectionContext); Debug.Assert(dataItem.Flags == (DkmEvaluationResultFlags.ReadOnly | DkmEvaluationResultFlags.Expandable)); // Note: We're not including value.EvalFlags in Flags parameter // below (there shouldn't be a reason to do so). completionRoutine(DkmSuccessEvaluationResult.Create( InspectionContext: inspectionContext, StackFrame: value.StackFrame, Name: Resources.TypeVariablesName, FullName: dataItem.FullName, Flags: dataItem.Flags, Value: "", EditableValue: null, Type: "", Category: dataItem.Category, Access: value.Access, StorageType: value.StorageType, TypeModifierFlags: value.TypeModifierFlags, Address: value.Address, CustomUIVisualizers: null, ExternalModules: null, DataItem: dataItem)); } else if ((inspectionContext.EvaluationFlags & DkmEvaluationFlags.ResultsOnly) != 0) { var dataItem = ResultsViewExpansion.CreateResultsOnlyRow( inspectionContext, name, declaredType, declaredTypeInfo, value, this.Formatter); CreateEvaluationResultAndContinue( dataItem, workList, inspectionContext, value.StackFrame, completionRoutine); } else if ((inspectionContext.EvaluationFlags & DkmEvaluationFlags.DynamicView) != 0) { var dataItem = DynamicViewExpansion.CreateMembersOnlyRow( inspectionContext, name, value, this.Formatter); CreateEvaluationResultAndContinue( dataItem, workList, inspectionContext, value.StackFrame, completionRoutine); } else { var dataItem = ResultsViewExpansion.CreateResultsOnlyRowIfSynthesizedEnumerable( inspectionContext, name, declaredType, declaredTypeInfo, value, this.Formatter); if (dataItem != null) { CreateEvaluationResultAndContinue( dataItem, workList, inspectionContext, value.StackFrame, completionRoutine); } else { ReadOnlyCollection<string> formatSpecifiers; var fullName = this.Formatter.TrimAndGetFormatSpecifiers(name, out formatSpecifiers); dataItem = CreateDataItem( inspectionContext, name, typeDeclaringMemberAndInfo: default(TypeAndCustomInfo), declaredTypeAndInfo: new TypeAndCustomInfo(declaredType.GetLmrType(), declaredTypeInfo), value: value, parent: null, expansionFlags: ExpansionFlags.All, childShouldParenthesize: this.Formatter.NeedsParentheses(fullName), fullName: fullName, formatSpecifiers: formatSpecifiers, category: DkmEvaluationResultCategory.Other, flags: value.EvalFlags, evalFlags: inspectionContext.EvaluationFlags); GetResultAndContinue(dataItem, workList, declaredType, declaredTypeInfo, inspectionContext, parent: null, completionRoutine: completionRoutine); } } }
private EvalResult CreateDynamicViewRow(DkmInspectionContext inspectionContext, string name, EvalResultDataItem parent, IDkmClrFullNameProvider fullNameProvider) { var proxyTypeAndInfo = new TypeAndCustomInfo(_proxyValue.Type); var isRootExpression = parent == null; var fullName = isRootExpression ? name : parent.ChildFullNamePrefix; var childFullNamePrefix = (fullName == null) ? null : fullNameProvider.GetClrObjectCreationExpression(inspectionContext, proxyTypeAndInfo.ClrType, proxyTypeAndInfo.Info, fullName); var formatSpecifiers = isRootExpression ? Formatter.NoFormatSpecifiers : parent.FormatSpecifiers; return new EvalResult( ExpansionKind.DynamicView, name, typeDeclaringMemberAndInfo: default(TypeAndCustomInfo), declaredTypeAndInfo: proxyTypeAndInfo, useDebuggerDisplay: false, value: _proxyValue, displayValue: Resources.DynamicViewValueWarning, expansion: _proxyMembers, childShouldParenthesize: false, fullName: fullName, childFullNamePrefixOpt: childFullNamePrefix, formatSpecifiers: Formatter.AddFormatSpecifier(formatSpecifiers, DynamicFormatSpecifier), category: DkmEvaluationResultCategory.Method, flags: DkmEvaluationResultFlags.ReadOnly, editableValue: null, inspectionContext: inspectionContext); }
/// <remarks> /// Only <see cref="ExpressionEvaluator.EvalResultDataItem"/> is expected to instantiate this type. /// </remarks> public EnumContextDataItem(EvalResultDataItem dataItem) { this.EvalResultDataItem = dataItem; }
private static DkmEvaluationResult CreateEvaluationResultFromException(Exception e, EvalResultDataItem dataItem, DkmInspectionContext inspectionContext) { return DkmFailedEvaluationResult.Create( inspectionContext, dataItem.Value.StackFrame, Name: dataItem.Name, FullName: null, ErrorMessage: e.Message, Flags: DkmEvaluationResultFlags.None, Type: null, DataItem: null); }
private void CreateEvaluationResultAndContinue(EvalResultDataItem dataItem, WorkList workList, DkmInspectionContext inspectionContext, DkmStackWalkFrame stackFrame, CompletionRoutine<DkmEvaluationResult> completionRoutine) { switch (dataItem.Kind) { case ExpansionKind.Error: completionRoutine(DkmFailedEvaluationResult.Create( inspectionContext, StackFrame: stackFrame, Name: dataItem.Name, FullName: dataItem.FullName, ErrorMessage: dataItem.DisplayValue, Flags: DkmEvaluationResultFlags.None, Type: null, DataItem: null)); break; case ExpansionKind.NativeView: { var value = dataItem.Value; var name = Resources.NativeView; var fullName = dataItem.FullName; var display = dataItem.Name; DkmEvaluationResult evalResult; if (value.IsError()) { evalResult = DkmFailedEvaluationResult.Create( inspectionContext, stackFrame, Name: name, FullName: fullName, ErrorMessage: display, Flags: dataItem.Flags, Type: null, DataItem: dataItem); } else { // For Native View, create a DkmIntermediateEvaluationResult. // This will allow the C++ EE to take over expansion. var process = inspectionContext.RuntimeInstance.Process; var cpp = process.EngineSettings.GetLanguage(new DkmCompilerId(DkmVendorId.Microsoft, DkmLanguageId.Cpp)); evalResult = DkmIntermediateEvaluationResult.Create( inspectionContext, stackFrame, Name: name, FullName: fullName, Expression: display, IntermediateLanguage: cpp, TargetRuntime: process.GetNativeRuntimeInstance(), DataItem: dataItem); } completionRoutine(evalResult); } break; case ExpansionKind.NonPublicMembers: completionRoutine(DkmSuccessEvaluationResult.Create( inspectionContext, stackFrame, Name: Resources.NonPublicMembers, FullName: dataItem.FullName, Flags: dataItem.Flags, Value: null, EditableValue: null, Type: string.Empty, Category: DkmEvaluationResultCategory.Data, Access: DkmEvaluationResultAccessType.None, StorageType: DkmEvaluationResultStorageType.None, TypeModifierFlags: DkmEvaluationResultTypeModifierFlags.None, Address: dataItem.Value.Address, CustomUIVisualizers: null, ExternalModules: null, DataItem: dataItem)); break; case ExpansionKind.StaticMembers: completionRoutine(DkmSuccessEvaluationResult.Create( inspectionContext, stackFrame, Name: Formatter.StaticMembersString, FullName: dataItem.FullName, Flags: dataItem.Flags, Value: null, EditableValue: null, Type: string.Empty, Category: DkmEvaluationResultCategory.Class, Access: DkmEvaluationResultAccessType.None, StorageType: DkmEvaluationResultStorageType.None, TypeModifierFlags: DkmEvaluationResultTypeModifierFlags.None, Address: dataItem.Value.Address, CustomUIVisualizers: null, ExternalModules: null, DataItem: dataItem)); break; case ExpansionKind.RawView: completionRoutine(DkmSuccessEvaluationResult.Create( inspectionContext, stackFrame, Name: Resources.RawView, FullName: dataItem.FullName, Flags: dataItem.Flags, Value: null, EditableValue: dataItem.EditableValue, Type: string.Empty, Category: DkmEvaluationResultCategory.Data, Access: DkmEvaluationResultAccessType.None, StorageType: DkmEvaluationResultStorageType.None, TypeModifierFlags: DkmEvaluationResultTypeModifierFlags.None, Address: dataItem.Value.Address, CustomUIVisualizers: null, ExternalModules: null, DataItem: dataItem)); break; case ExpansionKind.DynamicView: case ExpansionKind.ResultsView: completionRoutine(DkmSuccessEvaluationResult.Create( inspectionContext, stackFrame, dataItem.Name, dataItem.FullName, dataItem.Flags, dataItem.DisplayValue, EditableValue: null, Type: string.Empty, Category: DkmEvaluationResultCategory.Method, Access: DkmEvaluationResultAccessType.None, StorageType: DkmEvaluationResultStorageType.None, TypeModifierFlags: DkmEvaluationResultTypeModifierFlags.None, Address: dataItem.Value.Address, CustomUIVisualizers: null, ExternalModules: null, DataItem: dataItem)); break; case ExpansionKind.TypeVariable: completionRoutine(DkmSuccessEvaluationResult.Create( inspectionContext, stackFrame, dataItem.Name, dataItem.FullName, dataItem.Flags, dataItem.DisplayValue, EditableValue: null, Type: dataItem.DisplayValue, Category: DkmEvaluationResultCategory.Data, Access: DkmEvaluationResultAccessType.None, StorageType: DkmEvaluationResultStorageType.None, TypeModifierFlags: DkmEvaluationResultTypeModifierFlags.None, Address: dataItem.Value.Address, CustomUIVisualizers: null, ExternalModules: null, DataItem: dataItem)); break; case ExpansionKind.PointerDereference: case ExpansionKind.Default: // This call will evaluate DebuggerDisplayAttributes. GetResultAndContinue( dataItem, workList, declaredType: DkmClrType.Create(dataItem.Value.Type.AppDomain, dataItem.DeclaredTypeAndInfo.Type), declaredTypeInfo: dataItem.DeclaredTypeAndInfo.Info, inspectionContext: inspectionContext, parent: dataItem.Parent, completionRoutine: completionRoutine); break; default: throw ExceptionUtilities.UnexpectedValue(dataItem.Kind); } }
private void GetChildrenAndContinue(EvalResultDataItem dataItem, DkmWorkList workList, DkmStackWalkFrame stackFrame, int initialRequestSize, DkmInspectionContext inspectionContext, DkmCompletionRoutine<DkmGetChildrenAsyncResult> completionRoutine) { var expansion = dataItem.Expansion; var rows = ArrayBuilder<EvalResultDataItem>.GetInstance(); int index = 0; if (expansion != null) { expansion.GetRows(this, rows, inspectionContext, dataItem, dataItem.Value, 0, initialRequestSize, visitAll: true, index: ref index); } var numRows = rows.Count; Debug.Assert(index >= numRows); Debug.Assert(initialRequestSize >= numRows); var initialChildren = new DkmEvaluationResult[numRows]; var wl = new WorkList(workList, e => completionRoutine(DkmGetChildrenAsyncResult.CreateErrorResult(e))); GetEvaluationResultsAndContinue(rows, initialChildren, 0, numRows, wl, inspectionContext, stackFrame, () => wl.ContinueWith( () => { var enumContext = DkmEvaluationResultEnumContext.Create(index, stackFrame, inspectionContext, new EnumContextDataItem(dataItem)); completionRoutine(new DkmGetChildrenAsyncResult(initialChildren, enumContext)); rows.Free(); })); wl.Execute(); }
private void GetItemsAndContinue(EvalResultDataItem dataItem, DkmWorkList workList, int startIndex, int count, DkmInspectionContext inspectionContext, DkmCompletionRoutine<DkmEvaluationEnumAsyncResult> completionRoutine) { var expansion = dataItem.Expansion; var value = dataItem.Value; var rows = ArrayBuilder<EvalResultDataItem>.GetInstance(); if (expansion != null) { int index = 0; expansion.GetRows(this, rows, inspectionContext, dataItem, value, startIndex, count, visitAll: false, index: ref index); } var numRows = rows.Count; Debug.Assert(count >= numRows); var results = new DkmEvaluationResult[numRows]; var wl = new WorkList(workList, e => completionRoutine(DkmEvaluationEnumAsyncResult.CreateErrorResult(e))); GetEvaluationResultsAndContinue(rows, results, 0, numRows, wl, inspectionContext, value.StackFrame, () => wl.ContinueWith( () => { completionRoutine(new DkmEvaluationEnumAsyncResult(results)); rows.Free(); })); wl.Execute(); }
private DkmEvaluationResult GetResult( DkmInspectionContext inspectionContext, EvalResultDataItem dataItem, DkmClrType declaredType, DkmClrCustomTypeInfo declaredTypeInfo, string displayName, string displayValue, string displayType, EvalResultDataItem parent) { var name = dataItem.Name; Debug.Assert(name != null); var typeDeclaringMemberAndInfo = dataItem.TypeDeclaringMemberAndInfo; // Note: Don't respect the debugger display name on the root element: // 1) In the Watch window, that's where the user's text goes. // 2) In the Locals window, that's where the local name goes. // Note: Dev12 respects the debugger display name in the Locals window, // but not in the Watch window, but we can't distinguish and this // behavior seems reasonable. if (displayName != null && parent != null) { name = displayName; } else if (typeDeclaringMemberAndInfo.Type != null) { bool unused; if (typeDeclaringMemberAndInfo.Type.IsInterface) { var interfaceTypeName = this.Formatter.GetTypeName(typeDeclaringMemberAndInfo, escapeKeywordIdentifiers: true, sawInvalidIdentifier: out unused); name = string.Format("{0}.{1}", interfaceTypeName, name); } else { var pooled = PooledStringBuilder.GetInstance(); var builder = pooled.Builder; builder.Append(name); builder.Append(" ("); builder.Append(this.Formatter.GetTypeName(typeDeclaringMemberAndInfo, escapeKeywordIdentifiers: false, sawInvalidIdentifier: out unused)); builder.Append(')'); name = pooled.ToStringAndFree(); } } var value = dataItem.Value; string display; if (value.HasExceptionThrown()) { display = dataItem.DisplayValue ?? value.GetExceptionMessage(dataItem.FullNameWithoutFormatSpecifiers ?? dataItem.Name, this.Formatter); } else if (displayValue != null) { display = value.IncludeObjectId(displayValue); } else { display = value.GetValueString(inspectionContext, Formatter.NoFormatSpecifiers); } var typeName = displayType ?? GetTypeName(inspectionContext, value, declaredType, declaredTypeInfo, dataItem.Kind); return CreateEvaluationResult(inspectionContext, value, name, typeName, display, dataItem); }
private void GetResultAndContinue( EvalResultDataItem dataItem, WorkList workList, DkmClrType declaredType, DkmClrCustomTypeInfo declaredTypeInfo, DkmInspectionContext inspectionContext, EvalResultDataItem parent, CompletionRoutine<DkmEvaluationResult> completionRoutine) { var value = dataItem.Value; // Value may have been replaced (specifically, for Nullable<T>). DebuggerDisplayInfo displayInfo; if (value.TryGetDebuggerDisplayInfo(out displayInfo)) { var targetType = displayInfo.TargetType; var attribute = displayInfo.Attribute; CompletionRoutine<Exception> onException = e => completionRoutine(CreateEvaluationResultFromException(e, dataItem, inspectionContext)); EvaluateDebuggerDisplayStringAndContinue(value, workList, inspectionContext, targetType, attribute.Name, displayName => EvaluateDebuggerDisplayStringAndContinue(value, workList, inspectionContext, targetType, attribute.Value, displayValue => EvaluateDebuggerDisplayStringAndContinue(value, workList, inspectionContext, targetType, attribute.TypeName, displayType => { completionRoutine(GetResult(inspectionContext, dataItem, declaredType, declaredTypeInfo, displayName.Result, displayValue.Result, displayType.Result, parent)); }, onException), onException), onException); } else { completionRoutine(GetResult(inspectionContext, dataItem, declaredType, declaredTypeInfo, displayName: null, displayValue: null, displayType: null, parent: parent)); } }
private static string GetFullName(DkmInspectionContext inspectionContext, EvalResultDataItem parent, string name, IDkmClrFullNameProvider fullNameProvider) { var parentFullName = parent.ChildFullNamePrefix; if (parentFullName == null) { return 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); if (parentFullName == null) { return null; // Contains invalid identifier. } } return parentFullName + name; }
internal EvalResultDataItem CreateDataItem( DkmInspectionContext inspectionContext, string name, TypeAndCustomInfo typeDeclaringMemberAndInfo, TypeAndCustomInfo declaredTypeAndInfo, DkmClrValue value, EvalResultDataItem parent, ExpansionFlags expansionFlags, bool childShouldParenthesize, string fullName, ReadOnlyCollection<string> formatSpecifiers, DkmEvaluationResultCategory category, DkmEvaluationResultFlags flags, DkmEvaluationFlags evalFlags) { if ((evalFlags & DkmEvaluationFlags.ShowValueRaw) != 0) { formatSpecifiers = Formatter.AddFormatSpecifier(formatSpecifiers, "raw"); } Expansion expansion; // If the declared type is Nullable<T>, the value should // have no expansion if null, or be expanded as a T. var declaredType = declaredTypeAndInfo.Type; var lmrNullableTypeArg = declaredType.GetNullableTypeArgument(); if (lmrNullableTypeArg != null && !value.HasExceptionThrown()) { Debug.Assert(value.Type.GetProxyType() == null); DkmClrValue nullableValue; if (value.IsError()) { expansion = null; } else if ((nullableValue = value.GetNullableValue(inspectionContext)) == null) { Debug.Assert(declaredType.Equals(value.Type.GetLmrType())); // No expansion of "null". expansion = null; } else { value = nullableValue; Debug.Assert(lmrNullableTypeArg.Equals(value.Type.GetLmrType())); // If this is not the case, add a test for includeRuntimeTypeIfNecessary. // CONSIDER: The DynamicAttribute for the type argument should just be Skip(1) of the original flag array. expansion = this.GetTypeExpansion(inspectionContext, new TypeAndCustomInfo(lmrNullableTypeArg), value, ExpansionFlags.IncludeResultsView); } } else if (value.IsError() || (inspectionContext.EvaluationFlags & DkmEvaluationFlags.NoExpansion) != 0) { expansion = null; } else { expansion = DebuggerTypeProxyExpansion.CreateExpansion( this, inspectionContext, name, typeDeclaringMemberAndInfo, declaredTypeAndInfo, value, childShouldParenthesize, fullName, flags.Includes(DkmEvaluationResultFlags.ExceptionThrown) ? null : fullName, formatSpecifiers, flags, this.Formatter.GetEditableValue(value, inspectionContext)); if (expansion == null) { expansion = value.HasExceptionThrown() ? this.GetTypeExpansion(inspectionContext, new TypeAndCustomInfo(value.Type), value, expansionFlags) : this.GetTypeExpansion(inspectionContext, declaredTypeAndInfo, value, expansionFlags); } } return new EvalResultDataItem( ExpansionKind.Default, name, typeDeclaringMemberAndInfo, declaredTypeAndInfo, parent: parent, value: value, displayValue: null, expansion: expansion, childShouldParenthesize: childShouldParenthesize, fullName: fullName, childFullNamePrefixOpt: flags.Includes(DkmEvaluationResultFlags.ExceptionThrown) ? null : fullName, formatSpecifiers: formatSpecifiers, category: category, flags: flags, editableValue: this.Formatter.GetEditableValue(value, inspectionContext), inspectionContext: inspectionContext); }
private static DkmEvaluationResult CreateEvaluationResult( DkmInspectionContext inspectionContext, DkmClrValue value, string name, string typeName, string display, EvalResultDataItem dataItem) { if (value.IsError()) { // Evaluation failed return DkmFailedEvaluationResult.Create( InspectionContext: inspectionContext, StackFrame: value.StackFrame, Name: name, FullName: dataItem.FullName, ErrorMessage: display, Flags: dataItem.Flags, Type: typeName, DataItem: dataItem); } else { ReadOnlyCollection<DkmCustomUIVisualizerInfo> customUIVisualizers = null; if (!value.IsNull) { DkmCustomUIVisualizerInfo[] customUIVisualizerInfo = value.Type.GetDebuggerCustomUIVisualizerInfo(); if (customUIVisualizerInfo != null) { customUIVisualizers = new ReadOnlyCollection<DkmCustomUIVisualizerInfo>(customUIVisualizerInfo); } } // If the EvalResultDataItem doesn't specify a particular category, we'll just propagate DkmClrValue.Category, // which typically appears to be set to the default value ("Other"). var category = (dataItem.Category != DkmEvaluationResultCategory.Other) ? dataItem.Category : value.Category; // Valid value return DkmSuccessEvaluationResult.Create( InspectionContext: inspectionContext, StackFrame: value.StackFrame, Name: name, FullName: dataItem.FullName, Flags: dataItem.Flags, Value: display, EditableValue: dataItem.EditableValue, Type: typeName, Category: category, Access: value.Access, StorageType: value.StorageType, TypeModifierFlags: value.TypeModifierFlags, Address: value.Address, CustomUIVisualizers: customUIVisualizers, ExternalModules: null, DataItem: dataItem); } }