diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Debugger.Tests.csproj b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Debugger.Tests.csproj index 50d2a841d0..bb9e46e06b 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Debugger.Tests.csproj +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Debugger.Tests.csproj @@ -53,18 +53,14 @@ - - - - @@ -83,11 +79,7 @@ - - - - diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/DebugType.cs b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/DebugType.cs index facfffad72..a71ff69cb6 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/DebugType.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/DebugType.cs @@ -12,109 +12,185 @@ namespace Debugger.Tests.TestPrograms { public class DebugType { - public unsafe class MyClass + public delegate int AddDelegate(byte b1, byte b2); + + public static int Add(byte b1, byte b2) { - public delegate int Add(byte b1, byte b2); - - public int i; - public bool b; - public char c; - public IntPtr intPtr; - public int* pInt; - public void* pVoid; - public int[] intArray; - public int[,] intMultiArray; - public List intList; - public List[] intListArray; - public Point point; - public MyClass myClass; - public Add fnPtr; - - public T Foo(ref T tRef, T[] tArray) { return tRef; } + return b1 + b2; } - public interface MyInterface + // The classes are intentionally nested for testing + + public class MyClass { - K ItemKey { get; } } - public class MyInterfaceImpl : MyInterface, MyClass> + public class MyGenClass { - public T Item { get { return default(T); } } - public string ItemKey { get { return null; } } + public class MyGenNestedClass + { + } } - public struct Point { - int x; - int y; + public struct MyStruct + { } - public static unsafe void Main() + public struct MyGenStruct + { + public struct MyGenNestedStruct + { + } + } + + public interface MyInterface { - // TODO - // int? iNull = 5; - // int? iNull_null = null; + R Fun(A a, B b, M m); + } + + public unsafe class MyInterfaceImpl : MyInterface + { + public void* voidPtr; + + public List Prop { get { return new List(); } } + + R MyInterface.Fun(MyClass a, MyStruct b, M m) + { + throw new NotImplementedException(); + } + public M[] Fun2(ref int** iPtrPtr, ref M[,] mdArray, ref List.Enumerator listEnum) + { + throw new NotImplementedException(); + } + } + + public static unsafe void Main() + { // The nulls should be first to test for "Value does not fall within the expected range." exception of .BaseType - MyClass nullMyClass = null; object nullObject = null; string nullString = null; - object obj = new Object(); + MyClass nullMyClass = null; + + // Simple types + int i = 42; + bool b = true; + char c = 'a'; + object obj = new object(); MyClass myClass = new MyClass(); - int loc = 42; - int locByRef = 43; - int* locPtr = &loc; - int* locPtrByRef = &loc; - int** locPtrPtr = &locPtr; - void* locVoidPtr = &loc; - object locObj = new object(); - object locObjByRef = new object(); - char[] locSZArray = "Test".ToCharArray(); - char[,] locArray = new char[2,2]; - Point locStruct; - Point* locStructPtr = &locStruct; + MyStruct point = new MyStruct(); object box = 40; + + // Pointers + int* iPtr = &i; + int** iPtrPtr = &iPtr; + bool* bPtr = &b; + void* voidPtr = &i; + MyStruct* pointPtr = &point; + IntPtr ptr = IntPtr.Zero; + + // Arrays + char[] szArray = "Test".ToCharArray(); + char[,] mdArray = new char[2,3]; + + // Generics - nullables + int? nullable_value = 5; + int? nullable_null = null; + + // Generic class + MyGenClass myGenClass_int = new MyGenClass(); + MyGenClass[] array_MyGenClass_int = new MyGenClass[] {}; + MyGenClass> myGenClass_MyGenStruct_int = new MyGenClass>(); + MyGenClass.MyGenNestedClass myGenNestedClass = new MyGenClass.MyGenNestedClass(); + + // Generic struct + MyGenStruct myGenStruct_int = new MyGenStruct(); + MyGenStruct[] array_MyGenStruct_int = new MyGenStruct[] {}; + MyGenStruct> myGenStruct_MyGenClass_int = new MyGenStruct>(); + MyGenStruct.MyGenNestedStruct myGenNestedStruct = new MyGenStruct.MyGenNestedStruct(); + + // Generic interface MyInterfaceImpl myInterfaceImpl = new MyInterfaceImpl(); - MyInterface, MyClass> myInterface = myInterfaceImpl; + MyInterface myInterface = myInterfaceImpl; - System.Diagnostics.Debugger.Break(); + // TypeRef generics + List list = new List(); + // TODO List.Enumerator listEnum = list.GetEnumerator(); - Fun(loc, ref locByRef, locPtr, ref locPtrByRef, - locPtrPtr, locVoidPtr, - locObj, ref locObjByRef, - locSZArray, locArray, - locStruct, ref locStruct, locStructPtr, - box, ref box); + // Other + AddDelegate fnPtr = Add; + + Access access = new Access(); + + System.Diagnostics.Debugger.Break(); } - static unsafe void Fun(int arg, ref int argByRef, int* argPtr, ref int* argPtrByRef, - int** argPtrPtr, void* argVoidPtr, - object argObj, ref object argObjByRef, - char[] argSZArray, char[,] argArray, - Point argStruct, ref Point argStructByRef, Point* argStructPtr, - object argBox, ref object argBoxByRef) + public class Access { - System.Diagnostics.Debugger.Break(); + private int privateField = 0; + public int publicField = 0; + protected int protectedField = 0; + internal int internalField = 0; + static int staticField = 0; + + private int privateProperty { get { return 1 + privateField; } } + public int publicProperty { get { return 1 + publicField; } } + protected int protectedProperty { get { return 1 + protectedField; } } + internal int internalProperty { get { return 1 + internalField; } } + static int staticProperty { get { return 1 + staticField; } } + + private void privateMethod() {} + public void publicMethod() {} + protected void protectedMethod() {} + internal void internalMethod() {} + static void staticMethod() {} } } } #if TEST_CODE namespace Debugger.Tests { + using Debugger.MetaData; + using System.Linq; + public partial class DebuggerTests { + class LocalVariable + { + public string Name { get; set; } + public DebugType Type { get; set; } + public Value Value { get; set; } + } + + void PrintLocalVariables() + { + ObjectDump( + "LocalVariables", + process.SelectedStackFrame.MethodInfo.LocalVariables.Select(v => new LocalVariable() { Name = v.Name, Type = v.Type, Value = v.GetValue(process.SelectedStackFrame) }) + ); + } + [NUnit.Framework.Test] public void DebugType() { ExpandProperties( - "Value.Type", + "LocalVariable.Type", "DebugType.ElementType" ); StartTest("DebugType.cs"); - ObjectDump("MyClassMemberts", process.SelectedStackFrame.GetLocalVariableValue("myClass").Type.GetMembers()); - ObjectDump("LocalVariables", process.SelectedStackFrame.GetLocalVariableValues()); - process.Continue(); - ObjectDump("Arguments", process.SelectedStackFrame.GetArgumentValues()); + + process.Options.StepOverSingleLineProperties = false; + process.Options.StepOverFieldAccessProperties = true; + + ObjectDump("DefinedTypes", process.Modules["DebugType.exe"].GetNamesOfDefinedTypes()); + ObjectDump("DefinedTypes", process.Modules["DebugType.exe"].GetDefinedTypes()); + + ObjectDump("Access-Members", process.SelectedStackFrame.GetLocalVariableValue("access").Type.GetMembers()); + ObjectDump("MyInterfaceImpl-Members", process.SelectedStackFrame.GetLocalVariableValue("myInterfaceImpl").Type.GetMembers()); + PrintLocalVariables(); + + // TODO: Identity + EndTest(); } } @@ -129,160 +205,220 @@ namespace Debugger.Tests { mscorlib.dll (No symbols) DebugType.exe (Has symbols) - Break DebugType.cs:80,4-80,40 - Break DebugType.cs:125,4-125,40 + - - - + Count="11"> + Debugger.Tests.TestPrograms.DebugType + AddDelegate + MyClass + MyGenClass`1 + MyGenNestedClass`1 + MyStruct + MyGenStruct`1 + MyGenNestedStruct`1 + MyInterface`3 + MyInterfaceImpl`1 + Access + + - + Name="DebugType"> + null + - + Name="AddDelegate"> + null + - + Name="MyClass"> + null + - + Name="MyStruct"> + null + - + Name="Access"> + null + + + + Name="publicField" + Type="System.Int32" /> - + Name="get_publicProperty" + ReturnType="System.Int32" /> - + Name="publicMethod" /> - + Name=".ctor" /> - + Name="publicProperty" + Type="System.Int32" /> + + + Name="voidPtr" + Type="System.Void*" /> - + Name="get_Prop" + ReturnType="System.Collections.Generic.List<System.Int32>" /> + Name="Fun2" + ParameterCount="3" + ParameterTypes="{Exception: Can not find type Enumerator}" + ReturnType="System.Object[]" /> - - - + + + + + + + + + null + + + + + + + + + null + + + + + + null - + - + + Name="Int32"> null - + - + + FullName="System.Boolean" + Interfaces="{System.IComparable, System.IConvertible, System.IComparable<System.Boolean>, System.IEquatable<System.Boolean>}" + Kind="ValueType" + Module="mscorlib.dll" + Name="Boolean"> null - + - + + Name="Char"> null - + - + + Module="mscorlib.dll" + Name="Object"> null - + - + + FullName="MyClass" + Kind="Class" + Module="DebugType.exe" + Name="MyClass"> null - + - + + BaseType="System.ValueType" + FullName="MyStruct" + Kind="ValueType" + Module="DebugType.exe" + Name="MyStruct"> null - + - + - - - null - - + FullName="System.Object" + Kind="Class" + Module="mscorlib.dll" + Name="Object"> + null - + - + null - + - + null @@ -497,15 +612,40 @@ namespace Debugger.Tests { - + + + + + + + + + null + + + + + - + null - + - + - null + ElementType="MyStruct" + FullName="MyStruct*" + Kind="Pointer" + Module="{Exception: The type is not a class or value type.}" + Name="MyStruct*"> + + + null + + - + - + + Name="IntPtr"> null - + - + null - + - + null - + - + - null - - - - - - - - - - - null - - - - - - - - - - + Name="Nullable<Int32>"> null - + - + + Kind="ValueType" + Module="mscorlib.dll" + Name="Nullable<Int32>"> null - + - + - null - - - - - - Break DebugType.cs:97,4-97,40 - - - - - + Name="MyGenClass<Int32>"> null - + - + - null - - - - - - - - - - - null - - - - - - - - - - + Name="Int32>[]"> + FullName="MyGenClass<System.Int32>" + GenericArguments="{System.Int32}" + Kind="Class" + Module="DebugType.exe" + Name="MyGenClass<Int32>"> null - - - - - - - - - - - null - - - - - - - + - + - - - null - - + BaseType="System.Object" + FullName="MyGenClass<MyGenStruct<System.Int32>>" + GenericArguments="{MyGenStruct<System.Int32>}" + Kind="Class" + Module="DebugType.exe" + Name="MyGenClass<MyGenStruct<Int32>>"> + null - + - + + Module="DebugType.exe" + Name="MyGenNestedClass<Int32,Char>"> null - + - + + BaseType="System.ValueType" + FullName="MyGenStruct<System.Int32>" + GenericArguments="{System.Int32}" + Kind="ValueType" + Module="DebugType.exe" + Name="MyGenStruct<Int32>"> null - + - + + Name="Int32>[]"> + BaseType="System.ValueType" + FullName="MyGenStruct<System.Int32>" + GenericArguments="{System.Int32}" + Kind="ValueType" + Module="DebugType.exe" + Name="MyGenStruct<Int32>"> null - + - + - - - null - - + BaseType="System.ValueType" + FullName="MyGenStruct<MyGenClass<System.Int32>>" + GenericArguments="{MyGenClass<System.Int32>}" + Kind="ValueType" + Module="DebugType.exe" + Name="MyGenStruct<MyGenClass<Int32>>"> + null - + - + + Name="MyGenNestedStruct<Int32,Char>"> null - + - + + Name="MyInterfaceImpl<Int32>"> null - + - + - - - null - - + FullName="MyInterface<System.Int32,MyClass,MyStruct>" + GenericArguments="{System.Int32, MyClass, MyStruct}" + Kind="Class" + Module="DebugType.exe" + Name="MyInterface<Int32,MyClass,MyStruct>"> + null - + - + + Name="List<Int32>"> null - + - + + + + null + + + + + + + FullName="Access" + Kind="Class" + Module="DebugType.exe" + Name="Access"> null - + - + diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/DebugType_Access.cs b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/DebugType_Access.cs deleted file mode 100644 index 411bb1cf40..0000000000 --- a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/DebugType_Access.cs +++ /dev/null @@ -1,440 +0,0 @@ -// -// -// -// -// $Revision$ -// - -// Never used field -#pragma warning disable 0169 -// Field will always have default value -#pragma warning disable 0649 - -using System; - -namespace Debugger.Tests.TestPrograms -{ - public class DebugType_Access - { - private int privateField; - public int publicField; - protected int protectedField; - internal int internalField; - static int staticField; - - private int privateProperty { get { return 0; } } - public int publicProperty { get { return 0; } } - protected int protectedProperty { get { return 0; } } - internal int internalProperty { get { return 0; } } - static int staticProperty { get { return 0; } } - - private void privateMethod() {} - public void publicMethod() {} - protected void protectedMethod() {} - internal void internalMethod() {} - static void staticMethod() {} - - public static void Main() - { - System.Diagnostics.Debugger.Break(); - } - } - - public class Metadata2 {} - public class Metadata3 {} - public class Metadata4 {} - public class Metadata5 {} - public class Metadata6 {} - public class Metadata7 {} -} - -#if TEST_CODE -namespace Debugger.Tests { - using Debugger.MetaData; - - public partial class DebuggerTests - { - [NUnit.Framework.Test] - public void DebugType_Access() - { - StartTest("DebugType_Access.cs"); - - process.Options.StepOverSingleLineProperties = false; - process.Options.StepOverFieldAccessProperties = true; - - ObjectDump("Members", process.SelectedStackFrame.MethodInfo.DeclaringType.GetMembers(BindingFlags.All)); - ObjectDump("Types", process.SelectedStackFrame.MethodInfo.Module.GetNamesOfDefinedTypes()); - - EndTest(); - } - } -} -#endif - -#if EXPECTED_OUTPUT - - - - - mscorlib.dll (No symbols) - DebugType_Access.exe (Has symbols) - Break DebugType_Access.cs:39,4-39,40 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Debugger.Tests.TestPrograms.DebugType_Access - Debugger.Tests.TestPrograms.Metadata2 - Debugger.Tests.TestPrograms.Metadata3 - Debugger.Tests.TestPrograms.Metadata4 - Debugger.Tests.TestPrograms.Metadata5 - Debugger.Tests.TestPrograms.Metadata6 - Debugger.Tests.TestPrograms.Metadata7 - - - - -#endif // EXPECTED_OUTPUT \ No newline at end of file diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/DebugType_DefinedTypes.cs b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/DebugType_DefinedTypes.cs deleted file mode 100644 index 0d41ff7e7a..0000000000 --- a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/DebugType_DefinedTypes.cs +++ /dev/null @@ -1,88 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; - -namespace Debugger.Tests.TestPrograms -{ - public class DefinedTypes_Class - { - public static void Main() - { - System.Diagnostics.Debugger.Break(); - } - } - - public struct DefinedTypes_Struct - { - - } - - public class DefinedTypes_GenericClass - { - - } -} - -#if TEST_CODE -namespace Debugger.Tests { - public partial class DebuggerTests - { - [NUnit.Framework.Test] - public void DebugType_DefinedTypes() - { - StartTest("DebugType_DefinedTypes.cs"); - - ObjectDump("TypesAsString", process.Modules["DebugType_DefinedTypes.exe"].GetNamesOfDefinedTypes()); - ObjectDump("Types", process.Modules["DebugType_DefinedTypes.exe"].GetDefinedTypes()); - - EndTest(); - } - } -} -#endif - -#if EXPECTED_OUTPUT - - - - - mscorlib.dll (No symbols) - DebugType_DefinedTypes.exe (Has symbols) - Break DebugType_DefinedTypes.cs:16,4-16,40 - - Debugger.Tests.TestPrograms.DefinedTypes_Class - Debugger.Tests.TestPrograms.DefinedTypes_Struct - Debugger.Tests.TestPrograms.DefinedTypes_GenericClass`2 - - - - - - - - - - - - -#endif // EXPECTED_OUTPUT \ No newline at end of file diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/DebugType_Generics.cs b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/DebugType_Generics.cs deleted file mode 100644 index a7f79cb4f3..0000000000 --- a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/DebugType_Generics.cs +++ /dev/null @@ -1,564 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; - -namespace Debugger.Tests.TestPrograms -{ - public class MainClass - { - public static void Main() - { - GenericClass gClass = new GenericClass(); - gClass.Metod(1, "1!"); - gClass.GenericMethod(2, "2!"); - GenericClass.StaticMetod(3, "3!"); - GenericClass.StaticGenericMethod(4, "4!"); - - GenericStruct gStruct = new GenericStruct(); - gStruct.Metod(5, "5!"); - gStruct.GenericMethod(6, "6!"); - GenericStruct.StaticMetod(7, "7!"); - GenericStruct.StaticGenericMethod(8, "8!"); - - System.Diagnostics.Debugger.Break(); - } - } - - public class GenericClass - { - public V Prop { - get { - return default(V); - } - } - - public static V StaticProp { - get { - return default(V); - } - } - - public K Metod(V v, K k) - { - System.Diagnostics.Debugger.Break(); - return k; - } - - public T GenericMethod(V v, K k) - { - System.Diagnostics.Debugger.Break(); - return default(T); - } - - public static K StaticMetod(V v, K k) - { - System.Diagnostics.Debugger.Break(); - return k; - } - - public static T StaticGenericMethod(V v, K k) - { - System.Diagnostics.Debugger.Break(); - return default(T); - } - } - - public struct GenericStruct - { - public K Metod(V v, K k) - { - System.Diagnostics.Debugger.Break(); - return k; - } - - public T GenericMethod(V v, K k) - { - System.Diagnostics.Debugger.Break(); - return default(T); - } - - public static K StaticMetod(V v, K k) - { - System.Diagnostics.Debugger.Break(); - return k; - } - - public static T StaticGenericMethod(V v, K k) - { - System.Diagnostics.Debugger.Break(); - return default(T); - } - } -} - -#if TEST_CODE -namespace Debugger.Tests { - public partial class DebuggerTests - { - [NUnit.Framework.Test] - public void DebugType_Generics() - { - ExpandProperties( - "StackFrame.MethodInfo", - "MemberInfo.DeclaringType" - ); - StartTest("DebugType_Generics.cs"); - - for(int i = 0; i < 8; i++) { - ObjectDump("SelectedStackFrame", process.SelectedStackFrame); - ObjectDump("SelectedStackFrame-GetArguments", process.SelectedStackFrame.GetArgumentValues()); - process.Continue(); - } - ObjectDump("Prop", process.SelectedStackFrame.GetLocalVariableValue("gClass").GetMemberValue("Prop")); - ObjectDump("StaticProp", process.SelectedStackFrame.GetLocalVariableValue("gClass").GetMemberValue("StaticProp")); - - EndTest(); - } - } -} -#endif - -#if EXPECTED_OUTPUT - - - - - mscorlib.dll (No symbols) - DebugType_Generics.exe (Has symbols) - Break DebugType_Generics.cs:48,4-48,40 - - - - - - - - - - - - - - - - - - - - Break DebugType_Generics.cs:54,4-54,40 - - - - - - - - - - - - - - - - - - - - Break DebugType_Generics.cs:60,4-60,40 - - - - - - - - - - - - - - - - - - - - Break DebugType_Generics.cs:66,4-66,40 - - - - - - - - - - - - - - - - - - - - Break DebugType_Generics.cs:75,4-75,40 - - - - - - - - - - - - - - - - - - - - Break DebugType_Generics.cs:81,4-81,40 - - - - - - - - - - - - - - - - - - - - Break DebugType_Generics.cs:87,4-87,40 - - - - - - - - - - - - - - - - - - - - Break DebugType_Generics.cs:93,4-93,40 - - - - - - - - - - - - - - - - - - - - Break DebugType_Generics.cs:28,4-28,40 - - - - - - - - - -#endif // EXPECTED_OUTPUT \ No newline at end of file diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/DebugType_Identity.cs b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/DebugType_Identity.cs deleted file mode 100644 index 8006089a46..0000000000 --- a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/DebugType_Identity.cs +++ /dev/null @@ -1,65 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; - -namespace Debugger.Tests.TestPrograms -{ - public class DebugType_Identity - { - public static void Main() - { - new DebugType_Identity().Func(); - } - - public void Func() - { - System.Diagnostics.Debugger.Break(); - System.Diagnostics.Debugger.Break(); - } - } -} - -#if TEST_CODE -namespace Debugger.Tests { - using NUnit.Framework; - using Debugger.MetaData; - - public partial class DebuggerTests - { - [NUnit.Framework.Test] - public void DebugType_Identity() - { - StartTest("DebugType_Identity.cs"); - - DebugType type = process.SelectedStackFrame.GetThisValue().Type; - MethodInfo mainMethod = process.SelectedStackFrame.MethodInfo; - process.Continue(); - - Assert.AreEqual(type, process.SelectedStackFrame.GetThisValue().Type); - Assert.AreEqual(mainMethod, process.SelectedStackFrame.MethodInfo); - - EndTest(); - } - } -} -#endif - -#if EXPECTED_OUTPUT - - - - - mscorlib.dll (No symbols) - DebugType_Identity.exe (Has symbols) - Break DebugType_Identity.cs:21,4-21,40 - Break DebugType_Identity.cs:22,4-22,40 - - - -#endif // EXPECTED_OUTPUT \ No newline at end of file