mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-16 17:10:20 -10:00
* ProvidersHelper.cs: HttpApplication.LoadTypeFromPrivateBin
renamed to LoadTypeFromBin.
2007-08-23 Marek Habersack <[email protected]>
* AppCodeCompiler.cs: use HttpApplication.BinDirectoryAssemblies
and HttpApplication.LoadTypeFromBin.
* BuildProvider.cs: use HttpApplication.BinDirectoryAssemblies in
AddAssembliesInBin.
2007-08-23 Marek Habersack <[email protected]>
* ApplicationHost.cs: set AppDomainSetup.PrivateBinPath to "bin"
if running on Windows or with MONO_IOMAP in effect, and to
"Bin:bin" otherwise.
2007-08-23 Marek Habersack <[email protected]>
* SimpleWebHandlerParser.cs: use
HttpApplication.BinDirectoryAssemblies in AddAssembliesInBin and
LoadAssemblyFromBin.
Restore the old logic in GetTypeFromBin, also use
HttpApplication.BinDirectoryAssemblies there.
* TemplateParser.cs: use HttpApplication.BinDirectories to
interate over the list of bin dirs.
Use HttpApplication.BinDirectoryAssemblies in AddAssembliesInBin.
2007-08-23 Marek Habersack <[email protected]>
* HttpApplication.cs: added a static array BinDirs which contains
the common bin directory names we can encounter.
Added internal static property IsRunningOnWindows.
Added internal enumerable property BinDirectories to iterate over
the full paths of the available binary directories.
Added internal enumerable property BinDirectoryAssemblies to
iterate over .dll files in the bin directories.
LoadTypeFromPrivateBin renamed to LoadTypeFromBin.
LoadTypeFromBin uses BinDirectoryAssemblies.
* HttpApplicationFactory.cs: use HttpApplication.BinDirectories to
interate over the list of bin dirs.
svn path=/trunk/mcs/; revision=84684
232 lines
6.0 KiB
C#
232 lines
6.0 KiB
C#
//
|
|
// System.Web.Compilation.BuildProvider
|
|
//
|
|
// Authors:
|
|
// Chris Toshok ([email protected])
|
|
// Gonzalo Paniagua Javier ([email protected])
|
|
//
|
|
// (C) 2006 Novell, Inc (http://www.novell.com)
|
|
//
|
|
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining
|
|
// a copy of this software and associated documentation files (the
|
|
// "Software"), to deal in the Software without restriction, including
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
// distribute, sublicense, and/or sell copies of the Software, and to
|
|
// permit persons to whom the Software is furnished to do so, subject to
|
|
// the following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be
|
|
// included in all copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
//
|
|
|
|
#if NET_2_0
|
|
|
|
using System;
|
|
using System.CodeDom.Compiler;
|
|
using System.Collections;
|
|
using System.Collections.Specialized;
|
|
using System.IO;
|
|
using System.Reflection;
|
|
using System.Web.Configuration;
|
|
using System.Web.Hosting;
|
|
using System.Web.Util;
|
|
|
|
namespace System.Web.Compilation {
|
|
|
|
public abstract class BuildProvider {
|
|
string virtual_path;
|
|
ArrayList ref_assemblies;
|
|
|
|
ICollection vpath_deps;
|
|
|
|
protected BuildProvider()
|
|
{
|
|
ref_assemblies = new ArrayList ();
|
|
}
|
|
|
|
internal void SetVirtualPath (string path)
|
|
{
|
|
virtual_path = path;
|
|
}
|
|
|
|
public virtual void GenerateCode (AssemblyBuilder assemblyBuilder)
|
|
{
|
|
}
|
|
|
|
public virtual string GetCustomString (CompilerResults results)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
protected CompilerType GetDefaultCompilerType ()
|
|
{
|
|
CompilationSection config;
|
|
config = (CompilationSection) WebConfigurationManager.GetSection ("system.web/compilation");
|
|
return GetDefaultCompilerTypeForLanguage (config.DefaultLanguage, config);
|
|
}
|
|
|
|
void SetCommonParameters (CompilationSection config, CompilerParameters p)
|
|
{
|
|
p.IncludeDebugInformation = config.Debug;
|
|
foreach (AssemblyInfo info in config.Assemblies) {
|
|
if (info.Assembly != "*") {
|
|
p.ReferencedAssemblies.Add (info.Assembly);
|
|
ref_assemblies.Add (info.Assembly);
|
|
} else {
|
|
AddAssembliesInBin (p.ReferencedAssemblies);
|
|
}
|
|
}
|
|
|
|
// explicit, strict?
|
|
// embedded? linked?/resources
|
|
}
|
|
|
|
void AddAssembliesInBin (StringCollection coll)
|
|
{
|
|
foreach (string s in HttpApplication.BinDirectoryAssemblies) {
|
|
coll.Add (s);
|
|
ref_assemblies.Add (s);
|
|
}
|
|
}
|
|
|
|
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;
|
|
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) {
|
|
Type type = Type.GetType (compiler.Type, true);
|
|
p = new CompilerParameters ();
|
|
p.CompilerOptions = compiler.CompilerOptions;
|
|
p.WarningLevel = compiler.WarningLevel;
|
|
SetCommonParameters (config, p);
|
|
return new CompilerType (type, p);
|
|
}
|
|
|
|
if (!CodeDomProvider.IsDefinedLanguage (language))
|
|
throw new HttpException (String.Format ("No compiler for language '{0}'.", language));
|
|
|
|
CompilerInfo info = CodeDomProvider.GetCompilerInfo (language);
|
|
CompilerParameters par = info.CreateDefaultCompilerParameters ();
|
|
SetCommonParameters (config, par);
|
|
return new CompilerType (info.CodeDomProviderType, par);
|
|
}
|
|
|
|
protected CompilerType GetDefaultCompilerTypeForLanguage (string language)
|
|
{
|
|
return GetDefaultCompilerTypeForLanguage (language, null);
|
|
}
|
|
|
|
public virtual Type GetGeneratedType (CompilerResults results)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
public virtual BuildProviderResultFlags GetResultFlags (CompilerResults results)
|
|
{
|
|
return BuildProviderResultFlags.Default;
|
|
}
|
|
|
|
protected TextReader OpenReader ()
|
|
{
|
|
return OpenReader (VirtualPath);
|
|
}
|
|
|
|
protected TextReader OpenReader (string virtualPath)
|
|
{
|
|
Stream st = OpenStream (virtualPath);
|
|
return new StreamReader (st, WebEncoding.FileEncoding);
|
|
}
|
|
|
|
protected Stream OpenStream ()
|
|
{
|
|
return OpenStream (VirtualPath);
|
|
}
|
|
|
|
protected Stream OpenStream (string virtualPath)
|
|
{
|
|
// MS also throws a NullReferenceException here when not hosted.
|
|
return VirtualPathProvider.OpenFile (virtualPath);
|
|
}
|
|
|
|
public virtual CompilerType CodeCompilerType {
|
|
get { return null; } // Documented to return null
|
|
}
|
|
|
|
protected ICollection ReferencedAssemblies {
|
|
get { return ref_assemblies; }
|
|
}
|
|
|
|
protected internal string VirtualPath {
|
|
get { return virtual_path; }
|
|
}
|
|
|
|
public virtual ICollection VirtualPathDependencies {
|
|
get {
|
|
if (vpath_deps == null)
|
|
vpath_deps = new OneNullCollection ();
|
|
|
|
return vpath_deps;
|
|
}
|
|
}
|
|
}
|
|
|
|
class OneNullCollection : ICollection {
|
|
public int Count {
|
|
get { return 1; }
|
|
}
|
|
|
|
public bool IsSynchronized {
|
|
get { return false; }
|
|
}
|
|
|
|
public object SyncRoot {
|
|
get { return this; }
|
|
}
|
|
|
|
public void CopyTo (Array array, int index)
|
|
{
|
|
if (array == null)
|
|
throw new ArgumentNullException ();
|
|
|
|
if (index < 0)
|
|
throw new ArgumentOutOfRangeException ();
|
|
|
|
if (array.Rank > 1)
|
|
throw new ArgumentException ();
|
|
|
|
int length = array.Length;
|
|
if (index >= length || index > length - 1)
|
|
throw new ArgumentException ();
|
|
|
|
array.SetValue (null, index);
|
|
}
|
|
|
|
public IEnumerator GetEnumerator ()
|
|
{
|
|
yield return null;
|
|
}
|
|
}
|
|
}
|
|
#endif
|
|
|