Author: mhabersack
Date: 2006-11-08 08:43:06 -0500 (Wed, 08 Nov 2006)
New Revision: 67517

Modified:
   trunk/mcs/class/System.Web/System.Web.Compilation/AppCodeCompiler.cs
   trunk/mcs/class/System.Web/System.Web.Compilation/AppResourcesCompiler.cs
   trunk/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs
   trunk/mcs/class/System.Web/System.Web.Compilation/BuildProvider.cs
   trunk/mcs/class/System.Web/System.Web.Compilation/ChangeLog
   trunk/mcs/class/System.Web/System.Web/ChangeLog
   trunk/mcs/class/System.Web/System.Web/HttpApplicationFactory.cs
   trunk/mcs/class/System.Web/System.Web/HttpRuntime.cs
Log:
A few changes related to App_*Resources and App_Code folders

Modified: trunk/mcs/class/System.Web/System.Web/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web/ChangeLog     2006-11-08 13:14:16 UTC 
(rev 67516)
+++ trunk/mcs/class/System.Web/System.Web/ChangeLog     2006-11-08 13:43:06 UTC 
(rev 67517)
@@ -1,7 +1,15 @@
 2006-11-08  Marek Habersack  <[EMAIL PROTECTED]>
 
-       * HttpApplicationFactory.cs: Add invocation of the App_Code compiler
+       * HttpRuntime.cs: Moved the resource compiler results handling to
+       the resource compiler itself.
 
+       * HttpApplicationFactory.cs: Add invocation of the App_Code
+       compiler. Moved the resource compiler results handling to the
+       resource compiler itself. Removed compilation of the local
+       resources from here - it should be done only when a request
+       determines that the App_LocalResources directory exists.
+       
+
 2006-11-07  Andrew Skiba  <[EMAIL PROTECTED]>
 
        * HttpRuntime.cs: TARGET_JVM ifdef

Modified: trunk/mcs/class/System.Web/System.Web/HttpApplicationFactory.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web/HttpApplicationFactory.cs     
2006-11-08 13:14:16 UTC (rev 67516)
+++ trunk/mcs/class/System.Web/System.Web/HttpApplicationFactory.cs     
2006-11-08 13:43:06 UTC (rev 67517)
@@ -386,13 +386,7 @@
                
 #if NET_2_0 && !TARGET_J2EE
                                AppGlobalResourcesCompiler agrc = new 
AppGlobalResourcesCompiler();
-                               CompilerResults cr = agrc.Compile();
-                               if (cr != null && cr.CompiledAssembly != null)
-                                       
WebConfigurationManager.ExtraAssemblies.Add(cr.PathToAssembly);
-                               AppLocalResourcesCompiler alrc  = new 
AppLocalResourcesCompiler ();
-                               cr = alrc.Compile ();
-                               if (cr != null && cr.CompiledAssembly != null)
-                                       
WebConfigurationManager.ExtraAssemblies.Add (cr.PathToAssembly);
+                               agrc.Compile();
                                
                                // Todo: Process App_WebResources here
                                

Modified: trunk/mcs/class/System.Web/System.Web/HttpRuntime.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web/HttpRuntime.cs        2006-11-08 
13:14:16 UTC (rev 67516)
+++ trunk/mcs/class/System.Web/System.Web/HttpRuntime.cs        2006-11-08 
13:43:06 UTC (rev 67517)
@@ -265,10 +265,9 @@
                                // Compile the local resources, if any
                                //
                                AppLocalResourcesCompiler alrc = new 
AppLocalResourcesCompiler();
-                               CompilerResults cr = alrc.Compile();
-                               if (cr != null && cr.CompiledAssembly != null)
-                                       
WebConfigurationManager.ExtraAssemblies.Add(cr.PathToAssembly);
-#endif                 
+                               alrc.Compile();
+#endif
+                               
                                //
                                // Ask application to service the request
                                //

Modified: trunk/mcs/class/System.Web/System.Web.Compilation/AppCodeCompiler.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Compilation/AppCodeCompiler.cs        
2006-11-08 13:14:16 UTC (rev 67516)
+++ trunk/mcs/class/System.Web/System.Web.Compilation/AppCodeCompiler.cs        
2006-11-08 13:43:06 UTC (rev 67517)
@@ -145,10 +145,8 @@
                                parameters.OutputAssembly = assemblyName;
                                CompilerResults results = 
