Skip to content

Commit

Permalink
Backport of r145831
Browse files Browse the repository at this point in the history
svn path=/branches/mono-2-4/mcs/; revision=145833
  • Loading branch information
grendello committed Nov 10, 2009
1 parent be535c8 commit eb6d24a
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 42 deletions.
Expand Up @@ -225,7 +225,7 @@ public void RegisterFoundry (string foundryName, string tagName, string source)

void RegisterConfigControls ()
{
PagesSection pages = WebConfigurationManager.GetWebApplicationSection ("system.web/pages") as PagesSection;
PagesSection pages = WebConfigurationManager.GetSection ("system.web/pages") as PagesSection;
if (pages == null)
return;

Expand Down
Expand Up @@ -249,7 +249,7 @@ internal void ConstructType ()
mainClass.TypeAttributes = TypeAttributes.Public;
mainNS.Types.Add (mainClass);

foreach (object o in parser.Imports) {
foreach (object o in parser.Imports.Keys) {
if (o is string)
mainNS.Imports.Add (new CodeNamespaceImport ((string) o));
}
Expand Down
8 changes: 8 additions & 0 deletions mcs/class/System.Web/System.Web.Compilation/ChangeLog
@@ -1,3 +1,11 @@
2009-11-10 Marek Habersack <mhabersack@novell.com>

* BaseCompiler.cs: parser.Imports is a Dictionary <>/Hashtable
now.

* AspComponentFoundry.cs: system.web/pages section is not confined
to the top-level web.config

2009-11-03 Marek Habersack <mhabersack@novell.com>

* AppResourcesCompiler.cs: put default culture resources in a
Expand Down
5 changes: 5 additions & 0 deletions mcs/class/System.Web/System.Web.Configuration_2.0/ChangeLog
@@ -1,3 +1,8 @@
2009-11-10 Marek Habersack <mhabersack@novell.com>

* WebConfigurationManager.cs: path passed to OpenWebConfiguration
from GetSection does not come from FindWebConfig.

2009-11-09 Marek Habersack <mhabersack@novell.com>

* WebConfigurationManager.cs: there's no need to cache sections by
Expand Down
Expand Up @@ -414,7 +414,7 @@ internal static object GetSection (string sectionName, string path, HttpContext
null, /* server */
null, /* userName */
null, /* password */
true /* path from FindWebConfig */);
false /* path from FindWebConfig */);
ConfigurationSection section = c.GetSection (sectionName);
if (section == null)
return null;
Expand Down
2 changes: 1 addition & 1 deletion mcs/class/System.Web/System.Web.UI/BaseParser.cs
Expand Up @@ -157,7 +157,7 @@ internal void ThrowParseFileNotFound (string path, params object[] parms)
VirtualPath vpath = VirtualPath;
string vp = vpath != null ? vpath.Absolute : null;
if (vp == null)
return WebConfigurationManager.GetWebApplicationSection (section) as TSection;
return WebConfigurationManager.GetSection (section) as TSection;
else
return WebConfigurationManager.GetSection (section, vp) as TSection;
}
Expand Down
11 changes: 11 additions & 0 deletions mcs/class/System.Web/System.Web.UI/ChangeLog
@@ -1,3 +1,14 @@
2009-11-10 Marek Habersack <mhabersack@novell.com>

* TemplateParser.cs: AddImports is called from LoadConfigDefaults
so that it reads configuration from the correct .config file (it
needs to be called after this.VirtualPath has been
initialized). Fixes an issue with MVC apps which put configuration
in Views/web.config etc. Fixes bug #552457

* ControlBuilder.cs, Page.cs: system.web/pages section is not
confined to the top-level web.config

2009-10-30 Marek Habersack <mhabersack@novell.com>

* Control.cs: ResolveClientUrl takes base path from
Expand Down
2 changes: 1 addition & 1 deletion mcs/class/System.Web/System.Web.UI/ControlBuilder.cs
Expand Up @@ -476,7 +476,7 @@ static Type MapTagType (Type tagType)
if (tagType == null)
return null;

PagesSection ps = WebConfigurationManager.GetWebApplicationSection ("system.web/pages") as PagesSection;
PagesSection ps = WebConfigurationManager.GetSection ("system.web/pages") as PagesSection;
if (ps == null)
return tagType;

Expand Down
4 changes: 2 additions & 2 deletions mcs/class/System.Web/System.Web.UI/Page.cs
Expand Up @@ -187,7 +187,7 @@ public Page ()
ID = "__Page";

