[Mono-bugs] [Bug 42994][Blo] New - compiler fails on composite control

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Wed, 14 May 2003 13:43:14 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by tkaszuba@hotmail.com.

http://bugzilla.ximian.com/show_bug.cgi?id=42994

--- shadow/42994	Wed May 14 13:43:14 2003
+++ shadow/42994.tmp.28015	Wed May 14 13:43:14 2003
@@ -0,0 +1,272 @@
+Bug#: 42994
+Product: Mono/Class Libraries
+Version: unspecified
+OS: Red Hat 9.0
+OS Details: Fresh install
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Blocker
+Component: System.Web
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: tkaszuba@hotmail.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: compiler fails on composite control
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+
+I've recently tried to run a simple composite control that exposes the
+Image web control and the compiler throws the following error:
+
+/tmp/tmp180c57e1.cs(79,0) : error CS0127: Return with a value not allowed here
+/tmp/tmp180c57e1.cs(91,0) : error CS0127: Return with a value not allowed here
+/tmp/tmp180c57e1.cs(132,0) : error CS0127: Return with a value not allowed here
+(0,0) : error failed: 3 error(s), 0 warnings
+
+<snip>
+
+Line 74:         private void
+__BuildControl_Bottom1(System.Web.UI.WebControls.Image __ctrl) {
+Line 75:             __ctrl.ID = "Bottom1";
+Line 76:             __ctrl.ImageUrl = "_images/BackWhole.gif";
+Line 77:             __ctrl.EnableViewState = false;
+Line 78:             __ctrl.Width =
+System.Web.UI.WebControls.Unit.Parse("43px",
+System.Globalization.CultureInfo.InvariantCulture);
+Line 79:             return __ctrl;
+Line 80:         }
+
+<snip>
+
+Line 86:         private void
+__BuildControl_Top2(System.Web.UI.WebControls.Image __ctrl) {
+Line 87:             __ctrl.ID = "Top2";
+Line 88:             __ctrl.ImageUrl = "_images/b0.gif";
+Line 89:             __ctrl.EnableViewState = false;
+Line 90:             __ctrl.Width =
+System.Web.UI.WebControls.Unit.Parse("43px",
+System.Globalization.CultureInfo.InvariantCulture);
+Line 91:             return __ctrl;
+Line 92:         }
+
+<snip>
+
+Line 126:         private void
+__BuildControl_Container1(System.Web.UI.WebControls.Image __ctrl) {
+Line 127:             __ctrl.ID = "Container1";
+Line 128:             __ctrl.ImageUrl = "_images/b2.gif";
+Line 129:             __ctrl.EnableViewState = false;
+Line 130:             __ctrl.Width =
+System.Web.UI.WebControls.Unit.Parse("43px",
+System.Globalization.CultureInfo.InvariantCulture);
+Line 131:             __ctrl.Height =
+System.Web.UI.WebControls.Unit.Parse("155px",
+System.Globalization.CultureInfo.InvariantCulture);
+Line 132:             return __ctrl;
+Line 133:         }
+
+
+<snip>
+
+  
+
+Steps to reproduce the problem:
+1.Paste the following code into a file called "bar.cs" 
+
+using System;
+using System.Web.UI.WebControls;
+using System.Web.UI;
+using System.IO;
+
+namespace ICW.WebControls
+{
+	/// <summary>
+	/// 
+	/// </summary>
+	public class Bar:WebControl,INamingContainer
+	{
+		private int scale = 100;
+		protected Image img; 
+
+		public Bar():base()
+		{
+			img = new Image();
+			this.Controls.Add(img);
+		}
+		public int Scale
+		{
+			get{return scale;}
+			set{
+				if (scale < 0 || scale >100) throw new ArgumentException("Scale has to
+be a number between 0 and 100");
+				scale=value;
+			}
+		}
+		protected virtual int ScaledHeight
+		{
+			get
+			{
+				return (int)Math.Round(img.Height.Value*Scale/100);
+			}
+		}
+		public Image Container
+		{
+			get{return img;}
+		}
+		protected override void OnPreRender(EventArgs e)
+		{
+			img.Height = Unit.Pixel(ScaledHeight);
+		}
+	}
+	public class ThreeDimensionalBar:Bar
+	{
+		protected Image topimg;
+		protected Image bottomimg;
+		protected Table table;
+		protected int toppx=0;
+		protected int height;
+		protected string sep ="_";
+
+		public ThreeDimensionalBar():base()
+		{
+			topimg = new Image();
+			bottomimg = new Image();
+			Controls.Remove(img);
+			table = new Table();
+			table.CellPadding=0;
+			table.CellSpacing=0;
+
+			TableRow tr = new TableRow();
+			TableCell tc = new TableCell();
+			tr.Cells.Add(tc);
+			tc.Controls.Add(topimg);
+			table.Rows.Add(tr);
+
+			tr = new TableRow();
+			tc = new TableCell();
+			tr.Cells.Add(tc);
+			tc.Controls.Add(img);
+			table.Rows.Add(tr);
+
+			tr = new TableRow();
+			tc = new TableCell();
+			tr.Cells.Add(tc);
+			tc.Controls.Add(bottomimg);
+			table.Rows.Add(tr);
+
+			Controls.Add(table);
+		}
+		protected override void OnLoad(EventArgs e)
+		{
+			height = (int)Math.Round(img.Height.Value);
+			height = height+TopPx;
+		}
+		public int TopPx
+		{
+			get{return toppx;}
+			set{toppx=value;}
+		}
+		public string Seperator
+		{
+			get{return sep;}
+			set{sep=value;}
+		}
+		public Image Top
+		{
+			get	{
+				return topimg;
+			}
+		}
+		public Image Bottom
+		{
+			get	{return bottomimg;}
+		}
+		protected override int ScaledHeight
+		{
+			get
+			{
+				return (int)Math.Round((double)height*(Scale)/100,2);
+			}
+		}
+
+		protected override void OnPreRender(EventArgs e)
+		{
+
+			if (ScaledHeight >= height-TopPx)
+			{
+				int num = ScaledHeight-(height-toppx);
+				img.Height = Unit.Pixel((int)img.Height.Value+num);
+			}
+			else if (ScaledHeight <=toppx)
+			{
+				table.Rows.Remove(table.Rows[1]);
+				table.Rows.Remove(table.Rows[0]);
+				int num = ScaledHeight;
+				//Top.ImageUrl =
+Path.GetDirectoryName(Top.ImageUrl)+"/"+Path.GetFileNameWithoutExtension(Top.ImageUrl)
+				//	+ sep + num.ToString() + Path.GetExtension(Top.ImageUrl);//
+				Bottom.ImageUrl =
+Path.GetDirectoryName(Bottom.ImageUrl)+"/"+Path.GetFileNameWithoutExtension(Bottom.ImageUrl)
+					+ sep + num.ToString() +
+Path.GetExtension(Bottom.ImageUrl);//"_images/b1"+sep+(num)+".gif";
+				//Bottom.ImageUrl ="_images/BackWhole"+sep+num.ToString()+".gif";
+			}
+			else
+			{
+				img.Height = Unit.Pixel(ScaledHeight-toppx/2+1);
+			}
+		}
+
+	}
+}
+ 
+2. Compile the file into a library called icw.dll, using 
+mcs /r:System.Web.dll /target:library /warn:3/debug+ /debug:Full 
+/out:icw.dll bar.cs
+
+3. Move the file icw.dll to the bin directory
+
+4. Construct an aspx file test.aspx in the run directory and post the
+following code:
+
+<%@ language="C#"%>
+<%@ Register TagPrefix="GRAPH" Namespace="ICW.WebControls" Assembly="icw" %>
+<html>
+<head>
+<title>Literal</title>
+</head>
+<body>
+<form runat="server">
+	<GRAPH:THREEDIMENSIONALBAR id="BankBar" runat="server" TopPx="6">
+		<Container Width="43" Height="155" EnableViewState="false"
+ImageUrl="_images/b2.gif" id="Container1" runat="server" />
+		<Top id="Top2" Width="43" EnableViewState="false"
+ImageUrl="_images/b0.gif" runat="server" />
+		<Bottom id="Bottom1" Width="43" EnableViewState="false"
+ImageUrl="_images/BackWhole.gif" runat="server" />
+	</GRAPH:THREEDIMENSIONALBAR>
+</form>
+</body>
+</html>
+
+5. Run test.aspx
+
+Actual Results:
+The compilation error shown above
+
+Expected Results:
+Compiles and runs fine under MS
+
+How often does this happen? 
+Always
+
+Additional Information:
+I'm suspecting that the compiler notices that it's returning a null value.
+It would be worthwile to see what the auto generated file looks like under
+MS. I've also noticed that not all the compilation classes are done, maybe
+that's the cause of this error.