[Mono-bugs] [Bug 42973][Wis] New - MCS produced exe failes with compex inheritance from interfaces

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Wed, 14 May 2003 10:47:26 -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 roboto@gmx.net.

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

--- shadow/42973	Wed May 14 10:47:26 2003
+++ shadow/42973.tmp.26848	Wed May 14 10:47:26 2003
@@ -0,0 +1,95 @@
+Bug#: 42973
+Product: Mono/MCS
+Version: unspecified
+OS: GNU/Linux [Other]
+OS Details: Mono/MCS from CVS at date: 13. May 2003
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: Misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: roboto@gmx.net               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Summary: MCS produced exe failes with compex inheritance from interfaces
+
+Description of Problem:
+System.NullReferenceException occurs when the following code is compiled
+with mcs and run in mono:
+<code>
+  using System;
+
+  namespace ConsoleApplication
+  {
+    public interface ICommand {
+      void Run();
+    }
+
+    public interface ISubCommand : ICommand {}
+
+    public abstract class AbstractCommand : ICommand {
+      public abstract void Run();
+    }
+
+    public abstract class AbstractSubCommand : AbstractCommand, ISubCommand {}
+
+    public class TestCommand : AbstractSubCommand {
+      public override void Run() {
+        Console.WriteLine("Hello from: TestCommand");
+      }
+    }
+
+	  class Class1
+	  {
+		  static void Main(string[] args) {
+        TestCommand foo =  new TestCommand();
+        ((ICommand)foo).Run();
+        Console.ReadLine();
+		  }
+	  }
+  }
+</code>
+
+The inheritance is a bit complex and comes out of a existing software and
+this works on .NET and wiht csc compiled Exe's.
+
+As a base, there is ICommand that defines a 'void Run()'.
+ISubCommand is inherited from ICommand.
+AbstractCommand iherited form Command and AbstractSubcommand inherits from
+AbstractCommand and ISubCommand.
+The last Class is TestCommand, it inherits from AbstractSubCommand and so
+it inherits from AbstractCommand, ISubCommand and ICommand.
+
+If you call now on a instance of TestCommand:
+((ICommand)foo).Run();
+A NullReferenceException is thrown.
+But this should be alowed since it inherits from ICommand (it Inherits from
+ICommand 2 times!)
+
+Compiled on windows/.net this wokrs.
+The windows/.net exe also works on linux/mono.
+
+Compiled with linux/mono a exception throws.
+The linux/mono exe can't be run in windows/.net
+
+Steps to reproduce the problem:
+1. Compile above code
+2. run the exe with mono
+
+Actual Results:
+Unhandled Exception: System.NullReferenceException: A null value was found
+where an object instance was required
+in (unmanaged) 00 ConsoleApplication.AbstractCommand:Run ()
+in <0x0000e> 00 ConsoleApplication.AbstractSubCommand:ICommand.Run ()
+in <0x0003b> 00 ConsoleApplication.Class1:Main (string[])
+
+Expected Results:
+Hello from: TestCommand
+
+How often does this happen? 
+Always
+
+Additional Information:
+<none>