Author: andrews
Date: 2006-06-18 06:51:24 -0400 (Sun, 18 Jun 2006)
New Revision: 61826
Added:
trunk/mcs/class/System.Web/Test/System.Web.Compilation/TemplateControlCompilerTest.cs
trunk/mcs/class/System.Web/Test/mainsoft/NunitWebResources/ReadOnlyPropertyBind.aspx
trunk/mcs/class/System.Web/Test/mainsoft/NunitWebResources/ReadOnlyPropertyControl.ascx
Modified:
trunk/mcs/class/System.Web/ChangeLog
trunk/mcs/class/System.Web/Makefile
trunk/mcs/class/System.Web/System.Web.Compilation/ChangeLog
trunk/mcs/class/System.Web/System.Web.Compilation/TemplateControlCompiler.cs
trunk/mcs/class/System.Web/System.Web_test.dll.sources
trunk/mcs/class/System.Web/Test/System.Web.Compilation/ChangeLog
Log:
Check IsWritablePropertyOrField before generating code for assignment statement
and DataBind event.
Modified: trunk/mcs/class/System.Web/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/ChangeLog 2006-06-18 10:34:15 UTC (rev
61825)
+++ trunk/mcs/class/System.Web/ChangeLog 2006-06-18 10:51:24 UTC (rev
61826)
@@ -1,3 +1,9 @@
+2006-06-18 Andrew Skiba <[EMAIL PROTECTED]>
+
+ * System.Web_test.dll.sources: add TemplateControlCompilerTest.cs
+ * Makefile: add ReadOnlyPropertyBind.aspx and
+ ReadOnlyPropertyControl.ascx
+
2006-06-14 Andrew Skiba <[EMAIL PROTECTED]>
* Makefile: add menuclass.aspx test resource file
Modified: trunk/mcs/class/System.Web/Makefile
===================================================================
--- trunk/mcs/class/System.Web/Makefile 2006-06-18 10:34:15 UTC (rev 61825)
+++ trunk/mcs/class/System.Web/Makefile 2006-06-18 10:51:24 UTC (rev 61826)
@@ -74,6 +74,8 @@
Test/mainsoft/NunitWebResources/PageWithStyleSheet.aspx \
Test/mainsoft/NunitWebResources/PageWithTheme.aspx \
Test/mainsoft/NunitWebResources/RunTimeSetTheme.aspx \
+ Test/mainsoft/NunitWebResources/ReadOnlyPropertyBind.aspx \
+ Test/mainsoft/NunitWebResources/ReadOnlyPropertyControl.ascx \
Test/mainsoft/NunitWebResources/Theme1.skin \
Test/mainsoft/NunitWebResources/Web.sitemap \
Test/mainsoft/MainsoftWebTest/nunitweb_config.xml
Modified: trunk/mcs/class/System.Web/System.Web.Compilation/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Compilation/ChangeLog 2006-06-18
10:34:15 UTC (rev 61825)
+++ trunk/mcs/class/System.Web/System.Web.Compilation/ChangeLog 2006-06-18
10:51:24 UTC (rev 61826)
@@ -1,3 +1,8 @@
+2006-06-18 Andrew Skiba <[EMAIL PROTECTED]>
+
+ * TemplateControlCompiler.cs: check IsWritablePropertyOrField before
+ generating code for assignment statement and DataBind event.
+
2006-06-15 Juraj Skripsky <[EMAIL PROTECTED]>
* AspTokenizer.cs (ReadAttValue), AspParser.cs (GetAttributes):
Modified:
trunk/mcs/class/System.Web/System.Web.Compilation/TemplateControlCompiler.cs
===================================================================
---
trunk/mcs/class/System.Web/System.Web.Compilation/TemplateControlCompiler.cs
2006-06-18 10:34:15 UTC (rev 61825)
+++
trunk/mcs/class/System.Web/System.Web.Compilation/TemplateControlCompiler.cs
2006-06-18 10:51:24 UTC (rev 61826)
@@ -399,7 +399,7 @@
void AddCodeForPropertyOrField (ControlBuilder builder, Type
type, string var_name, string att, MemberInfo member, bool isDataBound)
{
CodeMemberMethod method = builder.method;
- if (isDataBound) {
+ if (isDataBound && IsWritablePropertyOrField (member)) {
string dbMethodName = DataBoundProperty
(builder, type, var_name, att);
AddEventAssign (method, "DataBinding", typeof
(EventHandler), dbMethodName);
return;
@@ -476,6 +476,17 @@
return member;
}
+ static bool IsWritablePropertyOrField (MemberInfo member)
+ {
+ PropertyInfo pi = member as PropertyInfo;
+ if (pi != null)
+ return pi.CanWrite;
+ FieldInfo fi = member as FieldInfo;
+ if (fi != null)
+ return !fi.IsInitOnly;
+ throw new ArgumentException ("Argument must be of
PropertyInfo or FieldInfo type", "member");
+ }
+
bool ProcessPropertiesAndFields (ControlBuilder builder,
MemberInfo member, string id,
string attValue, string prefix)
{
@@ -486,8 +497,6 @@
Type type;
if (isPropertyInfo) {
type = ((PropertyInfo) member).PropertyType;
- if (hyphen == -1 && ((PropertyInfo)
member).CanWrite == false)
- return false;
} else {
type = ((FieldInfo) member).FieldType;
}
@@ -496,7 +505,8 @@
#if NET_2_0
if (isDataBound) RegisterBindingInfo (builder,
member.Name, ref attValue);
#endif
- AddCodeForPropertyOrField (builder, type,
member.Name, attValue, member, isDataBound);
+ if (IsWritablePropertyOrField (member))
+ AddCodeForPropertyOrField (builder,
type, member.Name, attValue, member, isDataBound);
return true;
}
Modified: trunk/mcs/class/System.Web/System.Web_test.dll.sources
===================================================================
--- trunk/mcs/class/System.Web/System.Web_test.dll.sources 2006-06-18
10:34:15 UTC (rev 61825)
+++ trunk/mcs/class/System.Web/System.Web_test.dll.sources 2006-06-18
10:51:24 UTC (rev 61826)
@@ -31,6 +31,7 @@
System.Web/SiteMapNodeTest.cs
System.Web/StaticSiteMapProviderTest.cs
System.Web.Compilation/ClientBuildManagerParameterTest.cs
+System.Web.Compilation/TemplateControlCompilerTest.cs
System.Web.Configuration/AnonymousIdentificationSectionTest.cs
System.Web.Configuration/AssemblyCollectionTest.cs
System.Web.Configuration/AssemblyInfoTest.cs
Modified: trunk/mcs/class/System.Web/Test/System.Web.Compilation/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/Test/System.Web.Compilation/ChangeLog
2006-06-18 10:34:15 UTC (rev 61825)
+++ trunk/mcs/class/System.Web/Test/System.Web.Compilation/ChangeLog
2006-06-18 10:51:24 UTC (rev 61826)
@@ -1,3 +1,7 @@
+2006-06-18 Andrew Skiba <[EMAIL PROTECTED]>
+
+ * TemplateControlCompilerTest.cs: new test.
+
2006-01-20 Chris Toshok <[EMAIL PROTECTED]>
* ClientBuildManagerParameterTest.cs: new test.
Added:
trunk/mcs/class/System.Web/Test/System.Web.Compilation/TemplateControlCompilerTest.cs
===================================================================
---
trunk/mcs/class/System.Web/Test/System.Web.Compilation/TemplateControlCompilerTest.cs
2006-06-18 10:34:15 UTC (rev 61825)
+++
trunk/mcs/class/System.Web/Test/System.Web.Compilation/TemplateControlCompilerTest.cs
2006-06-18 10:51:24 UTC (rev 61826)
@@ -0,0 +1,43 @@
+#if NET_2_0
+
+using NunitWeb;
+using NUnit.Framework;
+using System.Web.UI.WebControls;
+using System.Reflection;
+using System.ComponentModel;
+using System.Threading;
+
+namespace MonoTests.System.Web.Compilation {
+ public class ReadOnlyPropertyControl:TextBox {
+ [Bindable (true)]
+ public bool MyProp
+ {
+ get { return true; }
+ }
+
+ }
+
+ [TestFixture]
+ public class TemplateControlCompilerTest
+ {
+ [Test]
+ [NUnit.Framework.Category ("NunitWeb")]
+ public void ReadOnlyPropertyBindTest ()
+ {
+ Helper.Instance.CopyResource
(Assembly.GetExecutingAssembly (),
+ "ReadOnlyPropertyBind.aspx",
"ReadOnlyPropertyBind.aspx");
+ Helper.Instance.CopyResource
(Assembly.GetExecutingAssembly (),
+ "ReadOnlyPropertyControl.ascx",
"ReadOnlyPropertyControl.ascx");
+ Helper.Instance.RunUrl ("ReadOnlyPropertyBind.aspx");
+ }
+ [TestFixtureTearDown]
+ public void TearDown ()
+ {
+ Thread.Sleep (100);
+ Helper.Unload ();
+ }
+ }
+}
+
+#endif
+
Added:
trunk/mcs/class/System.Web/Test/mainsoft/NunitWebResources/ReadOnlyPropertyBind.aspx
===================================================================
---
trunk/mcs/class/System.Web/Test/mainsoft/NunitWebResources/ReadOnlyPropertyBind.aspx
2006-06-18 10:34:15 UTC (rev 61825)
+++
trunk/mcs/class/System.Web/Test/mainsoft/NunitWebResources/ReadOnlyPropertyBind.aspx
2006-06-18 10:51:24 UTC (rev 61826)
@@ -0,0 +1,21 @@
+<%@ Page Language="C#" CodeFile="MyPage.aspx.cs" Inherits="MyPage" %>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<%@ Register TagPrefix="uc1" TagName="ReadOnlyPropertyControl"
Src="ReadOnlyPropertyControl.ascx" %>
+
+<html xmlns="http://www.w3.org/1999/xhtml" >
+ <head>
+ <title>UrlProperty test</title>
+ </head>
+<body>
+ <form id="form1" runat="server">
+ <asp:FormView runat="server" ID="fv1" DataSourceID="DataSource1"
BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px"
CellPadding="4" ForeColor="Black" GridLines="Vertical" >
+ <ItemTemplate>
+ <uc1:ReadOnlyPropertyControl runat="server" ID="wuc1"
ReadOnlyProperty='<%# Bind("Chars") %>' />
+ <uc1:ReadOnlyPropertyControl runat="server" ID="wuc2" ReadOnlyField='<%#
Bind("Chars") %>' />
+ </ItemTemplate>
+ </asp:FormView>
+ <asp:ObjectDataSource ID="DataSource1" runat="server"
TypeName="System.Guid" SelectMethod="ToByteArray" />
+ </form>
+</body>
+</html>
Added:
trunk/mcs/class/System.Web/Test/mainsoft/NunitWebResources/ReadOnlyPropertyControl.ascx
===================================================================
---
trunk/mcs/class/System.Web/Test/mainsoft/NunitWebResources/ReadOnlyPropertyControl.ascx
2006-06-18 10:34:15 UTC (rev 61825)
+++
trunk/mcs/class/System.Web/Test/mainsoft/NunitWebResources/ReadOnlyPropertyControl.ascx
2006-06-18 10:51:24 UTC (rev 61826)
@@ -0,0 +1,10 @@
+<%@ Control Language="C#" %>
+<script runat="server">
+ [System.ComponentModel.Bindable (true)]
+ public readonly bool ReadOnlyField = true;
+ [System.ComponentModel.Bindable (true)]
+ public bool ReadOnlyProperty
+ {
+ get { return true; }
+ }
+</script>
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches