Browse Source

2008-12-23 Marek Habersack <[email protected]>

	* NunitWeb/Makefile (NunitWeb.dll): added NunitWeb/CustomSection.cs

	* NunitWebResources/CustomSectionEmptyCollection.aspx: added

2008-12-23  Marek Habersack  <[email protected]>

	* WebConfigurationManagerTest.cs: added new test.

2008-12-23  Marek Habersack  <[email protected]>

	* CustomSection.cs: added. Implementation of custom configuration
	elements for WebConfigurationManager tests.

2008-12-23  Marek Habersack  <[email protected]>

	* Web.mono.config: added CustomTags section definition, used in
	WebConfiguratioManager tests.

2008-12-23  Marek Habersack  <[email protected]>

	* WebConfigurationManager.cs: GetSection should call
	OpenWebConfiguration using the actual directory path, not a file
	path. If it fails to do so, System.Configuration may treat the
	top-level Web.config file as a child one which, in turn, in
	certain circumstances will lead to duplicate keys inserted in
	collections.

2008-12-23  Marek Habersack  <[email protected]>

	* Makefile (TEST_RESOURCE_FILES): added Test/mainsoft/NunitWebResources/CustomSectionEmptyCollection.aspx

	* System.Web_test.dll.sources: added mainsoft/NunitWeb/NunitWeb/CustomSection.cs

svn path=/trunk/mcs/; revision=122024
Marek Habersack 17 năm trước cách đây
mục cha
commit
ce8461d813

+ 6 - 0
mcs/class/System.Web/ChangeLog

@@ -1,3 +1,9 @@
+2008-12-23  Marek Habersack  <[email protected]>
+
+	* Makefile (TEST_RESOURCE_FILES): added Test/mainsoft/NunitWebResources/CustomSectionEmptyCollection.aspx
+
+	* System.Web_test.dll.sources: added mainsoft/NunitWeb/NunitWeb/CustomSection.cs
+
 2008-12-12  Dean Brettle  <[email protected]>
 
 	* System.Web.dll.sources: deleted

+ 2 - 1
mcs/class/System.Web/Makefile

@@ -157,7 +157,8 @@ TEST_RESOURCE_FILES = \
 	Test/mainsoft/NunitWebResources/TemplateControlParsingTest.aspx \
 	Test/mainsoft/NunitWebResources/ContentPlaceHolderInTemplate.aspx \
 	Test/mainsoft/NunitWebResources/ContentPlaceHolderInTemplate.master \
-	Test/mainsoft/NunitWebResources/MissingMasterFile.aspx
+	Test/mainsoft/NunitWebResources/MissingMasterFile.aspx \
+	Test/mainsoft/NunitWebResources/CustomSectionEmptyCollection.aspx
 
 RESX_DIST =  resources/TranslationResources.resx
 ifeq (net_2_0, $(PROFILE))

+ 9 - 0
mcs/class/System.Web/System.Web.Configuration_2.0/ChangeLog

@@ -1,3 +1,12 @@
+2008-12-23  Marek Habersack  <[email protected]>
+
+	* WebConfigurationManager.cs: GetSection should call
+	OpenWebConfiguration using the actual directory path, not a file
+	path. If it fails to do so, System.Configuration may treat the
+	top-level Web.config file as a child one which, in turn, in
+	certain circumstances will lead to duplicate keys inserted in
+	collections.
+
 2008-12-16  Marek Habersack  <[email protected]>
 
 	* WebConfigurationHost.cs: IsDefinitionAllowed should treat

+ 16 - 2
mcs/class/System.Web/System.Web.Configuration_2.0/WebConfigurationManager.cs

