[Mono-bugs] [Bug 52611][Wis] Changed - test-53 is invalid

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 11 Mar 2004 12:29:35 -0500 (EST)


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 bmaurer@users.sf.net.

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

--- shadow/52611	2004-03-11 12:17:37.000000000 -0500
+++ shadow/52611.tmp.4224	2004-03-11 12:29:35.000000000 -0500
@@ -44,6 +44,38 @@
 states that the expression.
 
 My reading of the spec is that MCS does implement this, and its a
 missing feature in Microsoft's compiler. 
 
 I have sent an email to Microsoft to confirm this.
+
+------- Additional Comments From bmaurer@users.sf.net  2004-03-11 12:29 -------
+Hrm, the problem is that this could lead to very weird and unexpected 
+behavior. Take this example:
+
+class ManagedPicture {
+        public static implicit operator UnmanagedPicture 
+(ManagedPicture me)
+        {
+                return new UnmanagedPicture (me.Data);
+        }
+}
+
+class UnmanagedPicture : IDisposable {
+   // ...
+}
+
+using (ManagedPicture m = myManagedPicture) {
+}
+
+In this example, there is no need to dispose the ManagedPicture, as 
+it is fully managed, so the using statement is probably a coding 
+error. However, what happens is that an unmanaged picture is created 
+and disposed but never used. I don't think this is the intention of 
+the c# guys.
+
+IMHO, we should go with CSC, as their behavior seems to be more 
+correct and more aligned as to what the user wants. Remember that if 
+you are doing a conversion that you will *HAVE* to allocate a new 
+object (because you cant do a user defined conversion to an iface), 
+and I don't see how a user would intend for that behavior with the 
+statement.