#if NET_2_0
PagesSection ps = WebConfigurationManager.GetWebApplicationSection ("system.web/pages") as PagesSection;
PagesSection ps = WebConfigurationManager.GetSection ("system.web/pages") as PagesSection;
if (ps != null) {
asyncTimeout = ps.AsyncTimeout;
viewStateEncryptionMode = ps.ViewStateEncryptionMode;
Expand Down Expand Up @@ -618,7 +618,7 @@ protected internal
void InitializeStyleSheet ()
{
if (_styleSheetTheme == null) {
PagesSection ps = WebConfigurationManager.GetWebApplicationSection ("system.web/pages") as PagesSection;
PagesSection ps = WebConfigurationManager.GetSection ("system.web/pages") as PagesSection;
if (ps != null)
_styleSheetTheme = ps.StyleSheetTheme;
}
Expand Down
72 changes: 37 additions & 35 deletions mcs/class/System.Web/System.Web.UI/TemplateParser.cs
Expand Up @@ -89,11 +89,11 @@ internal enum OutputCacheParsedParams
#if NET_2_0
string[] binDirAssemblies;
Dictionary <string, bool> namespacesCache;
List <string> imports;
Dictionary <string, bool> imports;
List <string> interfaces;
List <ServerSideScript> scripts;
#else
ArrayList imports;
Hashtable imports;
ArrayList interfaces;
ArrayList scripts;
#endif
Expand Down Expand Up @@ -146,38 +146,32 @@ internal enum OutputCacheParsedParams

internal TemplateParser ()
{
LoadConfigDefaults ();
#if NET_2_0
imports = new List <string> ();
AddNamespaces (imports);
imports = new Dictionary <string, bool> (StringComparer.Ordinal);
#else
imports = new ArrayList ();
imports.Add ("System");
imports.Add ("System.Collections");
imports.Add ("System.Collections.Specialized");
imports.Add ("System.Configuration");
imports.Add ("System.Text");
imports.Add ("System.Text.RegularExpressions");
imports.Add ("System.Web");
imports.Add ("System.Web.Caching");
imports.Add ("System.Web.Security");
imports.Add ("System.Web.SessionState");
imports.Add ("System.Web.UI");
imports.Add ("System.Web.UI.WebControls");
imports.Add ("System.Web.UI.HtmlControls");
imports = new Hashtable ();
imports.Add ("System", true);
imports.Add ("System.Collections", true);
imports.Add ("System.Collections.Specialized", true);
imports.Add ("System.Configuration", true);
imports.Add ("System.Text", true);
imports.Add ("System.Text.RegularExpressions", true);
imports.Add ("System.Web", true);
imports.Add ("System.Web.Caching", true);
imports.Add ("System.Web.Security", true);
imports.Add ("System.Web.SessionState", true);
imports.Add ("System.Web.UI", true);
imports.Add ("System.Web.UI.WebControls", true);
imports.Add ("System.Web.UI.HtmlControls", true);
#endif

LoadConfigDefaults ();
assemblies = new ArrayList ();
#if NET_2_0
CompilationSection compConfig = CompilationConfig;
foreach (AssemblyInfo info in compConfig.Assemblies) {
if (info.Assembly != "*")
AddAssemblyByName (info.Assembly);
}

foreach (NamespaceInfo info in PagesConfig.Namespaces) {
imports.Add (info.Namespace);
}
#else
CompilationConfiguration compConfig = CompilationConfig;

Expand All @@ -193,6 +187,9 @@ internal TemplateParser ()

internal virtual void LoadConfigDefaults ()
{
#if NET_2_0
AddNamespaces (imports);
#endif
debug = CompilationConfig.Debug;
}

Expand All @@ -218,10 +215,10 @@ internal void AddControl (Type type, IDictionary attributes)
generator.AddControl (type, attributes);
}

void AddNamespaces (List <string> imports)
void AddNamespaces (Dictionary <string, bool> imports)
{
if (BuildManager.HaveResources)
imports.Add ("System.Resources");
imports.Add ("System.Resources", true);

PagesSection pages = PagesConfig;
if (pages == null)
Expand All @@ -230,9 +227,14 @@ void AddNamespaces (List <string> imports)
NamespaceCollection namespaces = pages.Namespaces;
if (namespaces == null || namespaces.Count == 0)
return;

foreach (NamespaceInfo nsi in namespaces)
imports.Add (nsi.Namespace);

foreach (NamespaceInfo nsi in namespaces) {
string ns = nsi.Namespace;
if (imports.ContainsKey (ns))
continue;

imports.Add (ns, true);
}
}
#endif

Expand Down Expand Up @@ -570,16 +572,16 @@ internal virtual void AddImport (string namesp)

if (imports == null) {
#if NET_2_0
imports = new List <string> ();
imports = new Dictionary <string, bool> (StringComparer.Ordinal);
#else
imports = new ArrayList ();
imports = new Hashtable ();
#endif
}

if (imports.Contains (namesp))
if (imports.ContainsKey (namesp))
return;

imports.Add (namesp);
imports.Add (namesp, true);
#if NET_2_0
AddAssemblyForNamespace (namesp);
#endif
Expand Down Expand Up @@ -1305,7 +1307,7 @@ internal string EncodeIdentifier (string value)
}
}

internal List <string> Imports {
internal Dictionary <string, bool> Imports {
get { return imports; }
}

Expand All @@ -1322,7 +1324,7 @@ internal string EncodeIdentifier (string value)
}
}

internal ArrayList Imports {
internal Hashtable Imports {
get { return imports; }
}

Expand Down

0 comments on commit eb6d24a

Please sign in to comment.