diff --git a/src/AddIns/Debugger/Debugger.AddIn/TreeModel/ValueNode.cs b/src/AddIns/Debugger/Debugger.AddIn/TreeModel/ValueNode.cs index c03a3c56d8..82e7e35092 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/TreeModel/ValueNode.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/TreeModel/ValueNode.cs @@ -123,7 +123,7 @@ namespace Debugger.AddIn.TreeModel this.GetChildren = () => GetArrayChildren(dims, dims); } } else if (val.Type.Kind == TypeKind.Class || val.Type.Kind == TypeKind.Struct) { - if (val.Type.FullName == typeof(List<>).FullName) { + if (val.Type.IsKnownType(typeof(List<>))) { if ((int)val.GetFieldValue("_size").PrimitiveValue > 0) this.GetChildren = () => GetIListChildren(this.GetValue); } else { @@ -355,7 +355,7 @@ namespace Debugger.AddIn.TreeModel ); } - if (shownType.GetAllBaseTypeDefinitions().Any(t => t.FullName == typeof(IList).FullName)) { + if (shownType.GetAllBaseTypeDefinitions().Any(t => t.IsKnownType(typeof(IList)))) { yield return new TreeNode( "IList", () => GetIListChildren(GetValue) diff --git a/src/AddIns/Debugger/Debugger.Core/TypeSystemExtensions.cs b/src/AddIns/Debugger/Debugger.Core/TypeSystemExtensions.cs index 0300d5ffb2..5a693ae052 100644 --- a/src/AddIns/Debugger/Debugger.Core/TypeSystemExtensions.cs +++ b/src/AddIns/Debugger/Debugger.Core/TypeSystemExtensions.cs @@ -375,6 +375,16 @@ namespace Debugger return def != null && def.KnownTypeCode == knownType; } + public static bool IsKnownType(this IType type, Type knownType) + { + var def = type.GetDefinition(); + if (knownType.IsGenericTypeDefinition) { + return def != null && def.Compilation.FindType(knownType).Equals(def); + } else { + return def != null && def.Compilation.FindType(knownType).Equals(type); + } + } + public static IField GetBackingField(this IMethod method) { return null; @@ -405,7 +415,7 @@ namespace Debugger return true; // Anonymous method or lambda } - if (type.GetDefinition().Attributes.Any(a => a.AttributeType.FullName == typeof(System.Runtime.CompilerServices.CompilerGeneratedAttribute).FullName)) { + if (type.GetDefinition() != null && type.GetDefinition().Attributes.Any(a => a.AttributeType.IsKnownType(typeof(System.Runtime.CompilerServices.CompilerGeneratedAttribute)))) { if (type.GetAllBaseTypeDefinitions().Any(t => t.FullName == typeof(System.Collections.IEnumerator).FullName)) { return true; // yield } diff --git a/src/AddIns/Debugger/Debugger.Core/Value.cs b/src/AddIns/Debugger/Debugger.Core/Value.cs index f85029c7d2..d5a496ae06 100644 --- a/src/AddIns/Debugger/Debugger.Core/Value.cs +++ b/src/AddIns/Debugger/Debugger.Core/Value.cs @@ -493,6 +493,9 @@ namespace Debugger return objectInstance.CorObjectValue.GetFieldValue((fieldInfo.DeclaringType).ToCorDebug().GetClass(), fieldInfo.GetMetadataToken()); } } catch (COMException e) { + // System.Runtime.InteropServices.COMException (0x80131303): A class is not loaded. (Exception from HRESULT: 0x80131303) + if ((uint)e.ErrorCode == 0x80131303) + throw new GetValueException("Class " + fieldInfo.DeclaringType.FullName + " is not loaded"); throw new GetValueException("Can not get value of field", e); } }