Mono (as of 9/14/06 snapshots) doesn't currently support the MasterType
directive on Master Pages, although it does support it on regular pages.
MS supports it both places.
Please find attached a patch which implements support for this directive
for master pages as well. I've only submitted minor bug fixes to mono
before, so any feedback you can offer is appreciated.
I will add a testcase as needed. Which directory should I put it in?
System.Web/Test/mainsoft?
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 000..02ad8c3
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Compilation/MasterPageCompiler.cs
@@ -0,0 +1,64 @@
+//
+// 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.
+//
+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 NET_2_0
+ 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 1e6440f..b115473 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);
@@ -66,6 +67,32 @@ namespace System.Web.UI
mp.MasterPageFile = MasterPageFile;
}
+#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 =