This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 8533 - System.Configuration.ApplicationSettingsBase screws user.config file when used by multiple child classes
: System.Configuration.ApplicationSettingsBase screws user.config file when use...
Product: Class Libraries
Classification: Mono
Component: Configuration
: Trunk
: Macintosh Mac OS
: --- normal
: ---
Assigned To: Bugzilla
  Show dependency treegraph
Reported: 2012-11-20 22:13 EST by Kei Nakazawa
Modified: 2012-11-27 05:53 EST (History)
2 users (show)

See Also:

see "description" for detail (1.46 KB, application/zip)
2012-11-20 22:13 EST, Kei Nakazawa
fix bug 8533 (6.11 KB, patch)
2012-11-27 04:11 EST, Kei Nakazawa
Details | Diff

Description Kei Nakazawa 2012-11-20 22:13:24 EST
Created attachment 2981 [details]
see "description" for detail

repro. code:

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

namespace ApplicationSettingsBaseBehaviorTest
    class ConfHolder1 : ApplicationSettingsBase {
        public string TestKey1OnHolder1 { get { return
(string)this["TestKey1OnHolder1"] ?? ""; } set { this["TestKey1OnHolder1"] =
value; } }
    class ConfHolder2 : ApplicationSettingsBase
        public string TestKey1OnHolder2 { get { return
(string)this["TestKey1OnHolder2"] ?? ""; } set { this["TestKey1OnHolder2"] =
value; } }
    class Program
        static void Main(string[] args)
            var holder1 = new ConfHolder1();
            var holder2 = new ConfHolder2();
            holder1.TestKey1OnHolder1 = "candy";
            holder2.TestKey1OnHolder2 = "donut";

multi sectioned XML should be generated by this code like MS runtime does, but
Mono(tested on 3.0.0beta/master:5d436f92c) runtime
 - properly generates "sectionGroup" node
 - doesn't generate "section" node for ConfHandler2 inside "sectionGroup"
 - doesn't generate proper node for ConfHandler2 inside "userSettings"
 - put all values together into ConfHolder1 space inside "userSettings", which
should be splited into ConfHolder1 subsection and ConfHolder2 subsection (*1:
please refer XML snippet below)

I suspect report is triggered
by this behavior(wrong save -> internal error on next load).

*1: XML snippet
 [MS runtime]
            <setting name="TestKey1OnHolder2" serializeAs="String">
            <setting name="TestKey1OnHolder1" serializeAs="String">
 [/MS runtime]
 [Mono runtime]
  <setting name="TestKey1OnHolder1" serializeAs="String">
  <setting name="TestKey1OnHolder2" serializeAs="String">
 [/Mono runtime]

attached zip contains:
 - Program.cs : repro code(as seen above)
 - : proper user.config file generated by MS runtime(.NET 4.0)
 - user.config.mono : wrong user.config file generated by Mono
Comment 1 Kei Nakazawa 2012-11-27 04:11:17 EST
Created attachment 3019 [details]
fix bug 8533

this patch contains
 * test cases for regression testing
 * fix handling multiple userSections creation
 * suppress mixing up other userSections' data

generated against master/2ce79959
Comment 2 Atsushi Eno 2012-11-27 05:53:33 EST
Thanks, applied this patch too.

[master 05d46a8]

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