[Mono-bugs] [Bug 61902][Wis] Changed - Invalid warning CS0618 when invoking obsolete ctor from other ctor

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Fri, 13 Aug 2004 12:24:32 -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 gert.driesen@pandora.be.

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

--- shadow/61902	2004-08-08 12:41:06.000000000 -0400
+++ shadow/61902.tmp.5781	2004-08-13 12:24:32.000000000 -0400
@@ -3,13 +3,13 @@
 Version: unspecified
 OS: unknown
 OS Details: 
 Status: NEW   
 Resolution: 
 Severity: Unknown
-Priority: Normal
+Priority: Wishlist
 Component: C#
 AssignedTo: marek.safar@seznam.cz                            
 ReportedBy: gert.driesen@pandora.be               
 QAContact: mono-bugs@ximian.com
 TargetMilestone: ---
 URL: 
@@ -44,6 +44,69 @@
 ------- Additional Comments From marek.safar@seznam.cz  2004-08-08 12:41 -------
 I think it's Microsoft bug. C# spec says:
 
 If a program uses a type or member that is decorated with the Obsolete
 attribute, then the compiler shall issue a warning or error in order
 to alert the developer, so the offending code can be fixed.
+
+------- Additional Comments From gert.driesen@pandora.be  2004-08-13 12:24 -------
+Marek,
+
+CSC does not output obsolete warnings when the obsolete members are 
+invoked in the class in which they are defined.
+
+Consider the following source :
+
+using System;
+
+public class Test
+{
+	private string _name;
+
+	[Obsolete()]
+	public Test() : this("layout", false)
+	{
+	}
+
+	[Obsolete()]
+	public Test(string a, bool writeToErrorStream)
+	{
+		Name = a;
+	}
+
+	[Obsolete()]
+	public string Name
+	{
+		get { return _name; }
+		set { _name = value; }
+	}
+}
+
+public class DerivedTest : Test
+{
+	public DerivedTest(string a) : base(a, false)
+        {
+		Name = a;
+	}
+}
+
+Compiling this using csc will result in the following warnings :
+
+test.cs(27,9): warning CS0612: 'Test.Test(string, bool)' is obsolete
+test.cs(28,3): warning CS0612: 'Test.Name' is obsolete
+
+So you'll only get warnings for the invocation of the obsolete 
+members of "Test" from the derived class "DerivedTest", not for 
+invoking these obsolete members from "Test" itself.
+
+Mono outputs the following warnings for the same code :
+
+test.cs(8) warning CS0612: 'Test.Test(string, bool)' is obsolete
+test.cs(15) warning CS0612: 'Test.Name[string]' is obsolete
+test.cs(27) warning CS0612: 'Test.Test(string, bool)' is obsolete
+test.cs(28) warning CS0612: 'Test.Name[string]' is obsolete
+
+Only the last two warnings are actually valid.
+
+I know the specs aren't very clear about this, but I talked about 
+this with Ben Maurer and he think mcs should match the behaviour of 
+csc here.