Przeglądaj źródła

2004-06-08 Gonzalo Paniagua Javier <[email protected]>

	* System.Web.dll.sources: removed CSCompiler.cs

	* System.Web.Compilation/CSCompiler.cs: removed.

	* System.Web.Compilation/CachingCompiler.cs: language independent
	compilation for single files.

	* System.Web.UI/SimpleWebHandlerParser.cs:
	* System.Web.UI/TemplateParser.cs: pass the language when compiling from
	a file.

svn path=/trunk/mcs/; revision=29017
Gonzalo Paniagua Javier 21 lat temu
rodzic
commit
2dbdb5b80f

+ 4 - 0
mcs/class/System.Web/ChangeLog

@@ -1,3 +1,7 @@
+2004-06-08  Gonzalo Paniagua Javier <[email protected]>
+
+	* System.Web.dll.sources: removed CSCompiler.cs
+
 2004-06-07  Gonzalo Paniagua Javier <[email protected]>
 
 	* System.Web.dll.sources: removing ServerVariablesCollection. It does

+ 0 - 73
mcs/class/System.Web/System.Web.Compilation/CSCompiler.cs

@@ -1,73 +0,0 @@
-//
-// System.Web.Compilation.CSCompiler
-//
-// Authors:
-//	Gonzalo Paniagua Javier ([email protected])
-//
-// (C) 2003 Ximian, Inc (http://www.ximian.com)
-//
-using System;
-using System.CodeDom;
-using System.CodeDom.Compiler;
-using System.Collections;
-using System.Collections.Specialized;
-using System.IO;
-using System.Text;
-using System.Reflection;
-using Microsoft.CSharp;
-
-namespace System.Web.Compilation
-{
-	class CSCompiler
-	{
-		static CodeDomProvider provider;
-		static ICodeCompiler compiler;
-		string filename;
-		ArrayList assemblies;
-		CompilerParameters options;
-
-		static CSCompiler ()
-		{
-			provider = new CSharpCodeProvider ();
-			compiler = provider.CreateCompiler ();
-		}
-
-		private CSCompiler (string filename, ArrayList assemblies)
-		{
-			this.filename = filename;
-			this.assemblies = assemblies;
-			options = new CompilerParameters ();
-			if (assemblies != null) {
-				StringCollection coll = options.ReferencedAssemblies;
-				foreach (string str in assemblies)
-					coll.Add (str);
-			}
-		}
-
-		public Assembly GetCompiledAssembly ()
-		{
-			CompilerResults results = compiler.CompileAssemblyFromFile (options, filename);
-			if (results.NativeCompilerReturnValue != 0) {
-				StreamReader reader = new StreamReader (filename);
-				throw new CompilationException (filename, results.Errors, reader.ReadToEnd ());
-			}
-
-			return results.CompiledAssembly;
-		}
-
-		static public Assembly CompileCSFile (string file, ArrayList assemblies)
-		{
-			CSCompiler compiler = new CSCompiler (file, assemblies);
-			return compiler.GetCompiledAssembly ();
-		}
-
-		static public CodeDomProvider Provider {
-			get { return provider; }
-		}
-
-		static public ICodeCompiler Compiler {
-			get { return compiler; }
-		}
-	}
-}
-

+ 13 - 5
mcs/class/System.Web/System.Web.Compilation/CachingCompiler.cs

@@ -8,13 +8,12 @@
 // (c) Copyright Novell, Inc. (http://www.novell.com)
 //
 using System;
-using System.CodeDom;
 using System.CodeDom.Compiler;
 using System.Collections;
 using System.Collections.Specialized;
-using System.IO;
 using System.Web.UI;
 using System.Web.Caching;
+using System.Web.Configuration;
 
 namespace System.Web.Compilation
 {
@@ -79,7 +78,8 @@ namespace System.Web.Compilation
 			return options;
 		}
 
-		public static CompilerResults Compile (string key, string file, ArrayList assemblies)
+		public static CompilerResults Compile (string language, string key, string file,
+							ArrayList assemblies)
 		{
 			Cache cache = HttpRuntime.Cache;
 			CompilerResults results = (CompilerResults) cache [key];
@@ -90,9 +90,17 @@ namespace System.Web.Compilation
 				results = (CompilerResults) cache [key];
 				if (results != null)
 					return results;
-
+ 
+				CompilationConfiguration config;
+				config = CompilationConfiguration.GetInstance (HttpContext.Current);
+				CodeDomProvider provider = config.GetProvider (language);
+				if (provider == null)
+					throw new HttpException ("Configuration error. Language not supported: " +
+								  language, 500);
+
+				ICodeCompiler compiler = provider.CreateCompiler ();
 				CompilerParameters options = GetOptions (assemblies);
-				results = CSCompiler.Compiler.CompileAssemblyFromFile (options, file);
+				results = compiler.CompileAssemblyFromFile (options, file);
 				string [] deps = (string []) assemblies.ToArray (typeof (string));
 				cache.Insert (key, results, new CacheDependency (deps));
 			}

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

@@ -1,3 +1,9 @@
+2004-06-08  Gonzalo Paniagua Javier <[email protected]>
+
+	* CSCompiler.cs: removed.
+
+	* CachingCompiler.cs: language independent compilation for single files.
+
 2004-06-08  Gonzalo Paniagua Javier <[email protected]>
 
 	* BaseCompiler.cs:

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

@@ -1,3 +1,8 @@
+2004-06-08  Gonzalo Paniagua Javier <[email protected]>
+
+	* SimpleWebHandlerParser.cs:
+	* TemplateParser.cs: pass the language when compiling from a file.
+
 2004-06-08  Gonzalo Paniagua Javier <[email protected]>
 
 	* SimpleWebHandlerParser.cs: if we have a global.asax, move its

+ 1 - 1
mcs/class/System.Web/System.Web.UI/SimpleWebHandlerParser.cs

@@ -287,7 +287,7 @@ namespace System.Web.UI
 
 			AddDependency (realPath);
 
-			CompilerResults result = CachingCompiler.Compile (realPath, realPath, assemblies);
+			CompilerResults result = CachingCompiler.Compile (language, realPath, realPath, assemblies);
 			if (result.NativeCompilerReturnValue != 0) {
 				StreamReader reader = new StreamReader (realPath);
 				throw new CompilationException (realPath, result.Errors, reader.ReadToEnd ());

+ 1 - 1
mcs/class/System.Web/System.Web.UI/TemplateParser.cs

@@ -412,7 +412,7 @@ namespace System.Web.UI
 
 			AddDependency (realPath);
 
-			CompilerResults result = CachingCompiler.Compile (realPath, realPath, assemblies);
+			CompilerResults result = CachingCompiler.Compile (language, realPath, realPath, assemblies);
 			if (result.NativeCompilerReturnValue != 0) {
 				StringWriter writer = new StringWriter();
 				StreamReader reader = new StreamReader (realPath);

+ 0 - 1
mcs/class/System.Web/System.Web.dll.sources

@@ -81,7 +81,6 @@ System.Web.Compilation/AspParser.cs
 System.Web.Compilation/AspGenerator.cs
 System.Web.Compilation/WebServiceCompiler.cs
 System.Web.Compilation/CachingCompiler.cs
-System.Web.Compilation/CSCompiler.cs
 System.Web.Compilation/Directive.cs
 System.Web.Compilation/GlobalAsaxCompiler.cs
 System.Web.Compilation/PageCompiler.cs