#if NET_2_0
bool isRebuilding = false;
protected Hashtable partialNameOverride = new Hashtable();
+ protected CodeTypeDeclaration partialClass;
+ protected CodeTypeReferenceExpression partialClassExpr;
#endif
protected CodeTypeDeclaration mainClass;
protected CodeTypeReferenceExpression mainClassExpr;
classtype = classtype.Substring (dot + 1);
}
- mainNS = new CodeNamespace (ns);
- mainClass = new CodeTypeDeclaration (classtype);
- mainClass.IsPartial = true;
- mainClassExpr = new CodeTypeReferenceExpression (parser.PartialClassName);
- } else {
+ CodeNamespace partialNS = new CodeNamespace (ns);
+ partialClass = new CodeTypeDeclaration (classtype);
+ partialClass.IsPartial = true;
+ partialClassExpr = new CodeTypeReferenceExpression (parser.PartialClassName);
+
+ unit.Namespaces.Add (partialNS);
+ partialClass.TypeAttributes = TypeAttributes.Public;
+ partialNS.Types.Add (partialClass);
+ }
#endif
mainNS = new CodeNamespace ("ASP");
mainClass = new CodeTypeDeclaration (parser.ClassName);
- CodeTypeReference baseTypeRef = new CodeTypeReference (parser.BaseType.FullName);
+ CodeTypeReference baseTypeRef;
#if NET_2_0
- if (parser.BaseTypeIsGlobal)
+ if (partialClass != null) {
+ baseTypeRef = new CodeTypeReference (parser.PartialClassName);
baseTypeRef.Options |= CodeTypeReferenceOptions.GlobalReference;
+ } else {
+ baseTypeRef = new CodeTypeReference (parser.BaseType.FullName);
+ if (parser.BaseTypeIsGlobal)
+ baseTypeRef.Options |= CodeTypeReferenceOptions.GlobalReference;
+ }
+#else
+ baseTypeRef = new CodeTypeReference (parser.BaseType.FullName);
#endif
mainClass.BaseTypes.Add (baseTypeRef);
+
mainClassExpr = new CodeTypeReferenceExpression ("ASP." + parser.ClassName);
-#if NET_2_0
- }
-#endif
+
unit.Namespaces.Add (mainNS);
mainClass.TypeAttributes = TypeAttributes.Public;
mainNS.Types.Add (mainClass);
cast.Expression = refexp;
property.GetStatements.Add (ret);
- mainClass.Members.Add (property);
+ if (partialClass == null)
+ mainClass.Members.Add (property);
+ else
+ partialClass.Members.Add (property);
}
protected void CreateProfileProperty ()
2007-03-13 Marek Habersack <mhabersack@novell.com>
+ * PageCompiler.cs: interfaces are to be implemented by the parent
+ partial class, not the generated one.
+
* AppResourceFilesCollection.cs: added separate constructor for
local resources handling.
* TemplateControlCompiler.cs: request the local resource object
with proper virtual path.
+ Put field declarations for controls in the partial class.
* BaseCompiler.cs: added code to assing AppRelativeVirtualPath
property in the page/control constructor.
+ Change the generated code model for pages/controls to comply with
+ the way MS.NET does (partial class contains only two properties
+ plus declarations of all the controls, the actual control/page
+ class inherits from the partial class). Fixes bug #81001.
* AppResourcesCompiler.cs: does not require specifying manually
whether it's a global or local resource compiler anymore. New
protected override void AddInterfaces ()
{
base.AddInterfaces ();
- if (pageParser.EnableSessionState)
- mainClass.BaseTypes.Add (new CodeTypeReference (typeof(IRequiresSessionState)));
-
- if (pageParser.ReadOnlySessionState)
- mainClass.BaseTypes.Add (new CodeTypeReference (typeof (IReadOnlySessionState)));
+ CodeTypeReference cref;
+
+ if (pageParser.EnableSessionState) {
+ cref = new CodeTypeReference (typeof(IRequiresSessionState));
+#if NET_2_0
+ cref.Options |= CodeTypeReferenceOptions.GlobalReference;
+ if (partialClass != null)
+ partialClass.BaseTypes.Add (cref);
+ else
+#endif
+ mainClass.BaseTypes.Add (cref);
+ }
+
+ if (pageParser.ReadOnlySessionState) {
+ cref = new CodeTypeReference (typeof (IReadOnlySessionState));
+#if NET_2_0
+ cref.Options |= CodeTypeReferenceOptions.GlobalReference;
+ if (partialClass != null)
+ partialClass.BaseTypes.Add (cref);
+ else
+#endif
+ mainClass.BaseTypes.Add (cref);
+ }
}
void CreateGetTypeHashCode ()
CodeMemberField field;
field = new CodeMemberField (builder.ControlType.FullName, builder.ID);
field.Attributes = MemberAttributes.Family;
- mainClass.Members.Add (field);
+#if NET_2_0
+ if (partialClass != null)
+ partialClass.Members.Add (field);
+ else
+#endif
+ mainClass.Members.Add (field);
}
bool CheckBaseFieldOrProperty (string id, Type type)
if (childrenAsProperties || builder.ControlType == null) {
string typeString;
- if (builder is RootBuilder) {
-#if NET_2_0
- if (parser.IsPartial)
- typeString = parser.PartialClassName;
- else
-#endif
- typeString = parser.ClassName;
- }
+ if (builder is RootBuilder)
+ typeString = parser.ClassName;
else {
if (builder.ControlType != null && builder.isProperty &&
!typeof (ITemplate).IsAssignableFrom (builder.ControlType))
CodeCastExpression cast = new CodeCastExpression (appType.FullName, propRef);
prop.GetStatements.Add (new CodeMethodReturnStatement (cast));
+#if NET_2_0
+ if (partialClass != null)
+ partialClass.Members.Add (prop);
+ else
+#endif
mainClass.Members.Add (prop);
}
+2007-03-13 Marek Habersack <mhabersack@novell.com>
+
+ * TemplateParser.cs: name generated classes the same way MS.NET
+ does - include the app-relative path to the control/page in the
+ class name.
+
2007-03-13 Adar Wesley <adarw@mainsoft.com>
* Page.cs: improved Async Page implementation.
if (inherits != null)
SetBaseType (inherits);
-
+#endif
className = GetString (atts, "ClassName", null);
if (className != null && !CodeGenerator.IsValidLanguageIndependentIdentifier (className))
ThrowParseException (String.Format ("'{0}' is not valid for 'className'", className));
-#endif
+
if (atts.Count > 0)
ThrowParseException ("Unknown attribute: " + GetOneKey (atts));
if (className != null)
return className;
+#if NET_2_0
+ string physPath = HttpContext.Current.Request.PhysicalApplicationPath;
+
+ if (StrUtils.StartsWith (inputFile, physPath)) {
+ className = inputFile.Substring (physPath.Length).ToLower (CultureInfo.InvariantCulture);
+ className = className.Replace ('.', '_');
+ className = className.Replace ('/', '_').Replace ('\\', '_');
+ } else
+#endif
className = Path.GetFileName (inputFile).Replace ('.', '_');
className = className.Replace ('-', '_');
className = className.Replace (' ', '_');