[Mono-bugs] [Bug 56731][Nor] New - Alias does not take precedent when two classes have the same name
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Thu, 8 Apr 2004 20:36:44 -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 gmiyake@carter-inc.com.
http://bugzilla.ximian.com/show_bug.cgi?id=56731
--- shadow/56731 2004-04-08 20:36:44.000000000 -0400
+++ shadow/56731.tmp.15298 2004-04-08 20:36:44.000000000 -0400
@@ -0,0 +1,159 @@
+Bug#: 56731
+Product: Mono: Compilers
+Version: unspecified
+OS: Red Hat 9.0
+OS Details: RH 9, Mono 0.31.99
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: C#
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: gmiyake@carter-inc.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Alias does not take precedent when two classes have the same name
+
+Please fill in this template when reporting a bug, unless you know what
+you are doing.
+Description of Problem:
+
+When there are two classes with the same name, setting an alias for the
+class name (that has the same class name) does not work. For instance, if
+there are two classes named Class1 from different namespaces, an alias
+can be set with "using Class1 = NameSpace1.Class1;". In .NET 1.1 this
+will mean that all references to Class1 will resolve to
+NameSpace1.Class1, references to NameSpace2.Class1 will have to be fully
+qualified. Currently Mono does not recognize the alias.
+
+Steps to reproduce the problem:
+1. Compile the following code. (This compiles in .NET 1.1)
+2.
+3.
+
+Actual Results:
+make
+source files: Main.cs NameSpace1Class1.cs NameSpace2Class1.cs
+mcs -g /target:exe Main.cs NameSpace1Class1.cs NameSpace2Class1.cs
+Main.cs(29) error CS1502: The best overloaded match for method 'void
+Driver.Driver.method1 (AliasTest.NameSpac
+e1.Class1)' has some invalid arguments
+Main.cs(29) error CS1503: Argument 0: Cannot convert
+from 'AliasTest.NameSpace2.Class1' to 'AliasTest.NameSpac
+e1.Class1'
+Main.cs(29) error CS1501: No overload for method `method1' takes `1'
+arguments
+Main.cs(29) error CS8006: Could not find any applicable function for this
+argument list
+Compilation failed: 4 error(s), 0 warnings
+make: *** [AliasTest.exe] Error 1
+
+Expected Results:
+Clean compile. The alias should take precedence for the class name.
+
+How often does this happen?
+Always.
+
+Additional Information:
+The three files used for the test follow.
+
+
+--------------------------------------------------------------
+File: Main.cs
+
+using System;
+using Class1 = AliasTest.NameSpace1.Class1;
+using AliasTest.NameSpace2;
+
+namespace Driver
+{
+ /// <summary>
+ /// Summary description for Class1.
+ /// </summary>
+ public class Driver {
+ public void method1(AliasTest.NameSpace1.Class1 pArg1)
+ {
+ Console.WriteLine("Method 1 arg id is : " + pArg1.Id);
+ }
+
+ public void method2(AliasTest.NameSpace2.Class1 pArg1)
+ {
+ Console.WriteLine("Method 2 arg id is : " + pArg1.Id);
+ }
+ /// <summary>
+ /// The main entry point for the application.
+ /// </summary>
+ [STAThread]
+ static void Main(string[] args)
+ {
+
+ Class1 cl1 = new Class1();
+ Driver drv = new Driver();
+ drv.method1(cl1);
+
+ Console.WriteLine("Using just Class1, id is " + cl1.Id);
+ AliasTest.NameSpace2.Class1 cl2 = new
+AliasTest.NameSpace2.Class1();
+ Console.WriteLine("Using fully qualified name
+AliasTest.NameSpace2.Class1, id is " + cl2.Id);
+ Console.WriteLine("Press Enter to exit.");
+ Console.ReadLine();
+ }
+ }
+}
+
+------------------------------------------------------------------------
+File:NameSpace1Class1.cs
+using System;
+
+namespace AliasTest.NameSpace1
+{
+ /// <summary>
+ /// Summary description for Class1.
+ /// </summary>
+ public class Class1
+ {
+ private int myInt = 0;
+
+ public Class1()
+ {
+ }
+
+ public int Id
+ {
+ get
+ {
+ return myInt;
+ }
+ }
+ }
+}
+
+--------------------------------------------------------------------------
+File: NameSpace2Class1.cs
+using System;
+
+namespace AliasTest.NameSpace2
+{
+ /// <summary>
+ /// Summary description for NameSpace2Class1.
+ /// </summary>
+ public class Class1
+ {
+ private int myInt = 2;
+
+ public Class1()
+ {
+ }
+
+ public int Id
+ {
+ get
+ {
+ return myInt;
+ }
+ }
+ }
+}