Gonzalo Paniagua Javier wrote:
On Wed, 2006-09-20 at 16:12 -0400, joel reed wrote:
Please find 2 asp.net patches attached.

1) Page.Add.Namespaces.v1.diff

Implements TemplateParser.cs change for System.Web.Configuration.NamespaceCollection to work.

This one is in svn now.

awesome. thanks!


2) MasterType.on.MasterPages.v3.diff

Implements support for the MasterType directive for master pages. Version 3 here adds a test case - I feel far better about the code than the test case, as I've not written too many nunit test cases. Feedback much appreciated.

The patch for the test didn't apply cleanly. Can you provide a new patch
against current svn?

Ok, i took the mono-1.1.17.20060920 snapshot and redid it. If that doesn't work, I can use svn, but it takes forever to pull the whole tree. :(

how about snapshots with the svn metadata already in them, kind of bootstrapping the anon-svn experience? not sure if possible, but sure would be nice!

thanks,

jr

diff --git a/mcs/class/System.Web/System.Web.Compilation/AspGenerator.cs b/mcs/class/System.Web/System.Web.Compilation/AspGenerator.cs
index 89c8adf..07cc5c8 100644
--- a/mcs/class/System.Web/System.Web.Compilation/AspGenerator.cs
+++ b/mcs/class/System.Web/System.Web.Compilation/AspGenerator.cs
@@ -225,7 +225,7 @@ namespace System.Web.Compilation
 				return new UserControlCompiler ((UserControlParser) tparser);
 #if NET_2_0
 			if (type == typeof(MasterPageParser))
-				return new UserControlCompiler ((UserControlParser) tparser);
+				return new MasterPageCompiler ((MasterPageParser) tparser);
 #endif
 
 			throw new Exception ("Got type: " + type);
