mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-16 17:10:20 -10:00
* System.Web.Compilation/BaseCompiler.cs: try getting the Type from the cache before doing the real work. Remove temporary files right after successful compilation. * System.Web.Compilation/CachingCompiler.cs: added GetTypeFromCache. * System.Web.Compilation/UserControlCompiler.cs: nothing interesting. * System.Web.Compilation/WebServiceCompiler.cs: try getting the Type from the cache before doing anything else. Remove temp files on sucessful compilation. * System.Web.UI/SimpleWebHandlerParser.cs: implemented GetCompiledTypeFromCache. When we read the default directive, check the cache for the Type and if present, don't keep reading and store the type found. * System.Web.UI/WebHandlerParser.cs: * System.Web.UI/WebServiceParser.cs: try GetCompiledTypeFromCache before actually compiling. svn path=/trunk/mcs/; revision=29652
117 lines
3.3 KiB
C#
117 lines
3.3 KiB
C#
//
|
|
// System.Web.Compilation.WebServiceCompiler
|
|
//
|
|
// Authors:
|
|
// Gonzalo Paniagua Javier ([email protected])
|
|
//
|
|
// (C) 2002,2003 Ximian, Inc (http://www.ximian.com)
|
|
// Copyright (c) 2040 Novell, Inc. (http://www.novell.com)
|
|
//
|
|
using System;
|
|
using System.CodeDom.Compiler;
|
|
using System.IO;
|
|
using System.Web.Configuration;
|
|
using System.Web.UI;
|
|
using System.Reflection;
|
|
|
|
namespace System.Web.Compilation
|
|
{
|
|
class WebServiceCompiler : BaseCompiler
|
|
{
|
|
SimpleWebHandlerParser parser;
|
|
ICodeCompiler compiler;
|
|
CodeDomProvider provider;
|
|
CompilerParameters compilerParameters;
|
|
string inputFile;
|
|
|
|
public WebServiceCompiler (SimpleWebHandlerParser wService)
|
|
: base (null)
|
|
{
|
|
this.parser = wService;
|
|
}
|
|
|
|
public static Type CompileIntoType (SimpleWebHandlerParser wService)
|
|
{
|
|
WebServiceCompiler wsc = new WebServiceCompiler (wService);
|
|
return wsc.GetCompiledType ();
|
|
}
|
|
|
|
public override Type GetCompiledType ()
|
|
{
|
|
Type type = CachingCompiler.GetTypeFromCache (parser.PhysicalPath, parser.ClassName);
|
|
if (type != null)
|
|
return type;
|
|
|
|
if (parser.Program.Trim () == "")
|
|
return parser.GetTypeFromBin (parser.ClassName);
|
|
|
|
string lang = parser.Language;
|
|
CompilationConfiguration config;
|
|
config = CompilationConfiguration.GetInstance (parser.Context);
|
|
provider = config.GetProvider (lang);
|
|
if (provider == null)
|
|
throw new HttpException ("Configuration error. Language not supported: " +
|
|
lang, 500);
|
|
|
|
compiler = provider.CreateCompiler ();
|
|
|
|
compilerParameters = CachingCompiler.GetOptions (parser.Assemblies);
|
|
compilerParameters.IncludeDebugInformation = parser.Debug;
|
|
compilerParameters.CompilerOptions = config.GetCompilerOptions (lang);
|
|
compilerParameters.WarningLevel = config.GetWarningLevel (lang);
|
|
|
|
bool keepFiles = (Environment.GetEnvironmentVariable ("MONO_ASPNET_NODELETE") != null);
|
|
|
|
TempFileCollection tempcoll;
|
|
tempcoll = new TempFileCollection (config.TempDirectory, keepFiles);
|
|
compilerParameters.TempFiles = tempcoll;
|
|
|
|
inputFile = tempcoll.AddExtension (provider.FileExtension);
|
|
Stream st = File.OpenWrite (inputFile);
|
|
StreamWriter sw = new StreamWriter (st);
|
|
sw.WriteLine (parser.Program);
|
|
sw.Close ();
|
|
|
|
string dllfilename = tempcoll.AddExtension ("dll", true);
|
|
if (!Directory.Exists (dynamicBase))
|
|
Directory.CreateDirectory (dynamicBase);
|
|
|
|
compilerParameters.OutputAssembly = Path.Combine (dynamicBase, dllfilename);
|
|
|
|
CompilerResults results = CachingCompiler.Compile (this);
|
|
CheckCompilerErrors (results);
|
|
if (results.CompiledAssembly == null)
|
|
throw new CompilationException (inputFile, results.Errors,
|
|
"No assembly returned after compilation!?");
|
|
|
|
results.TempFiles.Delete ();
|
|
return results.CompiledAssembly.GetType (parser.ClassName, true);
|
|
}
|
|
|
|
void CheckCompilerErrors (CompilerResults results)
|
|
{
|
|
if (results.NativeCompilerReturnValue == 0)
|
|
return;
|
|
|
|
throw new CompilationException (parser.PhysicalPath, results.Errors, parser.Program);
|
|
}
|
|
|
|
internal new SimpleWebHandlerParser Parser {
|
|
get { return parser; }
|
|
}
|
|
|
|
internal override ICodeCompiler Compiler {
|
|
get { return compiler; }
|
|
}
|
|
|
|
internal CompilerParameters CompilerOptions {
|
|
get { return compilerParameters; }
|
|
}
|
|
|
|
internal string InputFile {
|
|
get { return inputFile; }
|
|
}
|
|
}
|
|
}
|
|
|