Browse Source

Fixed bug in type resolution from name

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4872 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 17 years ago
parent
commit
769ff4a479
  1. 10
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugType.cs
  2. 50
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/DebugType.cs

10
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugType.cs

@ -349,11 +349,13 @@ namespace Debugger.MetaData
public static DebugType CreateFromName(AppDomain appDomain, string typeName, DebugType enclosingType, params DebugType[] genericArguments) public static DebugType CreateFromName(AppDomain appDomain, string typeName, DebugType enclosingType, params DebugType[] genericArguments)
{ {
if (enclosingType != null && genericArguments != null)
typeName = GetQualifiedName(typeName, genericArguments.Length - enclosingType.GenericArguments.Count);
foreach(Module module in appDomain.Process.Modules) { foreach(Module module in appDomain.Process.Modules) {
if (module.AppDomain == appDomain) { if (module.AppDomain == appDomain) {
uint token; uint token;
try { try {
token = module.MetaData.FindTypeDefPropsByName(GetQualifiedName(typeName, genericArguments), enclosingType == null ? 0 : enclosingType.Token).Token; token = module.MetaData.FindTypeDefPropsByName(typeName, enclosingType == null ? 0 : enclosingType.Token).Token;
} catch { } catch {
continue; continue;
} }
@ -364,10 +366,10 @@ namespace Debugger.MetaData
} }
/// <summary> Converts type name to the form suitable for COM API. </summary> /// <summary> Converts type name to the form suitable for COM API. </summary>
static string GetQualifiedName(string typeName, params DebugType[] genericArguments) static string GetQualifiedName(string typeName, int genericArgumentsCount)
{ {
if (genericArguments != null && genericArguments.Length > 0 && !typeName.Contains("`")) { if (genericArgumentsCount > 0 && !typeName.Contains("`")) {
return typeName + "`" + genericArguments.Length; return typeName + "`" + genericArgumentsCount;
} else { } else {
return typeName; return typeName;
} }

50
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/DebugType.cs

@ -27,6 +27,9 @@ namespace Debugger.Tests.TestPrograms
public class MyGenClass<T> public class MyGenClass<T>
{ {
public class MyNestedClass
{
}
public class MyGenNestedClass<U> public class MyGenNestedClass<U>
{ {
} }
@ -101,6 +104,7 @@ namespace Debugger.Tests.TestPrograms
MyGenClass<int> myGenClass_int = new MyGenClass<int>(); MyGenClass<int> myGenClass_int = new MyGenClass<int>();
MyGenClass<int>[] array_MyGenClass_int = new MyGenClass<int>[] {}; MyGenClass<int>[] array_MyGenClass_int = new MyGenClass<int>[] {};
MyGenClass<MyGenStruct<int>> myGenClass_MyGenStruct_int = new MyGenClass<MyGenStruct<int>>(); MyGenClass<MyGenStruct<int>> myGenClass_MyGenStruct_int = new MyGenClass<MyGenStruct<int>>();
MyGenClass<int>.MyNestedClass myNestedClass = new MyGenClass<int>.MyNestedClass();
MyGenClass<int>.MyGenNestedClass<char> myGenNestedClass = new MyGenClass<int>.MyGenNestedClass<char>(); MyGenClass<int>.MyGenNestedClass<char> myGenNestedClass = new MyGenClass<int>.MyGenNestedClass<char>();
// Generic struct // Generic struct
@ -115,7 +119,7 @@ namespace Debugger.Tests.TestPrograms
// TypeRef generics // TypeRef generics
List<int> list = new List<int>(); List<int> list = new List<int>();
// TODO List<int>.Enumerator listEnum = list.GetEnumerator(); List<int>.Enumerator listEnum = list.GetEnumerator();
// Other // Other
AddDelegate fnPtr = Add; AddDelegate fnPtr = Add;
@ -205,14 +209,15 @@ namespace Debugger.Tests {
<ProcessStarted /> <ProcessStarted />
<ModuleLoaded>mscorlib.dll (No symbols)</ModuleLoaded> <ModuleLoaded>mscorlib.dll (No symbols)</ModuleLoaded>
<ModuleLoaded>DebugType.exe (Has symbols)</ModuleLoaded> <ModuleLoaded>DebugType.exe (Has symbols)</ModuleLoaded>
<DebuggingPaused>Break DebugType.cs:125,4-125,40</DebuggingPaused> <DebuggingPaused>Break DebugType.cs:129,4-129,40</DebuggingPaused>
<DefinedTypes <DefinedTypes
Capacity="16" Capacity="16"
Count="11"> Count="12">
<Item>Debugger.Tests.TestPrograms.DebugType</Item> <Item>Debugger.Tests.TestPrograms.DebugType</Item>
<Item>AddDelegate</Item> <Item>AddDelegate</Item>
<Item>MyClass</Item> <Item>MyClass</Item>
<Item>MyGenClass`1</Item> <Item>MyGenClass`1</Item>
<Item>MyNestedClass</Item>
<Item>MyGenNestedClass`1</Item> <Item>MyGenNestedClass`1</Item>
<Item>MyStruct</Item> <Item>MyStruct</Item>
<Item>MyGenStruct`1</Item> <Item>MyGenStruct`1</Item>
@ -355,7 +360,7 @@ namespace Debugger.Tests {
Module="DebugType.exe" Module="DebugType.exe"
Name="Fun2" Name="Fun2"
ParameterCount="3" ParameterCount="3"
ParameterTypes="{Exception: Can not find type Enumerator}" ParameterTypes="{System.Int32**, System.Object[,], Enumerator&lt;System.Object&gt;}"
ReturnType="System.Object[]" /> ReturnType="System.Object[]" />
</Item> </Item>
<Item> <Item>
@ -867,6 +872,24 @@ namespace Debugger.Tests {
</Type> </Type>
</LocalVariable> </LocalVariable>
</Item> </Item>
<Item>
<LocalVariable
Name="myNestedClass"
Type="MyNestedClass&lt;System.Int32&gt;"
Value="myNestedClass = {MyNestedClass&lt;System.Int32&gt;}">
<Type>
<DebugType
BaseType="System.Object"
FullName="MyNestedClass&lt;System.Int32&gt;"
GenericArguments="{System.Int32}"
Kind="Class"
Module="DebugType.exe"
Name="MyNestedClass&lt;Int32&gt;">
<ElementType>null</ElementType>
</DebugType>
</Type>
</LocalVariable>
</Item>
<Item> <Item>
<LocalVariable <LocalVariable
Name="myGenNestedClass" Name="myGenNestedClass"
@ -1022,6 +1045,25 @@ namespace Debugger.Tests {
</Type> </Type>
</LocalVariable> </LocalVariable>
</Item> </Item>
<Item>
<LocalVariable
Name="listEnum"
Type="Enumerator&lt;System.Int32&gt;"
Value="listEnum = {Enumerator&lt;System.Int32&gt;}">
<Type>
<DebugType
BaseType="System.ValueType"
FullName="Enumerator&lt;System.Int32&gt;"
GenericArguments="{System.Int32}"
Interfaces="{System.Collections.Generic.IEnumerator&lt;System.Int32&gt;, System.IDisposable, System.Collections.IEnumerator}"
Kind="ValueType"
Module="mscorlib.dll"
Name="Enumerator&lt;Int32&gt;">
<ElementType>null</ElementType>
</DebugType>
</Type>
</LocalVariable>
</Item>
<Item> <Item>
<LocalVariable <LocalVariable
Name="fnPtr" Name="fnPtr"

Loading…
Cancel
Save