This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 8592 - System.Configuration.ApplicationSettingsBase performs Reset() for user.config instead of proper Reload() behavior described on MSDN
: System.Configuration.ApplicationSettingsBase performs Reset() for user.config...
Status: RESOLVED FIXED
Product: Class Libraries
Classification: Mono
Component: Configuration
: Trunk
: Macintosh Mac OS
: --- normal
: ---
Assigned To: Bugzilla
:
:
:
:
  Show dependency treegraph
 
Reported: 2012-11-26 05:21 EST by Kei Nakazawa
Modified: 2012-11-27 02:16 EST (History)
2 users (show)

See Also:
Tags:
Test Case URL:
External Submit: ---


Attachments
fix for bug 8592 (6.79 KB, patch)
2012-11-27 01:22 EST, Kei Nakazawa
Details | Diff

Description Kei Nakazawa 2012-11-26 05:21:50 EST
Mono version of Reload() method actually resets configuration values instead of
reloading from persistent storage as described:
http://msdn.microsoft.com/en-us/library/system.configuration.applicationsettingsbase.reload(v=vs.80).aspx
repro code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Diagnostics;

namespace ApplicationSettingsBaseBehaviorTest
{
    class ConfHolder1 : ApplicationSettingsBase {
        [UserScopedSetting]
        public string TestKey1OnHolder1 { get { return
(string)this["TestKey1OnHolder1"] ?? ""; } set { this["TestKey1OnHolder1"] =
value; } }
    }
    class Program
    {
        static void Main(string[] args)
        {
            var holder = new ConfHolder1();
            holder.TestKey1OnHolder1 = "candy";
            holder.Save();
            Console.WriteLine(holder.TestKey1OnHolder1 == "candy" ? "ok" : "not
ok");
            holder.TestKey1OnHolder1 = "donut";
            Console.WriteLine(holder.TestKey1OnHolder1 == "donut" ? "ok" : "not
ok");
            holder.Reload();
            Console.WriteLine(holder.TestKey1OnHolder1 == "candy" ? "ok" : "not
ok");
            holder.Reset();
            Console.WriteLine(holder.TestKey1OnHolder1 == "" ? "ok" : "not
ok");
        }
    }
}

MS Runtime output:
ok
ok
ok
ok

Mono (master/5d436f9) Runtime output:
ok
ok
not ok
ok

this issue is realted to https://bugzilla.xamarin.com/show_bug.cgi?id=8533 but
is independent.
Comment 1 Kei Nakazawa 2012-11-27 01:22:18 EST
Created attachment 3017 [details]
fix for bug 8592

this patch satisfies needed behavior
 * Reset() should not flush current data to persistent storage
 * Reset() should restore default values by property definitions
 * Reload() should not be an alias for Reset()

I know there might be a better fix but not yet familiar with Mono tweaking
manner. Any comments would be appreciated.
Comment 2 Atsushi Eno 2012-11-27 02:16:44 EST
Applied the fix. Thanks!

[master 2ce7995]

Note You need to log in before you can comment on or make changes to this bug.