Author: atsushi
Date: 2006-05-17 13:20:02 -0400 (Wed, 17 May 2006)
New Revision: 60792

Added:
   trunk/mcs/class/System/Test/System.Configuration/ChangeLog
Modified:
   trunk/mcs/class/System/System.Configuration/ChangeLog
   trunk/mcs/class/System/System.Configuration/SettingsBase.cs
   trunk/mcs/class/System/System.Configuration/SettingsPropertyCollection.cs
   
trunk/mcs/class/System/Test/System.Configuration/ApplicationSettingsBaseTest.cs
   
trunk/mcs/class/System/Test/System.Configuration/LocalFileSettingsProviderTest.cs
   trunk/mcs/class/System/Test/System.Diagnostics/ChangeLog
   trunk/mcs/class/System/Test/System.Diagnostics/SwitchesTest.cs
Log:
2006-05-17  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * 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.



Modified: trunk/mcs/class/System/System.Configuration/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.Configuration/ChangeLog       2006-05-17 
17:03:10 UTC (rev 60791)
+++ trunk/mcs/class/System/System.Configuration/ChangeLog       2006-05-17 
17:20:02 UTC (rev 60792)
@@ -1,3 +1,10 @@
+2006-05-17  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * 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  <[EMAIL PROTECTED]>
 
        * ConfigurationSettings.cs : another System.Orgy insanity.

Modified: trunk/mcs/class/System/System.Configuration/SettingsBase.cs
===================================================================
--- trunk/mcs/class/System/System.Configuration/SettingsBase.cs 2006-05-17 
17:03:10 UTC (rev 60791)
+++ trunk/mcs/class/System/System.Configuration/SettingsBase.cs 2006-05-17 
17:20:02 UTC (rev 60792)
@@ -53,10 +53,10 @@
                        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 @@
 
                [Browsable (false)]
                public bool IsSynchronized {
-                       get { return false; }
+                       get { return sync; }
                }
 
                public virtual object this [ string propertyName ] {
@@ -74,20 +74,35 @@
                }
 
                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 @@
                        }
                }
 
+               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;
-                               }
-                       }
-               }
        }
 }
 

Modified: 
trunk/mcs/class/System/System.Configuration/SettingsPropertyCollection.cs
===================================================================
--- trunk/mcs/class/System/System.Configuration/SettingsPropertyCollection.cs   
2006-05-17 17:03:10 UTC (rev 60791)
+++ trunk/mcs/class/System/System.Configuration/SettingsPropertyCollection.cs   
2006-05-17 17:20:02 UTC (rev 60792)
@@ -138,9 +138,7 @@
                }
 
                public bool IsSynchronized {
-                       get {
-                               throw new NotImplementedException ();
-                       }
+                       get { return false; }
                }
 
                public SettingsProperty this [ string name ] {
@@ -150,9 +148,7 @@
                }
 
                public object SyncRoot {
-                       get {
-                               throw new NotImplementedException ();
-                       }
+                       get { return this; }
                }
        }
 

Modified: 
trunk/mcs/class/System/Test/System.Configuration/ApplicationSettingsBaseTest.cs
===================================================================
--- 
trunk/mcs/class/System/Test/System.Configuration/ApplicationSettingsBaseTest.cs 
    2006-05-17 17:03:10 UTC (rev 60791)
+++ 
trunk/mcs/class/System/Test/System.Configuration/ApplicationSettingsBaseTest.cs 
    2006-05-17 17:20:02 UTC (rev 60792)
@@ -279,7 +279,7 @@
                }
 
                [Test]
-               [Category ("NotWorking")]
+               [Ignore ("On MS.NET it returns null ...")]
                public void TestSettings3_Properties ()
                {
                        TestSettings3 settings = new TestSettings3 ();
@@ -292,6 +292,25 @@
                        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
+               {
+               }
        }
 
 }

Added: trunk/mcs/class/System/Test/System.Configuration/ChangeLog
===================================================================
--- trunk/mcs/class/System/Test/System.Configuration/ChangeLog  2006-05-17 
17:03:10 UTC (rev 60791)
+++ trunk/mcs/class/System/Test/System.Configuration/ChangeLog  2006-05-17 
17:20:02 UTC (rev 60792)
@@ -0,0 +1,6 @@
+2006-05-17  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * LocalFileSettingsProviderTest.cs : commented some lines in
+         Initialized() as they don't work under .NET.
+       * ApplicationSettingsBaseTest.cs : added Synchronized(), test for
+         bug #78430.


Property changes on: trunk/mcs/class/System/Test/System.Configuration/ChangeLog
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: 
trunk/mcs/class/System/Test/System.Configuration/LocalFileSettingsProviderTest.cs
===================================================================
--- 
trunk/mcs/class/System/Test/System.Configuration/LocalFileSettingsProviderTest.cs
   2006-05-17 17:03:10 UTC (rev 60791)
+++ 
trunk/mcs/class/System/Test/System.Configuration/LocalFileSettingsProviderTest.cs
   2006-05-17 17:20:02 UTC (rev 60792)
@@ -74,8 +74,10 @@
                        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");
                }
 
 

Modified: trunk/mcs/class/System/Test/System.Diagnostics/ChangeLog
===================================================================
--- trunk/mcs/class/System/Test/System.Diagnostics/ChangeLog    2006-05-17 
17:03:10 UTC (rev 60791)
+++ trunk/mcs/class/System/Test/System.Diagnostics/ChangeLog    2006-05-17 
17:20:02 UTC (rev 60792)
@@ -1,3 +1,8 @@
+2006-05-17  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * SwitchesTest.cs : Ignore NewSwitch under 2.0 as it fails under
+         .NET.
+
 2006-04-04  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * StopwatchTest.cs : new test.

Modified: trunk/mcs/class/System/Test/System.Diagnostics/SwitchesTest.cs
===================================================================
--- trunk/mcs/class/System/Test/System.Diagnostics/SwitchesTest.cs      
2006-05-17 17:03:10 UTC (rev 60791)
+++ trunk/mcs/class/System/Test/System.Diagnostics/SwitchesTest.cs      
2006-05-17 17:20:02 UTC (rev 60792)
@@ -131,6 +131,9 @@
                }
 
                [Test]
+#if NET_2_0
+               [Ignore ("this test depends on 1.x configuration type")]
+#endif
                public void NewSwitch ()
                {
                        AssertEquals ("#NS:Value", "42", tns.Value);

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to