provider.CompileAssemblyFromFile (parameters, knownfiles.ToArray ());
                                if (results.Errors.Count == 0) {
-                                       IList assemblies = 
BuildManager.CodeAssemblies;
-                                       if (assemblies == null)
-                                               throw new HttpException 
("Internal error compiling code from the App_Code folder.");
-                                       assemblies.Add (results.PathToAssembly);
+                                       BuildManager.CodeAssemblies.Add 
(results.PathToAssembly);
+                                       BuildManager.TopLevelAssemblies.Add 
(results.CompiledAssembly);
                                } else {
                                        if 
(HttpContext.Current.IsCustomErrorEnabled)
                                                throw new HttpException ("An 
error occurred while initializing application.");

Modified: 
trunk/mcs/class/System.Web/System.Web.Compilation/AppResourcesCompiler.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Compilation/AppResourcesCompiler.cs   
2006-11-08 13:14:16 UTC (rev 67516)
+++ trunk/mcs/class/System.Web/System.Web.Compilation/AppResourcesCompiler.cs   
2006-11-08 13:43:06 UTC (rev 67517)
@@ -34,6 +34,7 @@
 using System.Collections.Generic;
 using System.IO;
 using System.Web;
+using System.Web.Configuration;
 
 namespace System.Web.Compilation
 {
@@ -108,13 +109,17 @@
                        provider.GenerateCodeFromCompileUnit (unit, sw, new 
CodeGeneratorOptions ());
                        CompilerResults ret = provider.CompileAssemblyFromDom 
(cp, unit);      
                        
-                       if (ret.CompiledAssembly == null) {
+                       if (ret.Errors.Count != 0) {
                                Console.WriteLine ("Failed to compile 
{0}/*.resx. Errors:", ResourceDirectory);
                                foreach (CompilerError ce in ret.Errors)
                                        Console.WriteLine("{5} {0} ({1} 
{2}:{3}): {4}", ce.ErrorNumber,
                                                          ce.FileName, ce.Line, 
ce.Column, ce.ErrorText,
                                                          ce.IsWarning ? 
"warning" : "error");
+                       } else {
+                               
WebConfigurationManager.ExtraAssemblies.Add(ret.PathToAssembly);
+                               BuildManager.TopLevelAssemblies.Add 
(ret.CompiledAssembly);
                        }
+                       
                        return ret;
                }
        }

Modified: trunk/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs   
2006-11-08 13:14:16 UTC (rev 67516)
+++ trunk/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs   
2006-11-08 13:43:06 UTC (rev 67517)
@@ -44,7 +44,8 @@
 
 namespace System.Web.Compilation {
        public sealed class BuildManager {
-               private static List<string> AppCodeAssemblies = new 
List<string>();
+               private static List<string> AppCode_Assemblies = new 
List<string>();
+               private static List<Assembly> TopLevel_Assemblies = new 
List<Assembly>();
                
                internal BuildManager ()
                {
@@ -79,6 +80,20 @@
                        return null; // null is ok here until we store the 
dependency set in the Cache.
                }
 
+               internal static BuildProvider GetBuildProviderForPath (string 
virtualPath, bool throwOnMissing)
+               {
+                       string extension = VirtualPathUtility.GetExtension 
(virtualPath);
+                       object o = WebConfigurationManager.GetSection 
("system.web/compilation/buildProviders", virtualPath);
+                       BuildProviderCollection coll = o as 
BuildProviderCollection;
+                       if (coll == null || coll.Count == 0)
+                               ThrowNoProviderException (extension);
+                       
+                       BuildProvider provider = coll.GetProviderForExtension 
(extension);
+                       if (provider == null && throwOnMissing)
+                               ThrowNoProviderException (extension);
+                       return provider;
+               }
+               
                public static Assembly GetCompiledAssembly (string virtualPath)
                {
                        BuildProvider provider;
@@ -101,17 +116,7 @@
 
                        if (!HostingEnvironment.VirtualPathProvider.FileExists 
(virtualPath))
                                throw new HttpException (String.Format ("The 
file '{0}' does not exist.", virtualPath));
-
-                       object o = WebConfigurationManager.GetSection 
("system.web/compilation/buildProviders", virtualPath);
-                       BuildProviderCollection coll = 
(BuildProviderCollection) o;
-                       string extension = VirtualPathUtility.GetExtension 
(virtualPath);
-                       if (coll == null || coll.Count == 0)
-                               ThrowNoProviderException (extension);
-
-                       provider = coll.GetProviderForExtension (extension);
-                       if (provider == null)
-                               ThrowNoProviderException (extension);
-
+                       provider = GetBuildProviderForPath (virtualPath, true);
                        CompilerType compiler_type = provider.CodeCompilerType;
                        Type ctype = compiler_type.CodeDomProviderType;
                        CodeDomProvider dom_provider = (CodeDomProvider) 
Activator.CreateInstance (ctype, null);
@@ -122,10 +127,13 @@
                        return abuilder;
                }
 
-               [MonoTODO]
                public static string GetCompiledCustomString (string 
virtualPath)
                {
-                       throw new NotImplementedException ();
+                       BuildProvider provider = GetBuildProviderForPath 
(virtualPath, false);
+                       if (provider == null)
+                               return null;
+                       // FIXME: where to get the CompilerResults from?
+                       return provider.GetCustomString (null);
                }
 
                static CompilerParameters PrepareParameters (TempFileCollection 
temp_files,
@@ -177,10 +185,17 @@
                // Assemblies built from the App_Code directory
                public static IList CodeAssemblies {
                        get {
-                               return AppCodeAssemblies;
+                               return AppCode_Assemblies;
                        }
                }
 
+               internal static IList TopLevelAssemblies 
+               {
+                       get {
+                               return TopLevel_Assemblies;
+                       }
+               }
+               
        }
 }
 

Modified: trunk/mcs/class/System.Web/System.Web.Compilation/BuildProvider.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Compilation/BuildProvider.cs  
2006-11-08 13:14:16 UTC (rev 67516)
+++ trunk/mcs/class/System.Web/System.Web.Compilation/BuildProvider.cs  
2006-11-08 13:43:06 UTC (rev 67517)
@@ -66,17 +66,16 @@
                {
                }
 
-               [MonoTODO]
                public virtual string GetCustomString (CompilerResults results)
                {
-                       throw new NotImplementedException ();
+                       return null;
                }
 
                protected CompilerType GetDefaultCompilerType ()
                {
                        CompilationSection config;
                        config = (CompilationSection) 
WebConfigurationManager.GetSection ("system.web/compilation");
-                       return GetDefaultCompilerTypeForLanguage 
(config.DefaultLanguage);
+                       return GetDefaultCompilerTypeForLanguage 
(config.DefaultLanguage, config);
                }
 
                void SetCommonParameters (CompilationSection config, 
CompilerParameters p)
@@ -120,14 +119,18 @@
                        }
                }
 
-               protected CompilerType GetDefaultCompilerTypeForLanguage 
(string language)
+               internal CompilerType GetDefaultCompilerTypeForLanguage (string 
language, CompilationSection configSection)
                {
                        // MS throws when accesing a Hashtable, we do here.
                        if (language == null || language == "")
                                throw new ArgumentNullException ("language");
 
                        CompilationSection config;
-                       config = (CompilationSection) 
WebConfigurationManager.GetSection ("system.web/compilation");
+                       if (configSection == null)
+                               config = WebConfigurationManager.GetSection 
("system.web/compilation") as CompilationSection;
+                       else
+                               config = configSection;
+                       
                        Compiler compiler = config.Compilers.Get (language);
                        CompilerParameters p;
                        if (compiler != null) {
@@ -147,6 +150,11 @@
                        SetCommonParameters (config, par);
                        return new CompilerType (info.CodeDomProviderType, par);
                }
+               
+               protected CompilerType GetDefaultCompilerTypeForLanguage 
(string language)
+               {
+                       return GetDefaultCompilerTypeForLanguage (language, 
null);
+               }
 
                public virtual Type GetGeneratedType (CompilerResults results)
                {

Modified: trunk/mcs/class/System.Web/System.Web.Compilation/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Compilation/ChangeLog 2006-11-08 
13:14:16 UTC (rev 67516)
+++ trunk/mcs/class/System.Web/System.Web.Compilation/ChangeLog 2006-11-08 
13:43:06 UTC (rev 67517)
@@ -1,8 +1,17 @@
 2006-11-08  Marek Habersack  <[EMAIL PROTECTED]>
 
+       * BuildProvider.cs: Implemented the GetCustomString
+       method. Removed the necessity to retrieve the CompilationSection
+       twice when GetDefaultCompilerType is called.
+
+       * AppResourcesCompiler.cs: Added resource compiler results
+       handling.
+
        * AppCodeCompiler.cs: The App_Code compiler classes
 
-       * BuildManager.cs: Implement the CodeAssemblies property
+       * BuildManager.cs: Implement the CodeAssemblies property.
+       Added an internal TopLevelTypes property to be used in the custom
+       GetType methods. Implemented the GetCompiledCustomString method.
 
        * BaseCompiler.cs: Reference the assemblies from App_Code, if any
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to