[Mono-bugs] [Bug 76998][Nor] New - Default site's GetService method returns incorrect result

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Wed Dec 14 14:55:53 EST 2005


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 brian at fluggo.com.

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

--- shadow/76998	2005-12-14 14:55:53.000000000 -0500
+++ shadow/76998.tmp.1871	2005-12-14 14:55:53.000000000 -0500
@@ -0,0 +1,98 @@
+Bug#: 76998
+Product: Mono: Class Libraries
+Version: 1.1
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: Unknown
+Priority: Normal
+Component: System
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: brian at fluggo.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Default site's GetService method returns incorrect result
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+The site created by the System.ComponentModel.Container class does not pass
+service requests to its container unless the requested service is of type
+ISite. This is incorrect, although the documentation is unclear as to how
+to treat these requests. The correct behavior is likely that ISite requests
+be intercepted and the site returned, but all other requests are forwarded
+to the container. The .NET implementation exhibits this behavior.
+
+Steps to reproduce the problem:
+Execute the following code:
+
+-------------------------------------------------------
+using System;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+
+namespace Test {
+	class MainClass {
+		public static void Main() {
+			TestContainer container = new TestContainer();
+			Console.WriteLine( "// Results should be not null" );
+			
+			container.Add( new TestComponent() );
+			
+			Console.ReadLine();
+		}
+	}
+	
+	class TestService {
+	}
+	
+	class TestContainer : Container {
+		ServiceContainer _services = new ServiceContainer();
+		
+		public TestContainer() {
+			_services.AddService( typeof(TestService), new TestService() );
+		}
+		
+		protected override object GetService( Type serviceType ) {
+			return _services.GetService( serviceType );
+		}
+	}
+	
+	class TestComponent : Component {
+		public override ISite Site {
+			get {
+				return base.Site;
+			}
+			set {
+				base.Site = value;
+				
+				if( value != null ) {
+					Console.WriteLine( "ISite request result is {0}",
+						(value.GetService( typeof(ISite) ) == null) ? "null" : "not null" );
+					Console.WriteLine( "TestService request result is {0}",
+						(value.GetService( typeof(TestService) ) == null) ? "null" : "not
+null" );
+				}
+			}
+		}
+	}
+}
+
+-------------------------------------------------------
+
+Actual Results:
+Under Mono, both results are null.
+
+Expected Results:
+Under .NET, both requests show non-null results. This behavior, though not
+listed in the documentation, makes far more sense.
+
+How often does this happen? 
+Every time.
+
+Additional Information:
+Offending code can be found in lines 105-108 of Container.cs in the Mono
+source code.


More information about the mono-bugs mailing list