@@ -290,7 +290,20 @@ namespace System.Web.Configuration {
 			if (cachedSection != null)
 				return cachedSection;
 
-			_Configuration c = OpenWebConfiguration (path);
+			string configPath;
+			if (String.Compare (path, HttpRuntime.AppDomainAppVirtualPath, StringComparison.Ordinal) == 0)
+				configPath = path;
+			else {
+				int len = path != null ? path.Length : 0;
+				if (len == 0)
+					configPath = path;
+				else if (path [len - 1] == '/')
+					configPath = path;
+				else
+					configPath = VirtualPathUtility.GetDirectory (path, false);
+			}
+			
+			_Configuration c = OpenWebConfiguration (configPath);
 			ConfigurationSection section = c.GetSection (sectionName);
 
 			if (section == null)
@@ -319,7 +332,8 @@ namespace System.Web.Configuration {
 
 		static string GetCurrentPath (HttpContext ctx)
 		{
-			return (ctx != null && ctx.Request != null) ? ctx.Request.Path : HttpRuntime.AppDomainAppVirtualPath;
+			HttpRequest req = ctx != null ? ctx.Request : null;
+			return req != null ? req.Path : HttpRuntime.AppDomainAppVirtualPath;
 		}
 
 		internal static void RemoveConfigurationFromCache (HttpContext ctx)

+ 1 - 0
mcs/class/System.Web/System.Web_test.dll.sources

@@ -17,6 +17,7 @@ mainsoft/NunitWeb/NunitWeb/BaseControlCollection.cs
 mainsoft/NunitWeb/NunitWeb/BaseInvoker.cs
 mainsoft/NunitWeb/NunitWeb/BaseRequest.cs
 mainsoft/NunitWeb/NunitWeb/BaseWorkerRequest.cs
+mainsoft/NunitWeb/NunitWeb/CustomSection.cs
 mainsoft/NunitWeb/NunitWeb/FakeMembershipProvider.cs
 mainsoft/NunitWeb/NunitWeb/FormRequest.cs
 mainsoft/NunitWeb/NunitWeb/IForeignData.cs

+ 4 - 0
mcs/class/System.Web/Test/System.Web.Configuration/ChangeLog

@@ -1,3 +1,7 @@
+2008-12-23  Marek Habersack  <[email protected]>
+
+	* WebConfigurationManagerTest.cs: added new test.
+
 2007-11-23  Marek Habersack  <[email protected]>
 
 	* CacheSectionTest.cs: modified to match the new MS.NET defaults.

+ 13 - 0
mcs/class/System.Web/Test/System.Web.Configuration/WebConfigurationManagerTest.cs

@@ -52,6 +52,12 @@ namespace MonoTests.System.Web.Configuration {
 			WebTest.Unload ();
 		}
 
+		[SetUp]
+		public void TestSetUp ()
+		{
+			WebTest.CopyResource (GetType (), "CustomSectionEmptyCollection.aspx", "CustomSectionEmptyCollection.aspx");
+		}
+		
 		[Test]
 		[Category ("NotWorking")]
 		public void OpenMachineConfiguration_1 ()
@@ -213,6 +219,13 @@ namespace MonoTests.System.Web.Configuration {
 			Assert.IsNotNull (WebConfigurationManager.AppSettings, "A1");
 			Assert.IsNotNull (WebConfigurationManager.ConnectionStrings, "A2");
 		}
+
+		[Test]
+		public void CustomSectionEmptyCollection ()
+		{
+			WebTest t = new WebTest ("CustomSectionEmptyCollection.aspx");
+			t.Run ();
+		}
 	}
 }
 

+ 6 - 0
mcs/class/System.Web/Test/mainsoft/ChangeLog

@@ -1,3 +1,9 @@
+2008-12-23  Marek Habersack  <[email protected]>
+
+	* NunitWeb/Makefile (NunitWeb.dll): added NunitWeb/CustomSection.cs
+
+	* NunitWebResources/CustomSectionEmptyCollection.aspx: added
+
 2008-12-10  Marek Habersack  <[email protected]>
 
 	* NunitWebResources/MissingMasterFile.aspx: added

+ 1 - 1
mcs/class/System.Web/Test/mainsoft/NunitWeb/Makefile

@@ -9,4 +9,4 @@ Test1.dll: NunitWeb.dll Test1/Class1.cs Makefile
 
 
 NunitWeb.dll: NunitWeb/Helper.cs NunitWeb/MyHandler.cs NunitWeb/MyHost.cs NunitWeb/Resources/My.master NunitWeb/Resources/MyPage.aspx NunitWeb/Resources/MyPage.aspx.cs NunitWeb/Resources/MyPageWithMaster.aspx NunitWeb/Resources/MyPageWithMaster.aspx.cs NunitWeb/Resources/Web.config NunitWeb/Resources/MyPageWithMasterInvalidPlaceHolder.aspx Makefile
