|
|
|
@ -496,24 +496,24 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem
@@ -496,24 +496,24 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem
|
|
|
|
|
Assert.IsTrue(f.IsConst); |
|
|
|
|
Assert.AreEqual(Accessibility.Public, f.Accessibility); |
|
|
|
|
Assert.AreSame(e, f.Type); |
|
|
|
|
Assert.AreEqual(typeof(short), f.ConstantValue.GetType()); |
|
|
|
|
Assert.AreEqual(typeof(short), f.GetConstantValue().GetType()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Assert.AreEqual("First", fields[0].Name); |
|
|
|
|
Assert.AreEqual(0, fields[0].ConstantValue); |
|
|
|
|
Assert.AreEqual(0, fields[0].GetConstantValue()); |
|
|
|
|
|
|
|
|
|
Assert.AreEqual("Second", fields[1].Name); |
|
|
|
|
Assert.AreSame(e, fields[1].Type); |
|
|
|
|
Assert.AreEqual(1, fields[1].ConstantValue); |
|
|
|
|
Assert.AreEqual(1, fields[1].GetConstantValue()); |
|
|
|
|
|
|
|
|
|
Assert.AreEqual("Flag1", fields[2].Name); |
|
|
|
|
Assert.AreEqual(0x10, fields[2].ConstantValue); |
|
|
|
|
Assert.AreEqual(0x10, fields[2].GetConstantValue()); |
|
|
|
|
|
|
|
|
|
Assert.AreEqual("Flag2", fields[3].Name); |
|
|
|
|
Assert.AreEqual(0x20, fields[3].ConstantValue); |
|
|
|
|
Assert.AreEqual(0x20, fields[3].GetConstantValue()); |
|
|
|
|
|
|
|
|
|
Assert.AreEqual("CombinedFlags", fields[4].Name); |
|
|
|
|
Assert.AreEqual(0x30, fields[4].ConstantValue); |
|
|
|
|
Assert.AreEqual(0x30, fields[4].GetConstantValue()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
@ -773,7 +773,7 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem
@@ -773,7 +773,7 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem
|
|
|
|
|
Assert.IsFalse(p.IsParams); |
|
|
|
|
Assert.IsTrue(p.HasConstantValueInSignature); |
|
|
|
|
Assert.AreEqual(0, p.GetAttributes().Count()); |
|
|
|
|
Assert.AreEqual(4, p.ConstantValue); |
|
|
|
|
Assert.AreEqual(4, p.GetConstantValue()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
@ -799,7 +799,7 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem
@@ -799,7 +799,7 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem
|
|
|
|
|
Assert.IsFalse(p.IsParams); |
|
|
|
|
Assert.IsTrue(p.HasConstantValueInSignature); |
|
|
|
|
Assert.AreEqual(0, p.GetAttributes().Count()); |
|
|
|
|
Assert.AreEqual((int)StringComparison.OrdinalIgnoreCase, p.ConstantValue); |
|
|
|
|
Assert.AreEqual((int)StringComparison.OrdinalIgnoreCase, p.GetConstantValue()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
@ -812,7 +812,7 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem
@@ -812,7 +812,7 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem
|
|
|
|
|
Assert.IsFalse(p.IsParams); |
|
|
|
|
Assert.IsTrue(p.HasConstantValueInSignature); |
|
|
|
|
Assert.AreEqual(0, p.GetAttributes().Count()); |
|
|
|
|
Assert.IsNull(p.ConstantValue); |
|
|
|
|
Assert.IsNull(p.GetConstantValue()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
@ -824,8 +824,8 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem
@@ -824,8 +824,8 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem
|
|
|
|
|
Assert.IsFalse(p.IsOut); |
|
|
|
|
Assert.IsFalse(p.IsParams); |
|
|
|
|
Assert.IsTrue(p.HasConstantValueInSignature); |
|
|
|
|
Assert.AreEqual(1L, p.ConstantValue); |
|
|
|
|
Assert.AreEqual(typeof(long), p.ConstantValue.GetType()); |
|
|
|
|
Assert.AreEqual(1L, p.GetConstantValue()); |
|
|
|
|
Assert.AreEqual(typeof(long), p.GetConstantValue().GetType()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
@ -837,8 +837,8 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem
@@ -837,8 +837,8 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem
|
|
|
|
|
Assert.IsFalse(p.IsOut); |
|
|
|
|
Assert.IsFalse(p.IsParams); |
|
|
|
|
Assert.IsTrue(p.HasConstantValueInSignature); |
|
|
|
|
Assert.AreEqual(1L, p.ConstantValue); |
|
|
|
|
Assert.AreEqual(typeof(long), p.ConstantValue.GetType()); |
|
|
|
|
Assert.AreEqual(1L, p.GetConstantValue()); |
|
|
|
|
Assert.AreEqual(typeof(long), p.GetConstantValue().GetType()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
@ -850,8 +850,8 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem
@@ -850,8 +850,8 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem
|
|
|
|
|
Assert.IsFalse(p.IsOut); |
|
|
|
|
Assert.IsFalse(p.IsParams); |
|
|
|
|
Assert.IsTrue(p.HasConstantValueInSignature); |
|
|
|
|
Assert.AreEqual(1M, p.ConstantValue); |
|
|
|
|
Assert.AreEqual(typeof(decimal), p.ConstantValue.GetType()); |
|
|
|
|
Assert.AreEqual(1M, p.GetConstantValue()); |
|
|
|
|
Assert.AreEqual(typeof(decimal), p.GetConstantValue().GetType()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
@ -1509,7 +1509,7 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem
@@ -1509,7 +1509,7 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem
|
|
|
|
|
{ |
|
|
|
|
ITypeDefinition type = GetTypeDefinition(typeof(ClassWithMethodThatHasNullableDefaultParameter)); |
|
|
|
|
var method = type.GetMethods().Single(m => m.Name == "Foo"); |
|
|
|
|
Assert.AreEqual(42, method.Parameters.Single().ConstantValue); |
|
|
|
|
Assert.AreEqual(42, method.Parameters.Single().GetConstantValue()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
@ -1529,7 +1529,7 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem
@@ -1529,7 +1529,7 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem
|
|
|
|
|
{ |
|
|
|
|
var f = type.GetFields().Single(x => x.Name == name); |
|
|
|
|
Assert.IsTrue(f.IsConst); |
|
|
|
|
Assert.AreEqual(expected, f.ConstantValue); |
|
|
|
|
Assert.AreEqual(expected, f.GetConstantValue()); |
|
|
|
|
Assert.AreEqual(0, f.GetAttributes().Count()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1577,7 +1577,7 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem
@@ -1577,7 +1577,7 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem
|
|
|
|
|
ITypeDefinition type = GetTypeDefinition(typeof(ConstantFieldTest)); |
|
|
|
|
IField field = type.Fields.Single(f => f.Name == "EnumFromThisAssembly"); |
|
|
|
|
Assert.IsTrue(field.IsConst); |
|
|
|
|
Assert.AreEqual((short)MyEnum.Second, field.ConstantValue); |
|
|
|
|
Assert.AreEqual((short)MyEnum.Second, field.GetConstantValue()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
@ -1586,7 +1586,7 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem
@@ -1586,7 +1586,7 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem
|
|
|
|
|
ITypeDefinition type = GetTypeDefinition(typeof(ConstantFieldTest)); |
|
|
|
|
IField field = type.Fields.Single(f => f.Name == "EnumFromAnotherAssembly"); |
|
|
|
|
Assert.IsTrue(field.IsConst); |
|
|
|
|
Assert.AreEqual((int)StringComparison.OrdinalIgnoreCase, field.ConstantValue); |
|
|
|
|
Assert.AreEqual((int)StringComparison.OrdinalIgnoreCase, field.GetConstantValue()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
@ -1595,7 +1595,7 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem
@@ -1595,7 +1595,7 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem
|
|
|
|
|
ITypeDefinition type = GetTypeDefinition(typeof(ConstantFieldTest)); |
|
|
|
|
IField field = type.Fields.Single(f => f.Name == "DefaultOfEnum"); |
|
|
|
|
Assert.IsTrue(field.IsConst); |
|
|
|
|
Assert.AreEqual((short)default(MyEnum), field.ConstantValue); |
|
|
|
|
Assert.AreEqual((short)default(MyEnum), field.GetConstantValue()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|