Prechádzať zdrojové kódy

2007-12-27 Marek Habersack <[email protected]>

	* BaseCompiler.cs: check for base type globality in all the
	location it is used.
2007-12-27  Marek Habersack  <[email protected]>

	* TemplateParser.cs: check for base type globality also when the
	default type is used.

svn path=/trunk/mcs/; revision=91942
Marek Habersack 18 rokov pred
rodič
commit
e9cf41bb57

+ 5 - 1
mcs/class/System.Web/System.Web.Compilation/BaseCompiler.cs

@@ -207,7 +207,11 @@ namespace System.Web.Compilation
 			if (VirtualPathUtility.IsAbsolute (arvp))
 				arvp = "~" + arvp;
 
-			CodeExpression cast = new CodeCastExpression (baseType, new CodeThisReferenceExpression ());
+			CodeTypeReference baseTypeRef = new CodeTypeReference (baseType.FullName);
+			if (parser.BaseTypeIsGlobal)
+				baseTypeRef.Options |= CodeTypeReferenceOptions.GlobalReference;
+			
+			CodeExpression cast = new CodeCastExpression (baseTypeRef, new CodeThisReferenceExpression ());
 			CodePropertyReferenceExpression arvpProp = new CodePropertyReferenceExpression (cast, "AppRelativeVirtualPath");
 			CodeAssignStatement arvpAssign = new CodeAssignStatement ();
 			arvpAssign.Left = arvpProp;

+ 5 - 0
mcs/class/System.Web/System.Web.Compilation/ChangeLog

@@ -1,3 +1,8 @@
+2007-12-27  Marek Habersack  <[email protected]>
+
+	* BaseCompiler.cs: check for base type globality in all the
+	location it is used.
+
 2007-12-23  Vladimir Krasnov  <[email protected]>
 
 	* AppSettingsExpressionBuilder.cs: fixed GetAppSetting, should convert

+ 5 - 0
mcs/class/System.Web/System.Web.UI/ChangeLog

@@ -1,3 +1,8 @@
+2007-12-27  Marek Habersack  <[email protected]>
+
+	* TemplateParser.cs: check for base type globality also when the
+	default type is used.
+
 2007-12-26 Igor Zelmanovich <[email protected]>
 
 	* Control.cs:

+ 23 - 10
mcs/class/System.Web/System.Web.UI/TemplateParser.cs

@@ -732,12 +732,28 @@ namespace System.Web.UI {
 			unknownMainAttributes.Add (desc);
 		}
 #endif
+
+		void CheckIfBaseTypeIsGlobal ()
+		{
+			if (baseType == null)
+				return;
+
+			// If we have a fully-qualified type name, then we don't need to use the
+			// global:: prefix
+			if (baseType.FullName.IndexOf ('.') == -1)
+				baseTypeIsGlobal = true;
+			else
+				baseTypeIsGlobal = false;
+		}
 		
 		internal void SetBaseType (string type)
 		{
-			if (type == DefaultBaseTypeName)
+			if (type == DefaultBaseTypeName) {
+				baseType = DefaultBaseType;
+				CheckIfBaseTypeIsGlobal ();
 				return;
-
+			}
+			
 			Type parent = null;
 			if (srcAssembly != null)
 				parent = srcAssembly.GetType (type);
@@ -752,8 +768,7 @@ namespace System.Web.UI {
 				ThrowParseException ("The parent type does not derive from " + DefaultBaseType);
 
 			baseType = parent;
-			if (parent.FullName.IndexOf ('.') == -1)
-				baseTypeIsGlobal = true;
+			CheckIfBaseTypeIsGlobal ();
 		}
 
 		internal void SetLanguage (string language)
@@ -819,18 +834,16 @@ namespace System.Web.UI {
 		}
 #endif
 
-		internal string Text
-		{
+		internal string Text {
 			get { return text; }
 			set { text = value; }
 		}
 
-		internal Type BaseType
-		{
+		internal Type BaseType {
 			get {
 				if (baseType == null)
-					baseType = DefaultBaseType;
-
+					SetBaseType (DefaultBaseTypeName);
+				
 				return baseType;
 			}
 		}