diff --git a/mcs/class/System.Web/System.Web.Compilation/MasterPageCompiler.cs b/mcs/class/System.Web/System.Web.Compilation/MasterPageCompiler.cs
new file mode 100644
index 0000000..5c7db1f
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Compilation/MasterPageCompiler.cs
@@ -0,0 +1,67 @@
+//
+// System.Web.Compilation.MasterPageCompiler
+//
+// Authors:
+//	Joel W. Reed ([EMAIL PROTECTED])
+//
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+
+using System;
+using System.CodeDom;
+using System.Web.UI;
+
+namespace System.Web.Compilation
+{
+	class MasterPageCompiler : UserControlCompiler
+	{
+		MasterPageParser parser;
+
+		public MasterPageCompiler (MasterPageParser parser)
+			: base (parser)
+		{
+			this.parser = parser;
+		}
+
+		protected internal override void CreateMethods ()
+		{
+			base.CreateMethods ();
+
+			if (parser.MasterType != null) {
+				CodeMemberProperty mprop = new CodeMemberProperty ();
+				mprop.Name = "Master";
+				mprop.Type = new CodeTypeReference (parser.MasterType);
+				mprop.Attributes = MemberAttributes.Public | MemberAttributes.New;
+				CodeExpression prop = new CodePropertyReferenceExpression (new CodeBaseReferenceExpression (), "Master");
+				prop = new CodeCastExpression (parser.MasterType, prop);
+				mprop.GetStatements.Add (new CodeMethodReturnStatement (prop));
+				mainClass.Members.Add (mprop);
+			}
+		}
+	}
+}
+
+#endif
+
diff --git a/mcs/class/System.Web/System.Web.UI/MasterPageParser.cs b/mcs/class/System.Web/System.Web.UI/MasterPageParser.cs
index 5a17920..9616fa4 100644
--- a/mcs/class/System.Web/System.Web.UI/MasterPageParser.cs
+++ b/mcs/class/System.Web/System.Web.UI/MasterPageParser.cs
@@ -41,6 +41,8 @@ namespace System.Web.UI
 {
 	internal sealed class MasterPageParser: UserControlParser
 	{
+		Type masterType;
+
 		internal MasterPageParser (string virtualPath, string inputFile, HttpContext context)
 		: base (virtualPath, inputFile, context, "System.Web.UI.MasterPage")
 		{
@@ -57,7 +59,6 @@ namespace System.Web.UI
 			MasterPageParser mpp = new MasterPageParser (virtualPath, inputFile, context);
 			return mpp.CompileIntoType ();
 		}
-
 		internal override void HandleOptions (object obj)
 		{
 			base.HandleOptions (obj);
@@ -67,6 +68,32 @@ namespace System.Web.UI
 		}
 
 
+#if NET_2_0
+		internal override void AddDirective (string directive, Hashtable atts)
+		{
+			if (String.Compare ("MasterType", directive, true) == 0) {
+				string type = GetString (atts, "TypeName", null);
+				if (type != null) {
+					masterType = LoadType (type);
+					if (masterType == null)
+						ThrowParseException ("Could not load type '" + type + "'.");
+				} else {
+					string path = GetString (atts, "VirtualPath", null);
+					if (path != null)
+						masterType = MasterPageParser.GetCompiledMasterType (path, MapPath (path), HttpContext.Current);
+					else
+						ThrowParseException ("The MasterType directive must have either a TypeName or a VirtualPath attribute.");				}
+				AddAssembly (masterType.Assembly, true);
+			}
+			else
+				base.AddDirective (directive, atts);
+		}
+#endif
+
+		internal Type MasterType {
+			get { return masterType; }
+		}
+
 		internal override Type DefaultBaseType {
 			get { return typeof (MasterPage); }
 		}
diff --git a/mcs/class/System.Web/System.Web.dll.sources b/mcs/class/System.Web/System.Web.dll.sources
index a68b69b..700dfaf 100644
--- a/mcs/class/System.Web/System.Web.dll.sources
+++ b/mcs/class/System.Web/System.Web.dll.sources
@@ -51,6 +51,7 @@ System.Web.Compilation/ImplicitResourceK
 System.Web.Compilation/IResourceProvider.cs
 System.Web.Compilation/LinePragmaCodeInfo.cs
 System.Web.Compilation/Location.cs
+System.Web.Compilation/MasterPageCompiler.cs
 System.Web.Compilation/PageBuildProvider.cs
 System.Web.Compilation/PageCompiler.cs
 System.Web.Compilation/PageThemeCompiler.cs
diff --git a/mcs/class/System.Web/Test/System.Web.UI.WebControls/MasterPageTest.cs b/mcs/class/System.Web/Test/System.Web.UI.WebControls/MasterPageTest.cs
index e40816c..0f6779d 100644
--- a/mcs/class/System.Web/Test/System.Web.UI.WebControls/MasterPageTest.cs
+++ b/mcs/class/System.Web/Test/System.Web.UI.WebControls/MasterPageTest.cs
@@ -70,30 +70,10 @@ namespace MonoTests.System.Web.UI.WebCon
 	[TestFixture]
 	public class MasterPageTest
 	{
-
-		[Test]
-		public void MasterPage_DefaultProperties ()
-		{
-			PokerMasterPage pmp = new PokerMasterPage ();
-			Assert.AreEqual (null, pmp.Master, "Master Property");
-			Assert.AreEqual (null, pmp.MasterPageFile, "MasterPageFile Property");
-		}
-
-		[Test]
-		[Category ("NotWorking")]
-		public void MasterPage_DefaultPropertiesNotWorking ()
-		{
-			PokerMasterPage pmp = new PokerMasterPage ();
-			IDictionary i = pmp.ContentTemplates ();
-			Assert.AreEqual (null, i, "ContentTemplates");
-		}
-
-		[Test]
-		[Category ("NunitWeb")]
-		public void MasterPage_Render()
+		public void Render_Helper(string url)
 		{
 			WebTest t = new WebTest (PageInvoker.CreateOnLoad (_RenderDefault));
-			t.Request.Url = StandardUrl.PAGE_WITH_MASTER;
+			t.Request.Url = url;
 			string PageRenderHtml = t.Run ();
 			Assert.AreEqual (-1, PageRenderHtml.IndexOf ("Master header text"), "Master#1");
 			
@@ -117,8 +97,38 @@ namespace MonoTests.System.Web.UI.WebCon
 			}
 
 		}
+
+		[Test]
+		public void MasterPage_DefaultProperties ()
+		{
+			PokerMasterPage pmp = new PokerMasterPage ();
+			Assert.AreEqual (null, pmp.Master, "Master Property");
+			Assert.AreEqual (null, pmp.MasterPageFile, "MasterPageFile Property");
+		}
+
+		[Test]
+		[Category ("NotWorking")]
+		public void MasterPage_DefaultPropertiesNotWorking ()
+		{
+			PokerMasterPage pmp = new PokerMasterPage ();
+			IDictionary i = pmp.ContentTemplates ();
+			Assert.AreEqual (null, i, "ContentTemplates");
+		}
+
+		[Test]
+		[Category ("NunitWeb")]
+		public void MasterPage_Render()
+		{
+			Render_Helper(StandardUrl.PAGE_WITH_MASTER);
+		}
 		
-		
+		[Test]
+		[Category ("NunitWeb")]
+		public void MasterPageDerived_Render()
+		{
+			Render_Helper(StandardUrl.PAGE_WITH_DERIVED_MASTER);
+		}
+
 		public static void _RenderDefault (Page p)
 		{
 			p.Form.Controls.Add(new LiteralControl("Page dynamic text"));
diff --git a/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/MyDerived.master b/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/MyDerived.master
new file mode 100644
index 0000000..5fa9116
--- /dev/null
+++ b/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/MyDerived.master
@@ -0,0 +1,30 @@
+<%@ Master Language="C#" MasterPageFile="My.master"%>                                   
+<%@ MasterType VirtualPath="My.master" %>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
+
+<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" >
+<head id="Head1" runat="server">
+	<title></title>
+</head>
+    <body>
+        <asp:contentplaceholder id="Header" runat="server">
+              Master header text
+        </asp:contentplaceholder>
+        
+        <asp:contentplaceholder id="Main" runat="server">
+              Master main text 
+        </asp:contentplaceholder>
+        
+        <asp:contentplaceholder id="Dynamic" runat="server">
+              Master dynamic text
+        </asp:contentplaceholder>
+        
+        <asp:contentplaceholder id="Footer" runat="server">
+		      My master page footer 
+		</asp:contentplaceholder>
+		
+		Master page content text
+	
+    </body>
+</html>
diff --git a/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/MyPageWithDerivedMaster.aspx b/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/MyPageWithDerivedMaster.aspx
new file mode 100644
index 0000000..089496d
--- /dev/null
+++ b/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/MyPageWithDerivedMaster.aspx
@@ -0,0 +1,12 @@
+<%@ Page Language="C#" MasterPageFile="MyDerived.master" AutoEventWireup="true" CodeFile="MyPage.aspx.cs" Inherits="MyPage" %>
+
+<asp:Content ID="BlankContent" ContentPlaceHolderID="Header" runat="server"/>
+
+<asp:content ID="LiteralContent" ContentPlaceHolderID="Main" runat="server">
+     Page main text
+</asp:content>
+
+<asp:content ID="FormContent" ContentPlaceHolderID="Dynamic" runat="server">
+    <form id="form1" runat="server" >
+    </form>
+</asp:content>
diff --git a/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/StandardUrl.cs b/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/StandardUrl.cs
index e1781b7..89b5590 100644
--- a/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/StandardUrl.cs
+++ b/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/StandardUrl.cs
@@ -21,5 +21,9 @@ namespace MonoTests.SystemWeb.Framework
 		/// An empty page, referencing a master page.
 		/// </summary>
 		public const string PAGE_WITH_MASTER = "MyPageWithMaster.aspx";
+		/// <summary>
+		/// An empty page, referencing a master page which references another master page.
+		/// </summary>
+		public const string PAGE_WITH_DERIVED_MASTER = "MyPageWithDerivedMaster.aspx";
 	}
 }
begin:vcard
fn:Joel Reed
n:Reed;Joel
org:Development Dimensions International;E-Systems
adr;dom:;;1225 Washington Pike;Bridgeville;PA;15017
title:Manager, E-Products R&D
tel;work:412-257-3881
note;quoted-printable:Unleashing Executive Talent.  Hiring & Promoting The Best.=0D=0A=
	Developing Extraordinary Leaders.  Discover how at www.ddiworld.com
x-mozilla-html:FALSE
version:2.1
end:vcard

_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list

Reply via email to