Bug 8592 - System.Configuration.ApplicationSettingsBase performs Reset() for user.config instead of proper Reload() behavior described on MSDN
Summary: System.Configuration.ApplicationSettingsBase performs Reset() for user.config...
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Configuration (show other bugs)
Version: master
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-11-26 05:21 UTC by Kei Nakazawa
Modified: 2012-11-27 02:16 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


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


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Kei Nakazawa 2012-11-26 05:21:50 UTC
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 UTC
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 UTC
Applied the fix. Thanks!

[master 2ce7995]