Browse Source

Bugfixes in type resolution. Written unit tests for it.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5155 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 16 years ago
parent
commit
4482b90ae4
  1. 64
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/NRefactory/Ast/ExpressionExtensionMethods.cs
  2. 56
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/Tests/DebugType_Tests.cs
  3. 49
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/Tests/ExpressionEvaluator_Tests.cs

64
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/NRefactory/Ast/ExpressionExtensionMethods.cs

@ -127,12 +127,6 @@ namespace ICSharpCode.NRefactory.Ast @@ -127,12 +127,6 @@ namespace ICSharpCode.NRefactory.Ast
public static TypeReference GetTypeReference(this Type type)
{
int pointerNest = 0;
while(type.IsPointer) {
pointerNest++;
type = type.GetElementType();
}
List<int> arrayRanks = new List<int>();
while(type.IsArray) {
// C# uses reverse array order
@ -140,7 +134,13 @@ namespace ICSharpCode.NRefactory.Ast @@ -140,7 +134,13 @@ namespace ICSharpCode.NRefactory.Ast
type = type.GetElementType();
}
if (type.IsPointer)
int pointerNest = 0;
while(type.IsPointer) {
pointerNest++;
type = type.GetElementType();
}
if (type.IsArray)
throw new DebuggerException("C# does not support pointers to arrays");
string name = type.Name;
@ -149,19 +149,23 @@ namespace ICSharpCode.NRefactory.Ast @@ -149,19 +149,23 @@ namespace ICSharpCode.NRefactory.Ast
if (!string.IsNullOrEmpty(type.Namespace))
name = type.Namespace + "." + name;
List<TypeReference> genArgs = new List<TypeReference>();
// TODO: Does it inlucde parent gen arguments
foreach(Type genArg in type.GetGenericArguments())
genArgs.Add(genArg.GetTypeReference());
List<Type> genArgs = new List<Type>();
genArgs.AddRange(type.GetGenericArguments());
if (type.DeclaringType != null)
genArgs.RemoveRange(0, type.DeclaringType.GetGenericArguments().Length);
List<TypeReference> genTypeRefs = new List<TypeReference>();
foreach(Type genArg in genArgs) {
genTypeRefs.Add(genArg.GetTypeReference());
}
if (type.DeclaringType != null) {
TypeReference outterRef = type.DeclaringType.GetTypeReference();
InnerClassTypeReference innerRef = new InnerClassTypeReference(outterRef, name, genArgs);
InnerClassTypeReference innerRef = new InnerClassTypeReference(outterRef, name, genTypeRefs);
innerRef.PointerNestingLevel = pointerNest;
innerRef.RankSpecifier = arrayRanks.ToArray();
return innerRef;
} else {
return new TypeReference(name, pointerNest, arrayRanks.ToArray(), genArgs);
return new TypeReference(name, pointerNest, arrayRanks.ToArray(), genTypeRefs);
}
}
@ -185,6 +189,17 @@ namespace ICSharpCode.NRefactory.Ast @@ -185,6 +189,17 @@ namespace ICSharpCode.NRefactory.Ast
);
} else if (expr is TypeReferenceExpression) {
return NormalizeTypeReference(((TypeReferenceExpression)expr).TypeReference);
} else if (expr is InnerClassTypeReference) { // Frist - it is also TypeReference
InnerClassTypeReference typeRef = (InnerClassTypeReference)expr;
string[] names = typeRef.Type.Split('.');
TypeReference newRef = NormalizeTypeReference(typeRef.BaseType);
foreach(string name in names) {
newRef = new InnerClassTypeReference(newRef, name, new List<TypeReference>());
}
newRef.GenericTypes.AddRange(typeRef.GenericTypes);
newRef.PointerNestingLevel = typeRef.PointerNestingLevel;
newRef.RankSpecifier = typeRef.RankSpecifier;
return newRef;
} else if (expr is TypeReference) {
TypeReference typeRef = (TypeReference)expr;
string[] names = typeRef.Type.Split('.');
@ -202,17 +217,6 @@ namespace ICSharpCode.NRefactory.Ast @@ -202,17 +217,6 @@ namespace ICSharpCode.NRefactory.Ast
newRef.PointerNestingLevel = typeRef.PointerNestingLevel;
newRef.RankSpecifier = typeRef.RankSpecifier;
return newRef;
} else if (expr is InnerClassTypeReference) {
InnerClassTypeReference typeRef = (InnerClassTypeReference)expr;
string[] names = typeRef.Type.Split('.');
TypeReference newRef = NormalizeTypeReference(typeRef.BaseType);
foreach(string name in names) {
newRef = new InnerClassTypeReference(newRef, name, new List<TypeReference>());
}
newRef.GenericTypes.AddRange(typeRef.GenericTypes);
newRef.PointerNestingLevel = typeRef.PointerNestingLevel;
newRef.RankSpecifier = typeRef.RankSpecifier;
return newRef;
} else {
throw new EvaluateException(expr, "Type expected. {0} seen.", expr.GetType());
}
@ -222,7 +226,7 @@ namespace ICSharpCode.NRefactory.Ast @@ -222,7 +226,7 @@ namespace ICSharpCode.NRefactory.Ast
{
string name = typeRef.Type;
if (typeRef.GenericTypes.Count > 0)
name += '`' + typeRef.GenericTypes.Count;
name += "`" + typeRef.GenericTypes.Count.ToString();
if (typeRef is InnerClassTypeReference) {
return GetNameWithArgCounts(((InnerClassTypeReference)typeRef).BaseType) + "." + name;
} else {
@ -256,8 +260,8 @@ namespace ICSharpCode.NRefactory.Ast @@ -256,8 +260,8 @@ namespace ICSharpCode.NRefactory.Ast
}
// Try to construct nested type
if (type != null && typeRef is InnerClassTypeReference) {
DebugType outter = ResolveType((InnerClassTypeReference)typeRef, appDomain);
if (type == null && typeRef is InnerClassTypeReference) {
DebugType outter = ResolveType(((InnerClassTypeReference)typeRef).BaseType, appDomain);
if (outter == null)
return null;
string nestedName = typeRef.GenericTypes.Count == 0 ? typeRef.Type : typeRef.Type + "`" + typeRef.GenericTypes.Count;
@ -270,8 +274,10 @@ namespace ICSharpCode.NRefactory.Ast @@ -270,8 +274,10 @@ namespace ICSharpCode.NRefactory.Ast
for(int i = 0; i < typeRef.PointerNestingLevel; i++) {
type = (DebugType)type.MakePointerType();
}
for(int i = typeRef.RankSpecifier.Length - 1; i >= 0; i--) {
type = (DebugType)type.MakeArrayType(typeRef.RankSpecifier[i] + 1);
if (typeRef.RankSpecifier != null) {
for(int i = typeRef.RankSpecifier.Length - 1; i >= 0; i--) {
type = (DebugType)type.MakeArrayType(typeRef.RankSpecifier[i] + 1);
}
}
return type;
}

56
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/Tests/DebugType_Tests.cs

@ -105,6 +105,7 @@ namespace Debugger.Tests @@ -105,6 +105,7 @@ namespace Debugger.Tests
// Arrays
char[] szArray = "Test".ToCharArray();
char[,] mdArray = new char[2,3];
char[][,] jagArray = new char[][,] { mdArray };
// Generics - nullables
int? nullable_value = 5;
@ -223,7 +224,7 @@ namespace Debugger.Tests { @@ -223,7 +224,7 @@ namespace Debugger.Tests {
<ProcessStarted />
<ModuleLoaded>mscorlib.dll (No symbols)</ModuleLoaded>
<ModuleLoaded>DebugType_Tests.exe (Has symbols)</ModuleLoaded>
<DebuggingPaused>Break DebugType_Tests.cs:137,4-137,40</DebuggingPaused>
<DebuggingPaused>Break DebugType_Tests.cs:138,4-138,40</DebuggingPaused>
<DefinedTypes
Capacity="16"
Count="12">
@ -1065,6 +1066,59 @@ namespace Debugger.Tests { @@ -1065,6 +1066,59 @@ namespace Debugger.Tests {
</Type>
</LocalVariable>
</Item>
<Item>
<LocalVariable
Name="jagArray"
Type="System.Char[,][]"
Value="{System.Char[,][]}">
<Type>
<DebugType
Attributes="NotPublic"
BaseType="System.Array"
FullName="System.Char[,][]"
GetArrayRank="1"
GetElementType="System.Char[,]"
GetMembers="{System.Object System.Array.GetValue(Int32[] indices), System.Object System.Array.GetValue(Int32 index), System.Object System.Array.GetValue(Int32 index1, Int32 index2), System.Object System.Array.GetValue(Int32 index1, Int32 index2, Int32 index3), System.Object System.Array.GetValue(Int64 index), System.Object System.Array.GetValue(Int64 index1, Int64 index2), System.Object System.Array.GetValue(Int64 index1, Int64 index2, Int64 index3), System.Object System.Array.GetValue(Int64[] indices), void System.Array.SetValue(Object value, Int32 index), void System.Array.SetValue(Object value, Int32 index1, Int32 index2), void System.Array.SetValue(Object value, Int32 index1, Int32 index2, Int32 index3), void System.Array.SetValue(Object value, Int32[] indices), void System.Array.SetValue(Object value, Int64 index), void System.Array.SetValue(Object value, Int64 index1, Int64 index2), void System.Array.SetValue(Object value, Int64 index1, Int64 index2, Int64 index3), void System.Array.SetValue(Object value, Int64[] indices), System.Int32 System.Array.get_Length(), System.Int64 System.Array.get_LongLength(), System.Int32 System.Array.GetLength(Int32 dimension), System.Int64 System.Array.GetLongLength(Int32 dimension), System.Int32 System.Array.get_Rank(), System.Int32 System.Array.GetUpperBound(Int32 dimension), System.Int32 System.Array.GetLowerBound(Int32 dimension), System.Object System.Array.get_SyncRoot(), System.Boolean System.Array.get_IsReadOnly(), System.Boolean System.Array.get_IsFixedSize(), System.Boolean System.Array.get_IsSynchronized(), System.Object System.Array.Clone(), System.Int32 System.Array.CompareTo(Object other, IComparer comparer), System.Boolean System.Array.Equals(Object other, IEqualityComparer comparer), System.Int32 System.Array.GetHashCode(IEqualityComparer comparer), void System.Array.CopyTo(Array array, Int32 index), void System.Array.CopyTo(Array array, Int64 index), System.Collections.IEnumerator System.Array.GetEnumerator(), void System.Array.Initialize(), System.Int32 Length, System.Int64 LongLength, System.Int32 Rank, System.Object SyncRoot, System.Boolean IsReadOnly, System.Boolean IsFixedSize, System.Boolean IsSynchronized, void System.Object..ctor(), System.String System.Object.ToString(), System.Boolean System.Object.Equals(Object obj), System.Int32 System.Object.GetHashCode(), System.Type System.Object.GetType()}"
GetMethods="{System.Object System.Array.GetValue(Int32[] indices), System.Object System.Array.GetValue(Int32 index), System.Object System.Array.GetValue(Int32 index1, Int32 index2), System.Object System.Array.GetValue(Int32 index1, Int32 index2, Int32 index3), System.Object System.Array.GetValue(Int64 index), System.Object System.Array.GetValue(Int64 index1, Int64 index2), System.Object System.Array.GetValue(Int64 index1, Int64 index2, Int64 index3), System.Object System.Array.GetValue(Int64[] indices), void System.Array.SetValue(Object value, Int32 index), void System.Array.SetValue(Object value, Int32 index1, Int32 index2), void System.Array.SetValue(Object value, Int32 index1, Int32 index2, Int32 index3), void System.Array.SetValue(Object value, Int32[] indices), void System.Array.SetValue(Object value, Int64 index), void System.Array.SetValue(Object value, Int64 index1, Int64 index2), void System.Array.SetValue(Object value, Int64 index1, Int64 index2, Int64 index3), void System.Array.SetValue(Object value, Int64[] indices), System.Int32 System.Array.get_Length(), System.Int64 System.Array.get_LongLength(), System.Int32 System.Array.GetLength(Int32 dimension), System.Int64 System.Array.GetLongLength(Int32 dimension), System.Int32 System.Array.get_Rank(), System.Int32 System.Array.GetUpperBound(Int32 dimension), System.Int32 System.Array.GetLowerBound(Int32 dimension), System.Object System.Array.get_SyncRoot(), System.Boolean System.Array.get_IsReadOnly(), System.Boolean System.Array.get_IsFixedSize(), System.Boolean System.Array.get_IsSynchronized(), System.Object System.Array.Clone(), System.Int32 System.Array.CompareTo(Object other, IComparer comparer), System.Boolean System.Array.Equals(Object other, IEqualityComparer comparer), System.Int32 System.Array.GetHashCode(IEqualityComparer comparer), void System.Array.CopyTo(Array array, Int32 index), void System.Array.CopyTo(Array array, Int64 index), System.Collections.IEnumerator System.Array.GetEnumerator(), void System.Array.Initialize(), void System.Object..ctor(), System.String System.Object.ToString(), System.Boolean System.Object.Equals(Object obj), System.Int32 System.Object.GetHashCode(), System.Type System.Object.GetType()}"
GetProperties="{System.Int32 Length, System.Int64 LongLength, System.Int32 Rank, System.Object SyncRoot, System.Boolean IsReadOnly, System.Boolean IsFixedSize, System.Boolean IsSynchronized}"
HasElementType="True"
IsArray="True"
IsClass="True"
IsCompilerGenerated="True">
<GetElementType>
<DebugType
Attributes="NotPublic"
BaseType="System.Array"
FullName="System.Char[,]"
GetArrayRank="2"
GetElementType="System.Char"
GetMembers="{System.Object System.Array.GetValue(Int32[] indices), System.Object System.Array.GetValue(Int32 index), System.Object System.Array.GetValue(Int32 index1, Int32 index2), System.Object System.Array.GetValue(Int32 index1, Int32 index2, Int32 index3), System.Object System.Array.GetValue(Int64 index), System.Object System.Array.GetValue(Int64 index1, Int64 index2), System.Object System.Array.GetValue(Int64 index1, Int64 index2, Int64 index3), System.Object System.Array.GetValue(Int64[] indices), void System.Array.SetValue(Object value, Int32 index), void System.Array.SetValue(Object value, Int32 index1, Int32 index2), void System.Array.SetValue(Object value, Int32 index1, Int32 index2, Int32 index3), void System.Array.SetValue(Object value, Int32[] indices), void System.Array.SetValue(Object value, Int64 index), void System.Array.SetValue(Object value, Int64 index1, Int64 index2), void System.Array.SetValue(Object value, Int64 index1, Int64 index2, Int64 index3), void System.Array.SetValue(Object value, Int64[] indices), System.Int32 System.Array.get_Length(), System.Int64 System.Array.get_LongLength(), System.Int32 System.Array.GetLength(Int32 dimension), System.Int64 System.Array.GetLongLength(Int32 dimension), System.Int32 System.Array.get_Rank(), System.Int32 System.Array.GetUpperBound(Int32 dimension), System.Int32 System.Array.GetLowerBound(Int32 dimension), System.Object System.Array.get_SyncRoot(), System.Boolean System.Array.get_IsReadOnly(), System.Boolean System.Array.get_IsFixedSize(), System.Boolean System.Array.get_IsSynchronized(), System.Object System.Array.Clone(), System.Int32 System.Array.CompareTo(Object other, IComparer comparer), System.Boolean System.Array.Equals(Object other, IEqualityComparer comparer), System.Int32 System.Array.GetHashCode(IEqualityComparer comparer), void System.Array.CopyTo(Array array, Int32 index), void System.Array.CopyTo(Array array, Int64 index), System.Collections.IEnumerator System.Array.GetEnumerator(), void System.Array.Initialize(), System.Int32 Length, System.Int64 LongLength, System.Int32 Rank, System.Object SyncRoot, System.Boolean IsReadOnly, System.Boolean IsFixedSize, System.Boolean IsSynchronized, void System.Object..ctor(), System.String System.Object.ToString(), System.Boolean System.Object.Equals(Object obj), System.Int32 System.Object.GetHashCode(), System.Type System.Object.GetType()}"
GetMethods="{System.Object System.Array.GetValue(Int32[] indices), System.Object System.Array.GetValue(Int32 index), System.Object System.Array.GetValue(Int32 index1, Int32 index2), System.Object System.Array.GetValue(Int32 index1, Int32 index2, Int32 index3), System.Object System.Array.GetValue(Int64 index), System.Object System.Array.GetValue(Int64 index1, Int64 index2), System.Object System.Array.GetValue(Int64 index1, Int64 index2, Int64 index3), System.Object System.Array.GetValue(Int64[] indices), void System.Array.SetValue(Object value, Int32 index), void System.Array.SetValue(Object value, Int32 index1, Int32 index2), void System.Array.SetValue(Object value, Int32 index1, Int32 index2, Int32 index3), void System.Array.SetValue(Object value, Int32[] indices), void System.Array.SetValue(Object value, Int64 index), void System.Array.SetValue(Object value, Int64 index1, Int64 index2), void System.Array.SetValue(Object value, Int64 index1, Int64 index2, Int64 index3), void System.Array.SetValue(Object value, Int64[] indices), System.Int32 System.Array.get_Length(), System.Int64 System.Array.get_LongLength(), System.Int32 System.Array.GetLength(Int32 dimension), System.Int64 System.Array.GetLongLength(Int32 dimension), System.Int32 System.Array.get_Rank(), System.Int32 System.Array.GetUpperBound(Int32 dimension), System.Int32 System.Array.GetLowerBound(Int32 dimension), System.Object System.Array.get_SyncRoot(), System.Boolean System.Array.get_IsReadOnly(), System.Boolean System.Array.get_IsFixedSize(), System.Boolean System.Array.get_IsSynchronized(), System.Object System.Array.Clone(), System.Int32 System.Array.CompareTo(Object other, IComparer comparer), System.Boolean System.Array.Equals(Object other, IEqualityComparer comparer), System.Int32 System.Array.GetHashCode(IEqualityComparer comparer), void System.Array.CopyTo(Array array, Int32 index), void System.Array.CopyTo(Array array, Int64 index), System.Collections.IEnumerator System.Array.GetEnumerator(), void System.Array.Initialize(), void System.Object..ctor(), System.String System.Object.ToString(), System.Boolean System.Object.Equals(Object obj), System.Int32 System.Object.GetHashCode(), System.Type System.Object.GetType()}"
GetProperties="{System.Int32 Length, System.Int64 LongLength, System.Int32 Rank, System.Object SyncRoot, System.Boolean IsReadOnly, System.Boolean IsFixedSize, System.Boolean IsSynchronized}"
HasElementType="True"
IsArray="True"
IsClass="True"
IsCompilerGenerated="True">
<GetElementType>
<DebugType
Attributes="AutoLayout, AnsiClass, Class, Public, SequentialLayout, Sealed, Serializable, BeforeFieldInit"
BaseType="System.ValueType"
FullName="System.Char"
GetFields="{System.Char MaxValue, System.Char MinValue}"
GetInterfaces="{System.IComparable, System.IConvertible, System.IComparable`1[System.Char], System.IEquatable`1[System.Char]}"
GetMembers="{System.Char MaxValue, System.Char MinValue, System.Int32 System.Char.GetHashCode(), System.Boolean System.Char.Equals(Object obj), System.Boolean System.Char.Equals(Char obj), System.Int32 System.Char.CompareTo(Object value), System.Int32 System.Char.CompareTo(Char value), System.String System.Char.ToString(), System.String System.Char.ToString(IFormatProvider provider), static System.String System.Char.ToString(Char c), static System.Char System.Char.Parse(String s), static System.Boolean System.Char.TryParse(String s, Char result), static System.Boolean System.Char.IsDigit(Char c), static System.Boolean System.Char.IsDigit(String s, Int32 index), static System.Boolean System.Char.IsLetter(Char c), static System.Boolean System.Char.IsLetter(String s, Int32 index), static System.Boolean System.Char.IsWhiteSpace(Char c), static System.Boolean System.Char.IsWhiteSpace(String s, Int32 index), static System.Boolean System.Char.IsUpper(Char c), static System.Boolean System.Char.IsUpper(String s, Int32 index), static System.Boolean System.Char.IsLower(Char c), static System.Boolean System.Char.IsLower(String s, Int32 index), static System.Boolean System.Char.IsPunctuation(Char c), static System.Boolean System.Char.IsPunctuation(String s, Int32 index), static System.Boolean System.Char.IsLetterOrDigit(Char c), static System.Boolean System.Char.IsLetterOrDigit(String s, Int32 index), static System.Char System.Char.ToUpper(Char c, CultureInfo culture), static System.Char System.Char.ToUpper(Char c), static System.Char System.Char.ToUpperInvariant(Char c), static System.Char System.Char.ToLower(Char c, CultureInfo culture), static System.Char System.Char.ToLower(Char c), static System.Char System.Char.ToLowerInvariant(Char c), System.TypeCode System.Char.GetTypeCode(), static System.Boolean System.Char.IsControl(Char c), static System.Boolean System.Char.IsControl(String s, Int32 index), static System.Boolean System.Char.IsNumber(Char c), static System.Boolean System.Char.IsNumber(String s, Int32 index), static System.Boolean System.Char.IsSeparator(Char c), static System.Boolean System.Char.IsSeparator(String s, Int32 index), static System.Boolean System.Char.IsSurrogate(Char c), static System.Boolean System.Char.IsSurrogate(String s, Int32 index), static System.Boolean System.Char.IsSymbol(Char c), static System.Boolean System.Char.IsSymbol(String s, Int32 index), static System.Globalization.UnicodeCategory System.Char.GetUnicodeCategory(Char c), static System.Globalization.UnicodeCategory System.Char.GetUnicodeCategory(String s, Int32 index), static System.Double System.Char.GetNumericValue(Char c), static System.Double System.Char.GetNumericValue(String s, Int32 index), static System.Boolean System.Char.IsHighSurrogate(Char c), static System.Boolean System.Char.IsHighSurrogate(String s, Int32 index), static System.Boolean System.Char.IsLowSurrogate(Char c), static System.Boolean System.Char.IsLowSurrogate(String s, Int32 index), static System.Boolean System.Char.IsSurrogatePair(String s, Int32 index), static System.Boolean System.Char.IsSurrogatePair(Char highSurrogate, Char lowSurrogate), static System.String System.Char.ConvertFromUtf32(Int32 utf32), static System.Int32 System.Char.ConvertToUtf32(Char highSurrogate, Char lowSurrogate), static System.Int32 System.Char.ConvertToUtf32(String s, Int32 index), System.Boolean System.ValueType.Equals(Object obj), System.Int32 System.ValueType.GetHashCode(), System.String System.ValueType.ToString(), void System.Object..ctor(), System.String System.Object.ToString(), System.Boolean System.Object.Equals(Object obj), System.Int32 System.Object.GetHashCode(), System.Type System.Object.GetType()}"
GetMethods="{System.Int32 System.Char.GetHashCode(), System.Boolean System.Char.Equals(Object obj), System.Boolean System.Char.Equals(Char obj), System.Int32 System.Char.CompareTo(Object value), System.Int32 System.Char.CompareTo(Char value), System.String System.Char.ToString(), System.String System.Char.ToString(IFormatProvider provider), static System.String System.Char.ToString(Char c), static System.Char System.Char.Parse(String s), static System.Boolean System.Char.TryParse(String s, Char result), static System.Boolean System.Char.IsDigit(Char c), static System.Boolean System.Char.IsDigit(String s, Int32 index), static System.Boolean System.Char.IsLetter(Char c), static System.Boolean System.Char.IsLetter(String s, Int32 index), static System.Boolean System.Char.IsWhiteSpace(Char c), static System.Boolean System.Char.IsWhiteSpace(String s, Int32 index), static System.Boolean System.Char.IsUpper(Char c), static System.Boolean System.Char.IsUpper(String s, Int32 index), static System.Boolean System.Char.IsLower(Char c), static System.Boolean System.Char.IsLower(String s, Int32 index), static System.Boolean System.Char.IsPunctuation(Char c), static System.Boolean System.Char.IsPunctuation(String s, Int32 index), static System.Boolean System.Char.IsLetterOrDigit(Char c), static System.Boolean System.Char.IsLetterOrDigit(String s, Int32 index), static System.Char System.Char.ToUpper(Char c, CultureInfo culture), static System.Char System.Char.ToUpper(Char c), static System.Char System.Char.ToUpperInvariant(Char c), static System.Char System.Char.ToLower(Char c, CultureInfo culture), static System.Char System.Char.ToLower(Char c), static System.Char System.Char.ToLowerInvariant(Char c), System.TypeCode System.Char.GetTypeCode(), static System.Boolean System.Char.IsControl(Char c), static System.Boolean System.Char.IsControl(String s, Int32 index), static System.Boolean System.Char.IsNumber(Char c), static System.Boolean System.Char.IsNumber(String s, Int32 index), static System.Boolean System.Char.IsSeparator(Char c), static System.Boolean System.Char.IsSeparator(String s, Int32 index), static System.Boolean System.Char.IsSurrogate(Char c), static System.Boolean System.Char.IsSurrogate(String s, Int32 index), static System.Boolean System.Char.IsSymbol(Char c), static System.Boolean System.Char.IsSymbol(String s, Int32 index), static System.Globalization.UnicodeCategory System.Char.GetUnicodeCategory(Char c), static System.Globalization.UnicodeCategory System.Char.GetUnicodeCategory(String s, Int32 index), static System.Double System.Char.GetNumericValue(Char c), static System.Double System.Char.GetNumericValue(String s, Int32 index), static System.Boolean System.Char.IsHighSurrogate(Char c), static System.Boolean System.Char.IsHighSurrogate(String s, Int32 index), static System.Boolean System.Char.IsLowSurrogate(Char c), static System.Boolean System.Char.IsLowSurrogate(String s, Int32 index), static System.Boolean System.Char.IsSurrogatePair(String s, Int32 index), static System.Boolean System.Char.IsSurrogatePair(Char highSurrogate, Char lowSurrogate), static System.String System.Char.ConvertFromUtf32(Int32 utf32), static System.Int32 System.Char.ConvertToUtf32(Char highSurrogate, Char lowSurrogate), static System.Int32 System.Char.ConvertToUtf32(String s, Int32 index), System.Boolean System.ValueType.Equals(Object obj), System.Int32 System.ValueType.GetHashCode(), System.String System.ValueType.ToString(), void System.Object..ctor(), System.String System.Object.ToString(), System.Boolean System.Object.Equals(Object obj), System.Int32 System.Object.GetHashCode(), System.Type System.Object.GetType()}"
IsPrimitive="True"
IsValueType="True">
<GetElementType>null</GetElementType>
</DebugType>
</GetElementType>
</DebugType>
</GetElementType>
</DebugType>
</Type>
</LocalVariable>
</Item>
<Item>
<LocalVariable
Name="nullable_value"

49
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/Tests/ExpressionEvaluator_Tests.cs

@ -104,12 +104,20 @@ namespace Debugger.Tests @@ -104,12 +104,20 @@ namespace Debugger.Tests
string instanceField = "instance field value";
static string staticField = "static field value";
public class A<T> {
public class B {
public class C<U> {
}
}
}
public static void Main()
{
new ExpressionEvaluator_Tests().Fun("function argument");
}
public void Fun(string arg)
public unsafe void Fun(string arg)
{
bool flag = true;
byte b = 1;
@ -124,6 +132,9 @@ namespace Debugger.Tests @@ -124,6 +132,9 @@ namespace Debugger.Tests
DerivedClass myClass = new DerivedClass();
int*[][,] complexType1 = new int*[][,] { new int*[,] { { (int*)0xDA1D } } };
A<int>.B.C<char>[][,] complexType2 = new A<int>.B.C<char>[0][,];
System.Diagnostics.Debugger.Break();
}
}
@ -136,15 +147,11 @@ namespace Debugger.Tests { @@ -136,15 +147,11 @@ namespace Debugger.Tests {
using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Ast;
using ICSharpCode.NRefactory.Visitors;
using NUnit.Framework;
public partial class DebuggerTests
{
[NUnit.Framework.Test]
public void ExpressionEvaluator_Tests()
{
StartTest();
string input = @"
string expressionsInput = @"
b
i
pi
@ -195,16 +202,21 @@ namespace Debugger.Tests { @@ -195,16 +202,21 @@ namespace Debugger.Tests {
flag
!flag
";
[NUnit.Framework.Test]
public void ExpressionEvaluator_Tests()
{
StartTest();
input = input.Replace("'", "\"");
expressionsInput = expressionsInput.Replace("'", "\"");
foreach(string line in input.Split('\n')) {
foreach(string line in expressionsInput.Split('\n')) {
Eval(line.Trim());
}
// Test member hiding / overloading
Value myClass = process.SelectedStackFrame.GetLocalVariableValue("myClass");
Value myClass = process.SelectedStackFrame.GetLocalVariableValue("myClass").GetPermanentReference();
List<Expression> expressions = new List<Expression>();
foreach(MemberInfo memberInfo in myClass.Type.GetFieldsAndNonIndexedProperties(DebugType.BindingFlagsAll)) {
@ -237,6 +249,19 @@ namespace Debugger.Tests { @@ -237,6 +249,19 @@ namespace Debugger.Tests {
Eval(line.Trim());
}
// Test type round tripping
foreach(DebugLocalVariableInfo locVar in process.SelectedStackFrame.MethodInfo.GetLocalVariables()) {
if (locVar.Name.StartsWith("complexType")) {
TypeReference complexTypeRef = locVar.LocalType.GetTypeReference();
string code = "typeof(" + complexTypeRef.PrettyPrint() + ")";
TypeOfExpression complexTypeRefRT = (TypeOfExpression)ExpressionEvaluator.Parse(code, SupportedLanguage.CSharp);
DebugType type = complexTypeRefRT.TypeReference.ResolveType(process.SelectedStackFrame.AppDomain);
string status = locVar.LocalType.FullName == type.FullName ? "ok" : "fail";
ObjectDumpToString("TypeResulution", string.Format(" {0} = {1} ({2})", code, type.FullName, status));
}
}
EndTest();
}
@ -271,7 +296,7 @@ namespace Debugger.Tests { @@ -271,7 +296,7 @@ namespace Debugger.Tests {
<ProcessStarted />
<ModuleLoaded>mscorlib.dll (No symbols)</ModuleLoaded>
<ModuleLoaded>ExpressionEvaluator_Tests.exe (Has symbols)</ModuleLoaded>
<DebuggingPaused>Break ExpressionEvaluator_Tests.cs:127,4-127,40</DebuggingPaused>
<DebuggingPaused>Break ExpressionEvaluator_Tests.cs:138,4-138,40</DebuggingPaused>
<Eval> </Eval>
<Eval> b = 1 </Eval>
<Eval> i = 4 </Eval>
@ -352,6 +377,8 @@ namespace Debugger.Tests { @@ -352,6 +377,8 @@ namespace Debugger.Tests {
<Eval> myClass.Convert(1, 2) = Incorrect parameter type for 's'. Excpeted System.String, seen System.Int32 </Eval>
<Eval> myClass.Convert("abc", 2) = "converted to abc and 2" </Eval>
<Eval> </Eval>
<TypeResulution> typeof(System.Int32*[][,]) = System.Int32*[,][] (ok)</TypeResulution>
<TypeResulution> typeof(Debugger.Tests.ExpressionEvaluator_Tests.A&lt;System.Int32&gt;.B.C&lt;System.Char&gt;[][,]) = Debugger.Tests.ExpressionEvaluator_Tests+A`1+B+C`1[System.Int32,System.Char][,][] (ok)</TypeResulution>
<ProcessExited />
</Test>
</DebuggerTests>

Loading…
Cancel
Save