+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.
throw new NotImplementedException ();
}
- [MonoTODO]
public static SettingsBase Synchronized (SettingsBase settingsBase)
{
- return new SyncSettingsBase (settingsBase);
+ settingsBase.sync = true;
+ return settingsBase;
}
public virtual SettingsContext Context {
[Browsable (false)]
public bool IsSynchronized {
- get { return false; }
+ get { return sync; }
}
public virtual object this [ string propertyName ] {
}
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 {
}
}
+ 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;
- }
- }
- }
}
}
}
public bool IsSynchronized {
- get {
- throw new NotImplementedException ();
- }
+ get { return false; }
}
public SettingsProperty this [ string name ] {
}
public object SyncRoot {
- get {
- throw new NotImplementedException ();
- }
+ get { return this; }
}
}
}
[Test]
- [Category ("NotWorking")]
+ [Ignore ("On MS.NET it returns null ...")]
public void TestSettings3_Properties ()
{
TestSettings3 settings = new TestSettings3 ();
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
+ {
+ }
}
}
--- /dev/null
+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.
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");
}
+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.
}
[Test]
+#if NET_2_0
+ [Ignore ("this test depends on 1.x configuration type")]
+#endif
public void NewSwitch ()
{
AssertEquals ("#NS:Value", "42", tns.Value);