2006-05-17 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Wed, 17 May 2006 17:20:02 +0000 (17:20 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Wed, 17 May 2006 17:20:02 +0000 (17:20 -0000)
* SettingsPropertyCollection.cs : implemented some synchronization
  releated members. Actually it can never be synchronized by itself.
* SettingsBase.cs : Synchronized() just returns the same instance,
  marking it as IsSynchronized = true. Fixed bug #78430.

* LocalFileSettingsProviderTest.cs : commented some lines in
  Initialized() as they don't work under .NET.
* ApplicationSettingsBaseTest.cs : added Synchronized(), test for
  bug #78430.

* SwitchesTest.cs : Ignore NewSwitch under 2.0 as it fails under
  .NET.

svn path=/trunk/mcs/; revision=60792

mcs/class/System/System.Configuration/ChangeLog
mcs/class/System/System.Configuration/SettingsBase.cs
mcs/class/System/System.Configuration/SettingsPropertyCollection.cs
mcs/class/System/Test/System.Configuration/ApplicationSettingsBaseTest.cs
mcs/class/System/Test/System.Configuration/ChangeLog [new file with mode: 0644]
mcs/class/System/Test/System.Configuration/LocalFileSettingsProviderTest.cs
mcs/class/System/Test/System.Diagnostics/ChangeLog
mcs/class/System/Test/System.Diagnostics/SwitchesTest.cs

index 0513527cdd8072a36fd24482dc31b5d5044c1c0a..22a6349361a4f072e1af8b3c7a7cc8ea6457614f 100644 (file)
@@ -1,3 +1,10 @@
+2006-05-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SettingsPropertyCollection.cs : implemented some synchronization
+         releated members. Actually it can never be synchronized by itself.
+       * SettingsBase.cs : Synchronized() just returns the same instance,
+         marking it as IsSynchronized = true. Fixed bug #78430.
+
 2006-05-12  Atsushi Enomoto  <atsushi@ximian.com>
 
        * ConfigurationSettings.cs : another System.Orgy insanity.
index 7caf836185d5e6279db58d25c40908c2cff6405f..093acbf7fc9a41078d75af69138e04215e7f4152 100644 (file)
@@ -53,10 +53,10 @@ namespace System.Configuration
                        throw new NotImplementedException ();
                }
 
-               [MonoTODO]
                public static SettingsBase Synchronized (SettingsBase settingsBase)
                {
-                       return new SyncSettingsBase (settingsBase);
+                       settingsBase.sync = true;
+                       return settingsBase;
                }
 
                public virtual SettingsContext Context {
@@ -65,7 +65,7 @@ namespace System.Configuration
 
                [Browsable (false)]
                public bool IsSynchronized {
-                       get { return false; }
+                       get { return sync; }
                }
 
                public virtual object this [ string propertyName ] {
@@ -74,20 +74,35 @@ namespace System.Configuration
                }
 
                public virtual SettingsPropertyCollection Properties {
-                       get { return properties; }
+                       get {
+                               // It seems that Properties.IsSynchronized is
+                               // nothing to do with this.IsSynchronized.
+                               return properties;
+                       }
                }
 
                public virtual SettingsPropertyValueCollection PropertyValues {
                        get {
-                               SettingsPropertyValueCollection col = new SettingsPropertyValueCollection ();
-
-                               foreach (SettingsProperty prop in properties)
-                               {
-                                       col.Add (new SettingsPropertyValue (prop));
+                               if (sync) {
+                                       lock (this) {
+                                               return GetPropertyValues ();
+                                       }
                                }
+                               else
+                                       return GetPropertyValues ();
+                       }
+               }
 
-                               return col;
+               SettingsPropertyValueCollection GetPropertyValues ()
+               {
+                       SettingsPropertyValueCollection col = new SettingsPropertyValueCollection ();
+
+                       foreach (SettingsProperty prop in properties)
+                       {
+                               col.Add (new SettingsPropertyValue (prop));
                        }
+
+                       return col;
                }
 
                public virtual SettingsProviderCollection Providers {
@@ -96,73 +111,10 @@ namespace System.Configuration
                        }
                }
 
+               bool sync;
                SettingsContext context;
                SettingsPropertyCollection properties;
                SettingsProviderCollection providers;
-
-               private class SyncSettingsBase : SettingsBase
-               {
-                       SettingsBase host;
-                       object syncRoot;
-
-                       public SyncSettingsBase (SettingsBase host)
-                       {
-                               this.host = host;
-                               syncRoot = host;
-                       }
-
-                       public override void Save ()
-                       {
-                               lock (syncRoot) {
-                                       host.Save ();
-                               }
-                       }
-
-                       public override object this [ string propertyName ] {
-                               get { return host[propertyName]; }
-                               set {
-                                       lock (syncRoot) {
-                                               host[propertyName] = value;
-                                       }
-                               }
-                       }
-
-                       public override SettingsPropertyCollection Properties {
-                               get {
-                                       SettingsPropertyCollection props;
-
-                                       lock (syncRoot) {
-                                               props = host.Properties;
-                                       }
-
-                                       return props;
-                               }
-                       }
-
-                       public virtual SettingsPropertyValueCollection PropertyValues {
-                               get {
-                                       SettingsPropertyValueCollection vals;
-
-                                       lock (syncRoot) {
-                                               vals = host.PropertyValues;
-                                       }
-
-                                       return vals;
-                               }
-                       }
-
-                       public virtual SettingsProviderCollection Providers {
-                               get {
-                                       SettingsProviderCollection prov;
-
-                                       lock (syncRoot) {
-                                               prov = host.Providers;
-                                       }
-
-                                       return prov;
-                               }
-                       }
-               }
        }
 }
 
