public void GetNestedTypesOfUnboundGenericClass() { ITypeDefinition dictionary = mscorlib.GetTypeDefinition(typeof(Dictionary <,>)); IType keyCollection = dictionary.GetNestedTypes(mscorlib).Single(t => t.Name == "KeyCollection"); Assert.IsTrue(keyCollection is ITypeDefinition); }
public void ClassDerivingFromTwoInstanciationsOfIEnumerable() { // class C : IEnumerable<int>, IEnumerable<uint> {} DefaultTypeDefinition c = new DefaultTypeDefinition(mscorlib, string.Empty, "C"); c.BaseTypes.Add(typeof(IEnumerable <int>).ToTypeReference()); c.BaseTypes.Add(typeof(IEnumerable <uint>).ToTypeReference()); IType[] expected = { c, c.BaseTypes[0].Resolve(context), c.BaseTypes[1].Resolve(context), mscorlib.GetTypeDefinition(typeof(IEnumerable)), mscorlib.GetTypeDefinition(typeof(object)) }; Assert.AreEqual(expected, c.GetAllBaseTypes(context).OrderBy(t => t.ReflectionName).ToArray()); }
ITypeDefinition GetClass(Type type) { return(testCasePC.GetTypeDefinition(type)); }
public void InheritanceTest() { ITypeDefinition c = Mscorlib.GetTypeDefinition(typeof(SystemException)); ITypeDefinition c2 = Mscorlib.GetTypeDefinition(typeof(Exception)); Assert.IsNotNull(c, "c is null"); Assert.IsNotNull(c2, "c2 is null"); //Assert.AreEqual(3, c.BaseTypes.Count); // Inherited interfaces are not reported by Cecil // which matches the behaviour of our C#/VB parsers Assert.AreEqual("System.Exception", c.BaseTypes[0].Resolve(ctx).FullName); Assert.AreSame(c2, c.BaseTypes[0]); string[] superTypes = c.GetAllBaseTypes(ctx).Select(t => t.ToString()).ToArray(); Assert.AreEqual(new string[] { "System.SystemException", "System.Exception", "System.Object", "System.Runtime.Serialization.ISerializable", "System.Runtime.InteropServices._Exception" }, superTypes); }