Search

ApplicationSettingsBase.Save does not save when a setting is changed indirectly by Martin S. Müller

Closed
as Won't Fix Help for as Won't Fix

1
0
Sign in
to vote
Type: Bug
ID: 777670
Opened: 1/28/2013 4:52:17 AM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
Consider this code:

using System.Collections.Generic;
using System.Configuration;

class Program
{
static void Main(string[] args)
{
     Settings settings = new Settings();
     settings.S = new List<string>();
     List<string> l = settings.S;
     l.Add("one");
     settings.Save();
     l.Add("two");
     settings.Save();
}

class Settings : ApplicationSettingsBase
{
     [UserScopedSetting]
     public List<string> S { get { return (List<string>) this["S"]; } set { this["S"] = value; } }
}
}

After the first save, the property S is changed without accessing settings["S"]. The change will not be saved to the xml settings file. However, if the change is done e.g. settings["S"].Add("two"), it will get writting the the xml settings file.

I am pretty sure this is by design. However, this behaviour is not obvious and I could not find any documentation about this behaviour.
Details (expand)

Visual Studio/Team Foundation Server/.NET Framework Tooling Version

.NET Framework 4.0

Steps to reproduce

Run the code above. Search for the xml settings file that has been created.

Product Language

English

Operating System

Windows XP

Operating System Language

English

Actual results

The settings file contains only the first string:

            <setting name="S" serializeAs="Xml">
                <value>
                    <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                        xmlns:xsd="http://www.w3.org/2001/XMLSchema">
                        <string>one</string>
                    </ArrayOfString>
                </value>
            </setting>

Expected results

The settings file contains both strings:

            <setting name="S" serializeAs="Xml">
                <value>
                    <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                        xmlns:xsd="http://www.w3.org/2001/XMLSchema">
                        <string>one</string>
                        <string>two</string>
                    </ArrayOfString>
                </value>
            </setting>
File Attachments
0 attachments
Sign in to post a comment.
Posted by Martin S. Müller on 2/26/2013 at 12:22 AM
Maybe it would be helpful to document this behavior.
Posted by Microsoft on 2/21/2013 at 7:25 AM
Thank you for your feedback. We are not going to be able to address this issue in our next release due to other priorities.

Regards,
Immo Landwerth
.NET Framework team
Posted by Microsoft on 1/30/2013 at 1:11 AM
Thank you for submitting feedback on Visual Studio and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by Microsoft on 1/28/2013 at 5:51 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.