[Mono-bugs] [Bug 658184] System.Configuration.Save() still not working in Mono 2.8.1

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Mar 9 14:35:08 EST 2011


https://bugzilla.novell.com/show_bug.cgi?id=658184

https://bugzilla.novell.com/show_bug.cgi?id=658184#c2


--- Comment #2 from QuickJack . <test051102 at hotmail.com> 2011-03-09 19:35:07 UTC ---
Meanwhile I have set up a complete debugging environment that allows me to use
MonoDevelop 2.6 Beta 1 to debug the Mono 2.10.1 class library.


General analysis of the problem
=====================
As demonstrated in my example, the bug occurs when calling
System.Configuration.Configuration.Save(). That looks simple in the first
place, but the logic involved is quite complex. The root cause must be
somewhere down in the call tree. The relevant call tree is as follows:

System.Configuration.Configuration.Save()
+ System.Configuration.SectionInfo.WriteData()
  + System.Configuration.ConfigurationSection.SerializeSection()
    + System.Configuration.ConfigurationElementCollection.Unmerge()
      + System.Web.Configuration.AuthorizationRule.Unmerge()
    + System.Configuration.ConfigurationElement.Unmerge()

I found out that the actual serialization logic seems to be working as
expected. It seems that the problem lies in the Unmerge process. These methods
are taking care of the ConfigurationElement's properties only. In case of an
AuthorizationRule these properties are „users“, „roles“ and „verbs“. However
the AuthorizationRule's Action property is simply ignored. When creating new
AuthorizationRule objects, the default value for the Action property is Allow.
Therefore, every new AuthorizationRule that is added to web.config will have
it's action set to „allow“.

Furthermore, I assume that the classes in the System.Configuration namespace
are OK because these are used at different places, too. As a result, the bug
must be in System.Web.Configuration.AuthorizationRule.Unmerge(). This method
must take care of the correct value for it's Action property.


Detailed analysis of the problem
=====================
The most important part in this scenario is in
ConfigurationElementCollection.cs - line 520:

nitem.Unmerge (sitem, pitem, ConfigurationSaveMode.Minimal);
BaseAdd(nitem)

where
nitem: new item
sitem: first AuthorizationRule from web.config
pitem: AuthorizationRule from Mono's base web.config (<allow users=“*“/>)

nitem.Unmerge() calls AuthorizationRule.Unmerge which ignores the Action
property. The newly created nitem has it's Action property set to Allow. After
returning from nitem.Unmerge(), nitem.Action always equals Allow.


Solution
=====================
One possible solution would be to simply ignore the parent's Action attribute.
Instead we copy the source item's Action attribute. It would be enough to add
the following code after the last line of AuthorizationRule.Unmerge(): 

    this.Action=sourceElement.Action;


Final words
=====================
Currently, I don't exactly understand the role of the parent item in the above
scenario. The basic functionality should be to simply write the
AuthorizationRules out to web.config. It would be nice if my solution would be
included in the next release of Mono 2.10.

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list