-	gmcs -d:NET_2_0 -r:System.Configuration -r:System.Web NunitWeb/Helper.cs NunitWeb/MyHandler.cs NunitWeb/MyHost.cs -resource:NunitWeb/Resources/My.master -resource:NunitWeb/Resources/MyPage.aspx -resource:NunitWeb/Resources/MyPage.aspx.cs -resource:NunitWeb/Resources/MyPageWithMaster.aspx -resource:NunitWeb/Resources/MyPageWithMaster.aspx.cs -resource:NunitWeb/Resources/MyPageWithMasterInvalidPlaceHolder.aspx -resource:NunitWeb/Resources/Web.config -target:library -out:NunitWeb.dll
+	gmcs -d:NET_2_0 -r:System.Configuration -r:System.Web NunitWeb/CustomSection.cs NunitWeb/Helper.cs NunitWeb/MyHandler.cs NunitWeb/MyHost.cs -resource:NunitWeb/Resources/My.master -resource:NunitWeb/Resources/MyPage.aspx -resource:NunitWeb/Resources/MyPage.aspx.cs -resource:NunitWeb/Resources/MyPageWithMaster.aspx -resource:NunitWeb/Resources/MyPageWithMaster.aspx.cs -resource:NunitWeb/Resources/MyPageWithMasterInvalidPlaceHolder.aspx -resource:NunitWeb/Resources/Web.config -target:library -out:NunitWeb.dll

+ 5 - 0
mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/ChangeLog

@@ -1,3 +1,8 @@
+2008-12-23  Marek Habersack  <[email protected]>
+
+	* CustomSection.cs: added. Implementation of custom configuration
+	elements for WebConfigurationManager tests.
+
 2008-12-02  Marek Habersack  <[email protected]>
 
 	* WebTest.cs: for 1.1, copy the Web.mono.config.1.1 resource

+ 57 - 0
mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/CustomSection.cs

@@ -0,0 +1,57 @@
+using System;
+using System.Configuration;
+
+namespace MonoTests.SystemWeb.Framework
+{
+    public class CustomSection : ConfigurationSection
+    {
+        [ConfigurationProperty ("sections", IsRequired = true)]
+        public CustomSubSectionCollection AreaSections {
+            get {
+                return (CustomSubSectionCollection) base["sections"];
+            }
+            set {
+                base["sections"] = value;
+            }
+        }
+    }
+
+    public class CustomSubSectionCollection : ConfigurationElementCollection
+    {
+        protected override ConfigurationElement CreateNewElement () {
+            return new CustomTagCollection ();
+        }
+
+        protected override object GetElementKey (ConfigurationElement element) {
+            return (element as CustomTagCollection).Area;
+        }
+    }
+
+    public class CustomTagCollection : ConfigurationElementCollection
+    {
+        protected override ConfigurationElement CreateNewElement () {
+            return new CustomTagElement ();
+        }
+
+        protected override object GetElementKey (ConfigurationElement element) {
+            return ((CustomTagElement) element).Name;
+        }
+
+        [ConfigurationProperty ("area", DefaultValue = "UndefinedArea", IsKey = true, IsRequired = true)]
+        public string Area {
+            get {
+                return (string) base["area"];
+            }
+        }
+    }
+
+    public class CustomTagElement : ConfigurationElement
+    {
+        [ConfigurationProperty ("name", DefaultValue = "CustomName", IsKey = true, IsRequired = true)]
+        public string Name {
+            get {
+                return (string) base["name"];
+            }
+        }
+    }
+}

+ 5 - 0
mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/ChangeLog

@@ -1,3 +1,8 @@
+2008-12-23  Marek Habersack  <[email protected]>
+
+	* Web.mono.config: added CustomTags section definition, used in
+	WebConfiguratioManager tests.
+
 2008-12-02  Marek Habersack  <[email protected]>
 
 	* Web.config: added ASP.NET AJAX 1.0 configuration entries

+ 13 - 0
mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/Web.mono.config

@@ -10,12 +10,25 @@
 					<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
 				</sectionGroup>
 			</sectionGroup>
+			<section name="CustomTags" restartOnExternalChanges="false" type="MonoTests.SystemWeb.Framework.CustomSection, System.Web_test_net_2_0" />
 		</sectionGroup>
 	</configSections>
   <appSettings>
     <add key="strvalue" value="str" />
     <add key="intvalue" value="123" />
   </appSettings>
+  
+  <!-- DO NOT REMOVE: USED BY TESTS -->
+  <CustomTags>
+    <sections>
+      <add area="activityTemplateTitle">
+        <add name="a" />
+      </add>
+      <add area="Something">
+      </add>
+    </sections>
+  </CustomTags>
+  
   <system.web>
     <siteMap enabled="true"/>
     <compilation debug="true" batch="false">

+ 16 - 0
mcs/class/System.Web/Test/mainsoft/NunitWebResources/CustomSectionEmptyCollection.aspx

@@ -0,0 +1,16 @@
+<%@ Page Language="C#" %>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head runat="server">
+    <title>Command</title>
+    <script runat="server">
+        void Page_Load ()
+        {
+		ConfigurationManager.GetSection ("GauntletSafeTags");
+        }
+    </script>
+</head>
+<body>
+</body>
+</html>
+