index 1fd0348a902ea3ed2be48eceaff7c8314e8d0b42..1e894f5bff466ce12720dd38df202a7601f88158 100644 (file)
@@ -138,9 +138,7 @@ namespace System.Configuration
                }
 
                public bool IsSynchronized {
-                       get {
-                               throw new NotImplementedException ();
-                       }
+                       get { return false; }
                }
 
                public SettingsProperty this [ string name ] {
@@ -150,9 +148,7 @@ namespace System.Configuration
                }
 
                public object SyncRoot {
-                       get {
-                               throw new NotImplementedException ();
-                       }
+                       get { return this; }
                }
        }
 
index d3aab5064bec28ebb91a45c179c0689fbf90d8f7..35388287108c647203825d0bc06591ffa205277b 100644 (file)
@@ -279,7 +279,7 @@ namespace MonoTests.System.Configuration {
                }
 
                [Test]
-               [Category ("NotWorking")]
+               [Ignore ("On MS.NET it returns null ...")]
                public void TestSettings3_Properties ()
                {
                        TestSettings3 settings = new TestSettings3 ();
@@ -292,6 +292,25 @@ namespace MonoTests.System.Configuration {
                        ApplicationSettingsBaseTest test = new ApplicationSettingsBaseTest();
                        test.TestSettings1_Properties();
                }
+
+               [Test]
+               public void Synchronized ()
+               {
+                       Bug78430 s = new Bug78430 ();
+                       s.Initialize (null, new SettingsPropertyCollection (),
+                               new SettingsProviderCollection ());
+                       SettingsBase sb = SettingsBase.Synchronized (s);
+                       Assert.IsTrue (sb.IsSynchronized, "#1");
+                       Assert.IsTrue (sb is Bug78430, "#2");
+                       // these checks are so cosmetic, actually not
+                       // worthy of testing.
+                       Assert.IsTrue (Object.ReferenceEquals (s, sb), "#3");
+                       Assert.IsFalse (sb.Properties.IsSynchronized, "#4");
+               }
+
+               class Bug78430 : SettingsBase
+               {
+               }
        }
 
 }
diff --git a/mcs/class/System/Test/System.Configuration/ChangeLog b/mcs/class/System/Test/System.Configuration/ChangeLog
new file mode 100644 (file)
index 0000000..947b84b
--- /dev/null
@@ -0,0 +1,6 @@
+2006-05-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * LocalFileSettingsProviderTest.cs : commented some lines in
+         Initialized() as they don't work under .NET.
+       * ApplicationSettingsBaseTest.cs : added Synchronized(), test for
+         bug #78430.
index af399e2f29e485570f127d8f5697e517b4119692..3e4ce9ac72d4373aa30682587bc02667a92ddd6d 100644 (file)
@@ -74,8 +74,10 @@ namespace MonoTests.System.Configuration {
                        nv.Add ("applicationName", "appName");
 
                        prov.Initialize ("hi", nv);
-                       Assert.AreEqual ("hi", prov.Name, "A3");
-                       Assert.AreEqual ("appName", prov.ApplicationName, "A4");
+                       // As these lines below shows, Initialize() behavior is unpredictable. Here I just comment out them and fix run-test-ondotnet tests.
+                       //Assert.AreEqual ("hi", prov.Name, "A3");
+                       //Assert.AreEqual ("hi", prov.Description, "A3.5");
+                       //Assert.AreEqual ("", prov.ApplicationName, "A4");
                }
 
 
index da46e73324e167ceec3e26bf050cded793f27e31..c3381a569c810fa235631368d2556b45907b4643 100644 (file)
@@ -1,3 +1,8 @@
+2006-05-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SwitchesTest.cs : Ignore NewSwitch under 2.0 as it fails under
+         .NET.
+
 2006-04-04  Atsushi Enomoto  <atsushi@ximian.com>
 
        * StopwatchTest.cs : new test.
index 503c56845c3e0544a306390e1910403bebaa21ec..a5574b0275d9b110754eaa8a6797e4f6e77a4dd6 100644 (file)
@@ -131,6 +131,9 @@ namespace MonoTests.System.Diagnostics {
                }
 
                [Test]
+#if NET_2_0
+               [Ignore ("this test depends on 1.x configuration type")]
+#endif
                public void NewSwitch ()
                {
                        AssertEquals ("#NS:Value", "42", tns.Value);