[Mono-bugs] [Bug 61223][Maj] New - System.Type.GetInterfaces does not report inherited interfaces

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Tue, 6 Jul 2004 20:03:45 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by rbo@acm.org.

http://bugzilla.ximian.com/show_bug.cgi?id=61223

--- shadow/61223	2004-07-06 20:03:45.000000000 -0400
+++ shadow/61223.tmp.20406	2004-07-06 20:03:45.000000000 -0400
@@ -0,0 +1,98 @@
+Bug#: 61223
+Product: Mono: Class Libraries
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Major
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: rbo@acm.org               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: System.Type.GetInterfaces does not report inherited interfaces
+
+Steps to reproduce the problem:
+using System;
+using System.Collections;
+using System.Reflection;
+using System.Reflection.Emit;
+using NUnit.Framework;
+
+namespace MonoTestFixtures
+{
+	[TestFixture]
+	public class GetInterfacesTest
+	{	
+		[Test]
+		public void GetInterfaces()
+		{
+			AssemblyName name = new AssemblyName();
+			name.Name = "GetInterfacesAssembly";
+		
+			AssemblyBuilder assemblyBuilder =
+AppDomain.CurrentDomain.DefineDynamicAssembly(name,AssemblyBuilderAccess.Run);
+			
+			ModuleBuilder moduleBuilder =
+assemblyBuilder.DefineDynamicModule("GetInterfacesModule");
+			
+			/*
+			type hierarchy similar to:
+			
+			interface IFoo
+			{
+			}
+			
+			interface IBar : IFoo
+			{
+			}
+			
+			class Foo : IBar
+			{
+			}
+			*/
+			TypeBuilder ifooBuilder = moduleBuilder.DefineType("IFoo",
+TypeAttributes.Interface|TypeAttributes.Abstract);
+			TypeBuilder ibarBuilder = moduleBuilder.DefineType("IBar",
+TypeAttributes.Interface|TypeAttributes.Abstract);
+			ibarBuilder.AddInterfaceImplementation(ifooBuilder);
+			
+			TypeBuilder fooBuilder = moduleBuilder.DefineType("Foo");
+			fooBuilder.AddInterfaceImplementation(ibarBuilder);
+			
+			Type ifoo = ifooBuilder.CreateType();
+			Type ibar = ibarBuilder.CreateType();
+			Type foo = fooBuilder.CreateType();
+			
+			Assert.IsNotNull(ifoo);
+			Assert.IsNotNull(ibar);
+			Assert.IsNotNull(foo);
+			
+			Type[] interfaces = foo.GetInterfaces();
+			Assert.AreEqual(2, interfaces.Length);
+			Assert.AreEqual(true, ((IList)interfaces).Contains(ifoo));
+			Assert.AreEqual(true, ((IList)interfaces).Contains(ibar));
+		}
+	}
+}
+
+Actual Results:
+
+Test fails (GetInterfaces() reports only one interface).
+
+
+Expected Results:
+
+Successful test run.
+
+How often does this happen? 
+
+Always.
+
+Additional Information:
+
+The test runs fine on ms.net.