Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,52 @@
//
// System.Web.Compilation.AppResourceFileInfo
//
// Authors:
// Marek Habersack (grendello@gmail.com)
//
// (C) 2006 Marek Habersack
//
//
// 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.
//
using System.IO;
namespace System.Web.Compilation
{
class AppResourceFileInfo
{
public readonly bool Embeddable;
public readonly bool Compilable;
public readonly FileInfo Info;
public readonly AppResourceFileKind Kind;
public bool Seen;
public AppResourceFileInfo (FileInfo info, AppResourceFileKind kind)
{
this.Embeddable = (kind == AppResourceFileKind.Resource || kind == AppResourceFileKind.Binary);
this.Compilable = (kind == AppResourceFileKind.ResX);
this.Info = info;
this.Kind = kind;
this.Seen = false;
}
};
};

View File

@@ -0,0 +1,177 @@
//
// System.Web.Compilation.AppResourceFilesCollection
//
// Authors:
// Marek Habersack (grendello@gmail.com)
//
// (C) 2006 Marek Habersack
//
//
// 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.
//
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Web.Util;
namespace System.Web.Compilation
{
internal enum AppResourceFileKind
{
NotResource,
ResX,
Resource,
Binary
};
internal class AppResourcesLengthComparer<T>: IComparer<T>
{
int CompareStrings (string a, string b)
{
if (a == null || b == null)
return 0;
return (int)b.Length - (int)a.Length;
}
int IComparer<T>.Compare (T _a, T _b)
{
string a = null, b = null;
if (_a is string && _b is string) {
a = _a as string;
b = _b as string;
} else if (_a is List<string> && _b is List<string>) {
List<string> tmp = _a as List<string>;
a = tmp [0];
tmp = _b as List<string>;
b = tmp [0];
} else if (_a is AppResourceFileInfo && _b is AppResourceFileInfo) {
AppResourceFileInfo tmp = _a as AppResourceFileInfo;
a = tmp.Info.Name;
tmp = _b as AppResourceFileInfo;
b = tmp.Info.Name;
} else
return 0;
return CompareStrings (a, b);
}
}
internal class AppResourceFilesCollection
{
List <AppResourceFileInfo> files;
bool isGlobal;
string sourceDir;
public string SourceDir {
get { return sourceDir; }
}
public bool HasFiles {
get {
if (String.IsNullOrEmpty (sourceDir))
return false;
return files.Count > 0;
}
}
public List <AppResourceFileInfo> Files {
get { return files; }
}
public AppResourceFilesCollection (HttpContext context)
{
if (context == null)
throw new ArgumentNullException ("context");
this.isGlobal = true;
this.files = new List <AppResourceFileInfo> ();
string resourcePath;
resourcePath = Path.Combine (HttpRuntime.AppDomainAppPath, "App_GlobalResources");
if (Directory.Exists (resourcePath))
sourceDir = resourcePath;
}
public AppResourceFilesCollection (string parserDir)
{
if (String.IsNullOrEmpty (parserDir))
throw new ArgumentException ("parserDir cannot be empty");
this.isGlobal = true;
this.files = new List <AppResourceFileInfo> ();
string resourcePath;
resourcePath = Path.Combine (parserDir, "App_LocalResources");
if (Directory.Exists (resourcePath)) {
sourceDir = resourcePath;
HttpApplicationFactory.WatchLocationForRestart (sourceDir, "*");
}
}
public void Collect ()
{
if (String.IsNullOrEmpty (sourceDir))
return;
DirectoryInfo di = new DirectoryInfo (sourceDir);
FileInfo[] infos = di.GetFiles ();
if (infos.Length == 0)
return;
string extension;
AppResourceFileInfo arfi;
AppResourceFileKind kind;
foreach (FileInfo fi in infos) {
extension = fi.Extension;
if (Acceptable (extension, out kind))
arfi = new AppResourceFileInfo (fi, kind);
else
continue;
files.Add (arfi);
}
if (isGlobal && files.Count == 0)
return;
AppResourcesLengthComparer<AppResourceFileInfo> lcFiles = new AppResourcesLengthComparer<AppResourceFileInfo> ();
files.Sort (lcFiles);
}
bool Acceptable (string extension, out AppResourceFileKind kind)
{
switch (extension.ToLower (Helpers.InvariantCulture))
{
default:
kind = AppResourceFileKind.NotResource;
return false;
case ".resx":
kind = AppResourceFileKind.ResX;
return true;
case ".resource":
kind = AppResourceFileKind.Resource;
return true;
}
}
};
};

View File

@@ -0,0 +1,314 @@
//
// System.Web.Compilation.AppResourceAseemblyBuilder
//
// Authors:
// Marek Habersack <grendel@twistedcode.net>
//
// (C) 2007-2009 Novell, Inc (http://novell.com/)
// (C) 2011 Xamarin, Inc (http://xamarin.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.
//
using System;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Web;
using System.Web.Configuration;
using System.Web.Util;
namespace System.Web.Compilation
{
class AppResourcesAssemblyBuilder
{
#if NET_4_5
static string framework_version = "4.5";
static string profile_path = "net_4_5";
#elif NET_4_0
static string framework_version = "4.0";
static string profile_path = "net_4_0";
#else
static string framework_version = "2.0";
static string profile_path = "net_2_0";
#endif
CompilationSection config;
CompilerInfo ci;
CodeDomProvider _provider;
string baseAssemblyPath;
string baseAssemblyDirectory;
string canonicAssemblyName;
Assembly mainAssembly;
AppResourcesCompiler appResourcesCompiler;
public CodeDomProvider Provider {
get {
if (_provider == null)
_provider = ci.CreateProvider ();
else
return _provider;
if (_provider == null)
throw new ApplicationException ("Failed to instantiate the default compiler.");
return _provider;
}
}
public Assembly MainAssembly {
get { return mainAssembly; }
}
public AppResourcesAssemblyBuilder (string canonicAssemblyName, string baseAssemblyPath, AppResourcesCompiler appres)
{
this.appResourcesCompiler = appres;
this.baseAssemblyPath = baseAssemblyPath;
this.baseAssemblyDirectory = Path.GetDirectoryName (baseAssemblyPath);
this.canonicAssemblyName = canonicAssemblyName;
config = WebConfigurationManager.GetWebApplicationSection ("system.web/compilation") as CompilationSection;
if (config == null || !CodeDomProvider.IsDefinedLanguage (config.DefaultLanguage))
throw new ApplicationException ("Could not get the default compiler.");
ci = CodeDomProvider.GetCompilerInfo (config.DefaultLanguage);
if (ci == null || !ci.IsCodeDomProviderTypeValid)
throw new ApplicationException ("Failed to obtain the default compiler information.");
}
public void Build ()
{
Build (null);
}
public void Build (CodeCompileUnit unit)
{
Dictionary <string, List <string>> cultures = appResourcesCompiler.CultureFiles;
List <string> defaultCultureFiles = appResourcesCompiler.DefaultCultureFiles;
if (defaultCultureFiles != null)
BuildDefaultAssembly (defaultCultureFiles, unit);
foreach (KeyValuePair <string, List <string>> kvp in cultures)
BuildSatelliteAssembly (kvp.Key, kvp.Value);
}
void BuildDefaultAssembly (List <string> files, CodeCompileUnit unit)
{
AssemblyBuilder abuilder = new AssemblyBuilder (Provider);
if (unit != null)
abuilder.AddCodeCompileUnit (unit);
CompilerParameters cp = ci.CreateDefaultCompilerParameters ();
cp.OutputAssembly = baseAssemblyPath;
cp.GenerateExecutable = false;
cp.TreatWarningsAsErrors = true;
cp.IncludeDebugInformation = config.Debug;
foreach (string f in files)
cp.EmbeddedResources.Add (f);
CompilerResults results = abuilder.BuildAssembly (cp);
if (results == null)
return;
if (results.NativeCompilerReturnValue == 0) {
mainAssembly = results.CompiledAssembly;
BuildManager.TopLevelAssemblies.Add (mainAssembly);
} else {
if (HttpContext.Current.IsCustomErrorEnabled)
throw new ApplicationException ("An error occurred while compiling global resources.");
throw new CompilationException (null, results.Errors, null);
}
HttpRuntime.WritePreservationFile (mainAssembly, canonicAssemblyName);
HttpRuntime.EnableAssemblyMapping (true);
}
void BuildSatelliteAssembly (string cultureName, List <string> files)
{
string assemblyPath = BuildAssemblyPath (cultureName);
var info = new ProcessStartInfo ();
var al = new Process ();
string arguments = SetAlPath (info);
var sb = new StringBuilder (arguments);
sb.Append ("/c:\"" + cultureName + "\" ");
sb.Append ("/t:lib ");
sb.Append ("/out:\"" + assemblyPath + "\" ");
if (mainAssembly != null)
sb.Append ("/template:\"" + mainAssembly.Location + "\" ");
string responseFilePath = assemblyPath + ".response";
using (FileStream fs = File.OpenWrite (responseFilePath)) {
using (StreamWriter sw = new StreamWriter (fs)) {
foreach (string f in files)
sw.WriteLine ("/embed:\"" + f + "\" ");
}
}
sb.Append ("@\"" + responseFilePath + "\"");
info.Arguments = sb.ToString ();
info.CreateNoWindow = true;
info.UseShellExecute = false;
info.RedirectStandardOutput = true;
info.RedirectStandardError = true;
al.StartInfo = info;
var alOutput = new StringCollection ();
var alMutex = new Mutex ();
DataReceivedEventHandler outputHandler = (object sender, DataReceivedEventArgs args) => {
if (args.Data != null) {
alMutex.WaitOne ();
alOutput.Add (args.Data);
alMutex.ReleaseMutex ();
}
};
al.ErrorDataReceived += outputHandler;
al.OutputDataReceived += outputHandler;
// TODO: consider using asynchronous processes
try {
al.Start ();
} catch (Exception ex) {
throw new HttpException (String.Format ("Error running {0}", al.StartInfo.FileName), ex);
}
Exception alException = null;
int exitCode = 0;
try {
al.BeginOutputReadLine ();
al.BeginErrorReadLine ();
al.WaitForExit ();
exitCode = al.ExitCode;
} catch (Exception ex) {
alException = ex;
} finally {
al.CancelErrorRead ();
al.CancelOutputRead ();
al.Close ();
}
if (exitCode != 0 || alException != null) {
// TODO: consider adding a new type of compilation exception,
// tailored for al
CompilerErrorCollection errors = null;
if (alOutput.Count != 0) {
foreach (string line in alOutput) {
if (!line.StartsWith ("ALINK: error ", StringComparison.Ordinal))
continue;
if (errors == null)
errors = new CompilerErrorCollection ();
int colon = line.IndexOf (':', 13);
string errorNumber = colon != -1 ? line.Substring (13, colon - 13) : "Unknown";
string errorText = colon != -1 ? line.Substring (colon + 1) : line.Substring (13);
errors.Add (new CompilerError (Path.GetFileName (assemblyPath), 0, 0, errorNumber, errorText));
}
}
throw new CompilationException (Path.GetFileName (assemblyPath), errors, null);
}
}
string SetAlPath (ProcessStartInfo info)
{
if (RuntimeHelpers.RunningOnWindows) {
string alPath;
string monoPath;
PropertyInfo gac = typeof (Environment).GetProperty ("GacPath", BindingFlags.Static|BindingFlags.NonPublic);
MethodInfo get_gac = gac.GetGetMethod (true);
string p = Path.GetDirectoryName ((string) get_gac.Invoke (null, null));
monoPath = Path.Combine (Path.GetDirectoryName (Path.GetDirectoryName (p)), "bin\\mono.bat");
if (!File.Exists (monoPath)) {
monoPath = Path.Combine (Path.GetDirectoryName (Path.GetDirectoryName (p)), "bin\\mono.exe");
if (!File.Exists (monoPath)) {
monoPath = Path.Combine (Path.GetDirectoryName (Path.GetDirectoryName (Path.GetDirectoryName (p))), "mono\\mono\\mini\\mono.exe");
if (!File.Exists (monoPath))
throw new FileNotFoundException ("Windows mono path not found: " + monoPath);
}
}
alPath = Path.Combine (p, framework_version + "\\al.exe");
if (!File.Exists (alPath)) {
alPath = Path.Combine (Path.GetDirectoryName (p), "lib\\" + profile_path + "\\al.exe");
if (!File.Exists (alPath))
throw new FileNotFoundException ("Windows al path not found: " + alPath);
}
info.FileName = monoPath;
return alPath + " ";
} else {
#if NET_4_0
info.FileName = "al";
#else
info.FileName = "al2";
#endif
return String.Empty;
}
}
string BuildAssemblyPath (string cultureName)
{
string baseDir = Path.Combine (baseAssemblyDirectory, cultureName);
if (!Directory.Exists (baseDir))
Directory.CreateDirectory (baseDir);
string baseFileName = Path.GetFileNameWithoutExtension (baseAssemblyPath);
string fileName = String.Concat (baseFileName, ".resources.dll");
fileName = Path.Combine (baseDir, fileName);
return fileName;
}
CodeCompileUnit GenerateAssemblyInfo (string cultureName)
{
CodeAttributeArgument[] args = new CodeAttributeArgument [1];
args [0] = new CodeAttributeArgument (new CodePrimitiveExpression (cultureName));
CodeCompileUnit unit = new CodeCompileUnit ();
unit.AssemblyCustomAttributes.Add (
new CodeAttributeDeclaration (
new CodeTypeReference ("System.Reflection.AssemblyCultureAttribute"),
args));
args = new CodeAttributeArgument [2];
args [0] = new CodeAttributeArgument (new CodePrimitiveExpression ("ASP.NET"));
args [1] = new CodeAttributeArgument (new CodePrimitiveExpression (Environment.Version.ToString ()));
unit.AssemblyCustomAttributes.Add (
new CodeAttributeDeclaration (
new CodeTypeReference ("System.CodeDom.Compiler.GeneratedCodeAttribute"),
args));
return unit;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,101 @@
//
// System.Web.Compilation.AppSettingsExpressionBuilder
//
// Authors:
// Chris Toshok (toshok@ximian.com)
//
// (C) 2006-2009 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.
//
using System;
using System.CodeDom;
using System.ComponentModel;
using System.Configuration;
using System.Web.Configuration;
using System.Web.UI;
using System.Reflection;
namespace System.Web.Compilation
{
[ExpressionEditor("System.Web.UI.Design.AppSettingsExpressionEditor, " + Consts.AssemblySystem_Design)]
[ExpressionPrefix("AppSettings")]
public class AppSettingsExpressionBuilder : ExpressionBuilder
{
public override object EvaluateExpression (object target, BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
{
return GetAppSetting (entry.Expression.Trim ());
}
public static object GetAppSetting (string key)
{
string value = WebConfigurationManager.AppSettings [key];
if (value == null)
throw new InvalidOperationException (String.Format ("The application setting '{0}' was not found.", key));
return value;
}
public static object GetAppSetting (string key, Type targetType, string propertyName)
{
object value = GetAppSetting (key);
if (targetType == null)
return value.ToString ();
PropertyInfo pi = targetType.GetProperty(propertyName);
if (pi == null)
return value.ToString ();
try {
TypeConverter converter = TypeDescriptor.GetConverter (pi.PropertyType);
return converter.ConvertFrom (value);
} catch (NotSupportedException) {
throw new InvalidOperationException (String.Format (
"Could not convert application setting '{0}' " +
" to type '{1}' for property '{2}'.", value,
pi.PropertyType.Name, pi.Name));
}
}
public override CodeExpression GetCodeExpression (BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
{
Type type = entry.DeclaringType;
PropertyDescriptor descriptor = TypeDescriptor.GetProperties(type)[entry.PropertyInfo.Name];
CodeExpression[] expressionArray = new CodeExpression[3];
expressionArray[0] = new CodePrimitiveExpression(entry.Expression.Trim());
expressionArray[1] = new CodeTypeOfExpression(entry.Type);
expressionArray[2] = new CodePrimitiveExpression(entry.Name);
return new CodeCastExpression(descriptor.PropertyType, new CodeMethodInvokeExpression(new
CodeTypeReferenceExpression(base.GetType()), "GetAppSetting", expressionArray));
}
public override bool SupportsEvaluate {
get { return true; }
}
}
}

View File

@@ -0,0 +1,104 @@
//
// System.Web.Compilation.AppWebResourcesCompiler
//
// Authors:
// Marek Habersack <mhabersack@novell.com>
//
// Copyright (C) 2008 Novell, Inc (http://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 WEBSERVICES_DEP
using System;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.IO;
using System.Reflection;
using System.Web;
using System.Web.Configuration;
namespace System.Web.Compilation
{
internal class AppWebReferencesCompiler
{
const string ResourcesDirName = "App_WebReferences";
public void Compile ()
{
string refsPath = Path.Combine (HttpRuntime.AppDomainAppPath, ResourcesDirName);
if (!Directory.Exists (refsPath))
return;
string[] files = Directory.GetFiles (refsPath, "*.wsdl", SearchOption.AllDirectories);
if (files == null || files.Length == 0)
return;
CompilationSection cs = WebConfigurationManager.GetWebApplicationSection ("system.web/compilation") as CompilationSection;
if (cs == null)
throw new HttpException ("Unable to determine default compilation language.");
CompilerType ct = BuildManager.GetDefaultCompilerTypeForLanguage (cs.DefaultLanguage, cs);
CodeDomProvider codeDomProvider = null;
Exception codeDomException = null;
try {
codeDomProvider = Activator.CreateInstance (ct.CodeDomProviderType) as CodeDomProvider;
} catch (Exception e) {
codeDomException = e;
}
if (codeDomProvider == null)
throw new HttpException ("Unable to instantiate default compilation language provider.", codeDomException);
AssemblyBuilder ab = new AssemblyBuilder (codeDomProvider, "App_WebReferences_");
ab.CompilerOptions = ct.CompilerParameters;
VirtualPath vp;
WsdlBuildProvider wbp;
foreach (string file in files) {
vp = VirtualPath.PhysicalToVirtual (file);
if (vp == null)
continue;
wbp = new WsdlBuildProvider ();
wbp.SetVirtualPath (vp);
wbp.GenerateCode (ab);
}
CompilerResults results;
try {
results = ab.BuildAssembly ();
} catch (CompilationException ex) {
throw new HttpException ("Failed to compile web references.", ex);
}
if (results == null)
return;
Assembly asm = results.CompiledAssembly;
BuildManager.TopLevelAssemblies.Add (asm);
}
}
}
#endif

View File

@@ -0,0 +1,62 @@
//
// System.Web.Compilation.ApplicationFileBuildProvider
//
// Authors:
// Marek Habersack (mhabersack@novell.com)
//
// (C) 2008-2009 Novell, Inc
//
//
// 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.
//
using System;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Collections;
using System.IO;
using System.Reflection;
using System.Web;
using System.Web.UI;
namespace System.Web.Compilation
{
[BuildProviderAppliesTo (BuildProviderAppliesTo.Web)]
internal class ApplicationFileBuildProvider : TemplateBuildProvider
{
protected override BaseCompiler CreateCompiler (TemplateParser parser)
{
return new GlobalAsaxCompiler (parser as ApplicationFileParser);
}
protected override TemplateParser CreateParser (VirtualPath virtualPath, string physicalPath, HttpContext context)
{
return CreateParser (virtualPath, physicalPath, OpenReader (virtualPath.Original), context);
}
protected override TemplateParser CreateParser (VirtualPath virtualPath, string physicalPath, TextReader reader, HttpContext context)
{
return new ApplicationFileParser (virtualPath, physicalPath, reader, context);
}
}
}

View File

@@ -0,0 +1,49 @@
//
// System.Web.Compilation.AspComponentFoundry
//
// Authors:
// Marek Habersack (mhabersack@novell.com)
//
// (C) 2008 Novell, Inc (http://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.
//
namespace System.Web.Compilation
{
internal sealed class AspComponent
{
public readonly Type Type;
public readonly string Prefix;
public readonly string Source;
public readonly bool FromConfig;
public readonly string Namespace;
public AspComponent (Type type, string ns, string prefix, string source, bool fromConfig)
{
Type = type;
Namespace = ns;
Prefix = prefix;
Source = source;
FromConfig = fromConfig;
}
}
}

View File

@@ -0,0 +1,490 @@
//
// System.Web.Compilation.AspComponentFoundry
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
// (C) 2002,2003 Ximian, Inc (http://www.ximian.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.
//
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.Util;
namespace System.Web.Compilation
{
class AspComponentFoundry
{
Hashtable foundries;
Dictionary <string, AspComponent> components;
Dictionary <string, AspComponent> Components {
get {
if (components == null)
components = new Dictionary <string, AspComponent> (StringComparer.OrdinalIgnoreCase);
return components;
}
}
public AspComponentFoundry ()
{
foundries = new Hashtable (StringComparer.InvariantCultureIgnoreCase);
Assembly sw = typeof (AspComponentFoundry).Assembly;
RegisterFoundry ("asp", sw, "System.Web.UI.WebControls");
RegisterFoundry ("", "object", typeof (System.Web.UI.ObjectTag));
RegisterConfigControls ();
}
public AspComponent GetComponent (string tagName)
{
if (tagName == null || tagName.Length == 0)
return null;
if (components != null) {
AspComponent ret;
if (components.TryGetValue (tagName, out ret))
return ret;
}
string foundryName, tag;
int colon = tagName.IndexOf (':');
if (colon > -1) {
if (colon == 0)
throw new Exception ("Empty TagPrefix is not valid.");
if (colon + 1 == tagName.Length)
return null;
foundryName = tagName.Substring (0, colon);
tag = tagName.Substring (colon + 1);
} else {
foundryName = String.Empty;
tag = tagName;
}
object o = foundries [foundryName];
if (o == null)
return null;
Foundry foundry = o as Foundry;
if (foundry != null)
return CreateComponent (foundry, tagName, foundryName, tag);
ArrayList af = o as ArrayList;
if (af == null)
return null;
AspComponent component = null;
Exception e = null;
foreach (Foundry f in af) {
try {
component = CreateComponent (f, tagName, foundryName, tag);
if (component != null)
return component;
} catch (Exception ex) {
e = ex;
}
}
if (e != null)
throw e;
return null;
}
AspComponent CreateComponent (Foundry foundry, string tagName, string prefix, string tag)
{
string source, ns;
Type type;
type = foundry.GetType (tag, out source, out ns);
if (type == null)
return null;
AspComponent ret = new AspComponent (type, ns, prefix, source, foundry.FromConfig);
Dictionary <string, AspComponent> components = Components;
components.Add (tagName, ret);
return ret;
}
public void RegisterFoundry (string foundryName, Assembly assembly, string nameSpace)
{
RegisterFoundry (foundryName, assembly, nameSpace, false);
}
public void RegisterFoundry (string foundryName,
Assembly assembly,
string nameSpace,
bool fromConfig)
{
AssemblyFoundry foundry = new AssemblyFoundry (assembly, nameSpace);
foundry.FromConfig = fromConfig;
InternalRegister (foundryName, foundry, fromConfig);
}
public void RegisterFoundry (string foundryName, string tagName, Type type)
{
RegisterFoundry (foundryName, tagName, type, false);
}
public void RegisterFoundry (string foundryName,
string tagName,
Type type,
bool fromConfig)
{
TagNameFoundry foundry = new TagNameFoundry (tagName, type);
foundry.FromConfig = fromConfig;
InternalRegister (foundryName, foundry, fromConfig);
}
public void RegisterFoundry (string foundryName, string tagName, string source)
{
RegisterFoundry (foundryName, tagName, source, false);
}
public void RegisterFoundry (string foundryName,
string tagName,
string source,
bool fromConfig)
{
TagNameFoundry foundry = new TagNameFoundry (tagName, source);
foundry.FromConfig = fromConfig;
InternalRegister (foundryName, foundry, fromConfig);
}
public void RegisterAssemblyFoundry (string foundryName,
string assemblyName,
string nameSpace,
bool fromConfig)
{
AssemblyFoundry foundry = new AssemblyFoundry (assemblyName, nameSpace);
foundry.FromConfig = fromConfig;
InternalRegister (foundryName, foundry, fromConfig);
}
void RegisterConfigControls ()
{
PagesSection pages = WebConfigurationManager.GetSection ("system.web/pages") as PagesSection;
if (pages == null)
return;
TagPrefixCollection controls = pages.Controls;
if (controls == null || controls.Count == 0)
return;
IList appCode = BuildManager.CodeAssemblies;
bool haveCodeAssemblies = appCode != null && appCode.Count > 0;
Assembly asm;
foreach (TagPrefixInfo tpi in controls) {
if (!String.IsNullOrEmpty (tpi.TagName))
RegisterFoundry (tpi.TagPrefix, tpi.TagName, tpi.Source, true);
else if (String.IsNullOrEmpty (tpi.Assembly)) {
if (haveCodeAssemblies) {
foreach (object o in appCode) {
asm = o as Assembly;
if (asm == null)
continue;
RegisterFoundry (tpi.TagPrefix, asm, tpi.Namespace, true);
}
}
} else if (!String.IsNullOrEmpty (tpi.Namespace))
RegisterAssemblyFoundry (tpi.TagPrefix,
tpi.Assembly,
tpi.Namespace,
true);
}
}
void InternalRegister (string foundryName, Foundry foundry, bool fromConfig)
{
object f = foundries [foundryName];
Foundry newFoundry = null;
if (f is CompoundFoundry) {
((CompoundFoundry) f).Add (foundry);
return;
} else if (f == null || f is ArrayList || (f is AssemblyFoundry && foundry is AssemblyFoundry)) {
newFoundry = foundry;
} else if (f != null) {
CompoundFoundry compound = new CompoundFoundry (foundryName);
compound.Add ((Foundry) f);
compound.Add (foundry);
newFoundry = foundry;
newFoundry.FromConfig = fromConfig;
}
if (newFoundry == null)
return;
if (f == null) {
foundries [foundryName] = newFoundry;
return;
}
ArrayList af = f as ArrayList;
if (af == null) {
af = new ArrayList (2);
af.Add (f);
foundries [foundryName] = af;
}
if (newFoundry is AssemblyFoundry) {
object o;
for (int i = 0; i < af.Count; i++) {
o = af [i];
if (o is AssemblyFoundry) {
af.Insert (i, newFoundry);
return;
}
}
af.Add (newFoundry);
} else
af.Insert (0, newFoundry);
}
public bool LookupFoundry (string foundryName)
{
return foundries.Contains (foundryName);
}
abstract class Foundry
{
bool _fromConfig;
public bool FromConfig {
get { return _fromConfig; }
set { _fromConfig = value; }
}
public abstract Type GetType (string componentName, out string source, out string ns);
}
class TagNameFoundry : Foundry
{
string tagName;
Type type;
string source;
public bool FromWebConfig {
get { return source != null; }
}
public TagNameFoundry (string tagName, string source)
{
this.tagName = tagName;
this.source = source;
}
public TagNameFoundry (string tagName, Type type)
{
this.tagName = tagName;
this.type = type;
}
public override Type GetType (string componentName, out string source, out string ns)
{
source = null;
ns = null;
if (0 != String.Compare (componentName, tagName, true, Helpers.InvariantCulture))
return null;
source = this.source;
return LoadType ();
}
Type LoadType ()
{
if (type != null)
return type;
HttpContext context = HttpContext.Current;
string vpath;
string realpath;
if (VirtualPathUtility.IsAppRelative (source)) {
vpath = source;
realpath = context.Request.MapPath (source);
} else {
vpath = VirtualPathUtility.ToAppRelative (source);
realpath = source;
}
if ((type = CachingCompiler.GetTypeFromCache (realpath)) != null)
return type;
type = BuildManager.GetCompiledType (vpath);
if (type != null) {
AspGenerator.AddTypeToCache (null, realpath, type);
BuildManager.AddToReferencedAssemblies (type.Assembly);
}
return type;
}
public string TagName {
get { return tagName; }
}
}
class AssemblyFoundry : Foundry
{
string nameSpace;
Assembly assembly;
string assemblyName;
Dictionary <string, Assembly> assemblyCache;
public AssemblyFoundry (Assembly assembly, string nameSpace)
{
this.assembly = assembly;
this.nameSpace = nameSpace;
if (assembly != null)
this.assemblyName = assembly.FullName;
else
this.assemblyName = null;
}
public AssemblyFoundry (string assemblyName, string nameSpace)
{
this.assembly = null;
this.nameSpace = nameSpace;
this.assemblyName = assemblyName;
}
public override Type GetType (string componentName, out string source, out string ns)
{
source = null;
ns = nameSpace;
if (assembly == null && assemblyName != null)
assembly = GetAssemblyByName (assemblyName, true);
string typeName = String.Concat (nameSpace, ".", componentName);
if (assembly != null)
return assembly.GetType (typeName, false, true);
IList tla = BuildManager.TopLevelAssemblies;
if (tla != null && tla.Count > 0) {
Type ret = null;
foreach (Assembly asm in tla) {
if (asm == null)
continue;
ret = asm.GetType (typeName, false, true);
if (ret != null)
return ret;
}
}
return null;
}
Assembly GetAssemblyByName (string name, bool throwOnMissing)
{
if (assemblyCache == null)
assemblyCache = new Dictionary <string, Assembly> ();
if (assemblyCache.ContainsKey (name))
return assemblyCache [name];
Assembly assembly = null;
Exception error = null;
if (name.IndexOf (',') != -1) {
try {
assembly = Assembly.Load (name);
} catch (Exception e) { error = e; }
}
if (assembly == null) {
try {
assembly = Assembly.LoadWithPartialName (name);
} catch (Exception e) { error = e; }
}
if (assembly == null)
if (throwOnMissing)
throw new HttpException ("Assembly " + name + " not found", error);
else
return null;
assemblyCache.Add (name, assembly);
return assembly;
}
}
class CompoundFoundry : Foundry
{
AssemblyFoundry assemblyFoundry;
Hashtable tagnames;
string tagPrefix;
public CompoundFoundry (string tagPrefix)
{
this.tagPrefix = tagPrefix;
tagnames = new Hashtable (StringComparer.InvariantCultureIgnoreCase);
}
public void Add (Foundry foundry)
{
if (foundry is AssemblyFoundry) {
assemblyFoundry = (AssemblyFoundry) foundry;
return;
}
TagNameFoundry tn = (TagNameFoundry) foundry;
string tagName = tn.TagName;
if (tagnames.Contains (tagName)) {
if (tn.FromWebConfig)
return;
string msg = String.Format ("{0}:{1} already registered.", tagPrefix, tagName);
throw new ApplicationException (msg);
}
tagnames.Add (tagName, foundry);
}
public override Type GetType (string componentName, out string source, out string ns)
{
source = null;
ns = null;
Type type = null;
Foundry foundry = tagnames [componentName] as Foundry;
if (foundry != null)
return foundry.GetType (componentName, out source, out ns);
if (assemblyFoundry != null) {
try {
type = assemblyFoundry.GetType (componentName, out source, out ns);
return type;
} catch { }
}
string msg = String.Format ("Type {0} not registered for prefix {1}", componentName, tagPrefix);
throw new ApplicationException (msg);
}
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,432 @@
//
// System.Web.Compilation.AspTokenizer
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
// Marek Habersack <mhabersack@novell.com>
//
// (C) 2002,2003 Ximian, Inc (http://www.ximian.com)
// (C) 2003-2009 Novell, Inc (http://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.
//
using System;
using System.Collections;
using System.IO;
using System.Text;
using System.Security.Cryptography;
namespace System.Web.Compilation
{
class Token
{
public const int EOF = 0x0200000;
public const int IDENTIFIER = 0x0200001;
public const int DIRECTIVE = 0x0200002;
public const int ATTVALUE = 0x0200003;
public const int TEXT = 0x0200004;
public const int DOUBLEDASH = 0x0200005;
public const int CLOSING = 0x0200006;
}
class AspTokenizer
{
const int CHECKSUM_BUF_SIZE = 8192;
class PutBackItem
{
public readonly string Value;
public readonly int Position;
public readonly int CurrentToken;
public readonly bool InTag;
public PutBackItem (string value, int position, int currentToken, bool inTag)
{
Value = value;
Position = position;
CurrentToken = currentToken;
InTag = inTag;
}
}
static char [] lfcr = new char [] { '\n', '\r' };
TextReader sr;
int current_token;
StringBuilder sb, odds;
int col, line;
int begcol, begline;
int position;
bool inTag;
bool expectAttrValue;
bool alternatingQuotes;
bool hasPutBack;
bool verbatim;
bool have_value;
bool have_unget;
int unget_value;
string val;
Stack putBackBuffer;
MD5 checksum;
char[] checksum_buf = new char [CHECKSUM_BUF_SIZE];
int checksum_buf_pos = -1;
public MD5 Checksum {
get { return checksum; }
}
public AspTokenizer (TextReader reader)
{
this.sr = reader;
sb = new StringBuilder ();
odds= new StringBuilder();
col = line = 1;
hasPutBack = inTag = false;
}
public bool Verbatim
{
get { return verbatim; }
set { verbatim = value; }
}
public void put_back ()
{
if (hasPutBack && !inTag)
throw new HttpException ("put_back called twice!");
hasPutBack = true;
if (putBackBuffer == null)
putBackBuffer = new Stack ();
string val = Value;
putBackBuffer.Push (new PutBackItem (val, position, current_token, inTag));
position -= val.Length;
}
public int get_token ()
{
if (hasPutBack) {
PutBackItem pbi;
if (verbatim) {
pbi = putBackBuffer.Pop () as PutBackItem;
string value = pbi.Value;
switch (value.Length) {
case 0:
// do nothing, CurrentToken will be used
break;
case 1:
pbi = new PutBackItem (String.Empty, pbi.Position, (int)value [0], false);
break;
default:
pbi = new PutBackItem (value, pbi.Position, (int)value [0], false);
break;
}
} else
pbi = putBackBuffer.Pop () as PutBackItem;
hasPutBack = putBackBuffer.Count > 0;
position = pbi.Position;
have_value = false;
val = null;
sb = new StringBuilder (pbi.Value);
current_token = pbi.CurrentToken;
inTag = pbi.InTag;
return current_token;
}
begline = line;
begcol = col;
have_value = false;
current_token = NextToken ();
return current_token;
}
bool is_identifier_start_character (char c)
{
return (Char.IsLetter (c) || c == '_' );
}
bool is_identifier_part_character (char c)
{
return (Char.IsLetterOrDigit (c) || c == '_' || c == '-');
}
void ungetc (int value)
{
have_unget = true;
unget_value = value;
// Only '/' passes through here now.
// If we ever let \n here, update 'line'
position--;
col--;
}
void TransformNextBlock (int count, bool final)
{
byte[] input = Encoding.UTF8.GetBytes (checksum_buf, 0, count);
if (checksum == null)
checksum = MD5.Create ();
if (final)
checksum.TransformFinalBlock (input, 0, input.Length);
else
checksum.TransformBlock (input, 0, input.Length, input, 0);
input = null;
checksum_buf_pos = -1;
}
void UpdateChecksum (int c)
{
bool final = c == -1;
if (!final) {
if (checksum_buf_pos + 1 >= CHECKSUM_BUF_SIZE)
TransformNextBlock (checksum_buf_pos + 1, false);
checksum_buf [++checksum_buf_pos] = (char)c;
} else
TransformNextBlock (checksum_buf_pos + 1, true);
}
int read_char ()
{
int c;
if (have_unget) {
c = unget_value;
have_unget = false;
} else {
c = sr.Read ();
UpdateChecksum (c);
}
if (c == '\r' && sr.Peek () == '\n') {
c = sr.Read ();
UpdateChecksum (c);
position++;
}
if (c == '\n'){
col = -1;
line++;
}
if (c != -1) {
col++;
position++;
}
return c;
}
int ReadAttValue (int start)
{
int quoteChar = 0;
bool quoted = false;
if (start == '"' || start == '\'') {
quoteChar = start;
quoted = true;
} else {
sb.Append ((char) start);
}
int c;
int last = 0;
bool inServerTag = false;
alternatingQuotes = true;
while ((c = sr.Peek ()) != -1) {
if (c == '%' && last == '<') {
inServerTag = true;
} else if (inServerTag && c == '>' && last == '%') {
inServerTag = false;
} else if (!inServerTag) {
if (!quoted && c == '/') {
read_char ();
c = sr.Peek ();
if (c == -1) {
c = '/';
} else if (c == '>') {
ungetc ('/');
break;
}
} else if (!quoted && (c == '>' || Char.IsWhiteSpace ((char) c))) {
break;
} else if (quoted && c == quoteChar && last != '\\') {
read_char ();
break;
}
} else if (quoted && c == quoteChar) {
alternatingQuotes = false;
}
sb.Append ((char) c);
read_char ();
last = c;
}
return Token.ATTVALUE;
}
int NextToken ()
{
int c;
sb.Length = 0;
odds.Length=0;
while ((c = read_char ()) != -1){
if (verbatim){
inTag = false;
sb.Append ((char) c);
return c;
}
if (inTag && expectAttrValue && (c == '"' || c == '\''))
return ReadAttValue (c);
if (c == '<'){
inTag = true;
sb.Append ((char) c);
return c;
}
if (c == '>'){
inTag = false;
sb.Append ((char) c);
return c;
}
if (current_token == '<' && "%/!".IndexOf ((char) c) != -1){
sb.Append ((char) c);
return c;
}
if (inTag && current_token == '%' && "@#=".IndexOf ((char) c) != -1){
if (odds.Length == 0 || odds.ToString ().IndexOfAny (lfcr) < 0) {
sb.Append ((char) c);
return c;
}
sb.Append ((char) c);
continue;
}
if (inTag && c == '-' && sr.Peek () == '-'){
sb.Append ("--");
read_char ();
return Token.DOUBLEDASH;
}
if (!inTag){
sb.Append ((char) c);
while ((c = sr.Peek ()) != -1 && c != '<')
sb.Append ((char) read_char ());
return (c != -1 || sb.Length > 0) ? Token.TEXT : Token.EOF;
}
if (inTag && current_token == '=' && !Char.IsWhiteSpace ((char) c))
return ReadAttValue (c);
if (inTag && is_identifier_start_character ((char) c)){
sb.Append ((char) c);
while ((c = sr.Peek ()) != -1) {
if (!is_identifier_part_character ((char) c) && c != ':')
break;
sb.Append ((char) read_char ());
}
if (current_token == '@' && Directive.IsDirective (sb.ToString ()))
return Token.DIRECTIVE;
return Token.IDENTIFIER;
}
if (!Char.IsWhiteSpace ((char) c)) {
sb.Append ((char) c);
return c;
}
// keep otherwise discarded characters in case we need.
odds.Append((char) c);
}
return Token.EOF;
}
public string Value {
get {
if (have_value)
return val;
have_value = true;
val = sb.ToString ();
return val;
}
}
public string Odds {
get {
return odds.ToString();
}
}
public bool InTag {
get { return inTag; }
set { inTag = value; }
}
// Hack for preventing confusion with VB comments (see bug #63451)
public bool ExpectAttrValue {
get { return expectAttrValue; }
set { expectAttrValue = value; }
}
public bool AlternatingQuotes {
get { return alternatingQuotes; }
}
public int BeginLine {
get { return begline; }
}
public int BeginColumn {
get { return begcol; }
}
public int EndLine {
get { return line; }
}
public int EndColumn {
get { return col; }
}
public int Position {
get { return position; }
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,61 @@
//
// System.Web.Compilation.BuildDependencySet
//
// Authors:
// Chris Toshok (toshok@ximian.com)
//
// (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.
//
using System;
using System.Collections;
namespace System.Web.Compilation {
public sealed class BuildDependencySet {
internal BuildDependencySet ()
{
}
[MonoTODO ("Not implemented")]
public string HashCode {
get {
throw new NotImplementedException ();
}
}
[MonoTODO ("Not implemented")]
public IEnumerable VirtualPaths {
get {
throw new NotImplementedException ();
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,79 @@
//
// System.Web.Compilation.BuildManagerCacheItem
//
// Authors:
// Marek Habersack (mhabersack@novell.com)
//
// (C) 2008-2009 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.
//
using System;
using System.CodeDom.Compiler;
using System.Reflection;
using System.Text;
namespace System.Web.Compilation
{
sealed class BuildManagerCacheItem
{
public readonly string CompiledCustomString;
public readonly Assembly BuiltAssembly;
public readonly string VirtualPath;
public readonly Type Type;
public BuildManagerCacheItem (Assembly assembly, BuildProvider bp, CompilerResults results)
{
this.BuiltAssembly = assembly;
this.CompiledCustomString = bp.GetCustomString (results);
this.VirtualPath = bp.VirtualPath;
this.Type = bp.GetGeneratedType (results);
}
public override string ToString ()
{
StringBuilder sb = new StringBuilder ("BuildCacheItem [");
bool first = true;
if (!String.IsNullOrEmpty (CompiledCustomString)) {
sb.Append ("compiledCustomString: " + CompiledCustomString);
first = false;
}
if (BuiltAssembly != null) {
sb.Append ((first ? String.Empty : "; ") + "assembly: " + BuiltAssembly.ToString ());
first = false;
}
if (!String.IsNullOrEmpty (VirtualPath)) {
sb.Append ((first ? String.Empty : "; ") + "virtualPath: " + VirtualPath);
first = false;
}
sb.Append ("]");
return sb.ToString ();
}
}
}

View File

@@ -0,0 +1,434 @@
//
// System.Web.Compilation.BuildManagerDirectoryBuilder
//
// Authors:
// Marek Habersack (mhabersack@novell.com)
//
// (C) 2008-2009 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.
//
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Web;
using System.Web.Configuration;
using System.Web.Hosting;
using System.Web.Util;
namespace System.Web.Compilation
{
sealed class BuildManagerDirectoryBuilder
{
sealed class BuildProviderItem
{
public BuildProvider Provider;
public int ListIndex;
public int ParentIndex;
public BuildProviderItem (BuildProvider bp, int listIndex, int parentIndex)
{
this.Provider = bp;
this.ListIndex = listIndex;
this.ParentIndex = parentIndex;
}
}
readonly VirtualPath virtualPath;
readonly string virtualPathDirectory;
CompilationSection compilationSection;
Dictionary <string, BuildProvider> buildProviders;
VirtualPathProvider vpp;
CompilationSection CompilationSection {
get {
if (compilationSection == null)
compilationSection = WebConfigurationManager.GetSection ("system.web/compilation") as CompilationSection;
return compilationSection;
}
}
public BuildManagerDirectoryBuilder (VirtualPath virtualPath)
{
if (virtualPath == null)
throw new ArgumentNullException ("virtualPath");
this.vpp = HostingEnvironment.VirtualPathProvider;
this.virtualPath = virtualPath;
this.virtualPathDirectory = VirtualPathUtility.GetDirectory (virtualPath.Absolute);
}
public List <BuildProviderGroup> Build (bool single)
{
if (StrUtils.StartsWith (virtualPath.AppRelative, "~/App_Themes/")) {
var themebp = new ThemeDirectoryBuildProvider ();
themebp.SetVirtualPath (virtualPath);
return GetSingleBuildProviderGroup (themebp);
}
CompilationSection section = CompilationSection;
BuildProviderCollection bpcoll = section != null ? section.BuildProviders : null;
if (bpcoll == null || bpcoll.Count == 0)
return null;
if (virtualPath.IsFake) {
BuildProvider bp = GetBuildProvider (virtualPath, bpcoll);
if (bp == null)
return null;
return GetSingleBuildProviderGroup (bp);
}
if (single) {
AddVirtualFile (GetVirtualFile (virtualPath.Absolute), bpcoll);
} else {
var cache = new Dictionary <string, bool> (RuntimeHelpers.StringEqualityComparer);
AddVirtualDir (GetVirtualDirectory (virtualPath.Absolute), bpcoll, cache);
cache = null;
if (buildProviders == null || buildProviders.Count == 0)
AddVirtualFile (GetVirtualFile (virtualPath.Absolute), bpcoll);
}
if (buildProviders == null || buildProviders.Count == 0)
return null;
var buildProviderGroups = new List <BuildProviderGroup> ();
foreach (BuildProvider bp in buildProviders.Values)
AssignToGroup (bp, buildProviderGroups);
if (buildProviderGroups == null || buildProviderGroups.Count == 0) {
buildProviderGroups = null;
return null;
}
// We need to reverse the order, so that the build happens from the least
// dependant assemblies to the most dependant ones, more or less.
buildProviderGroups.Reverse ();
return buildProviderGroups;
}
bool AddBuildProvider (BuildProvider buildProvider)
{
if (buildProviders == null)
buildProviders = new Dictionary <string, BuildProvider> (RuntimeHelpers.StringEqualityComparer);
string bpPath = buildProvider.VirtualPath;
if (buildProviders.ContainsKey (bpPath))
return false;
buildProviders.Add (bpPath, buildProvider);
return true;
}
void AddVirtualDir (VirtualDirectory vdir, BuildProviderCollection bpcoll, Dictionary <string, bool> cache)
{
if (vdir == null)
return;
BuildProvider bp;
IDictionary <string, bool> deps;
var dirs = new List <string> ();
string fileVirtualPath;
foreach (VirtualFile file in vdir.Files) {
fileVirtualPath = file.VirtualPath;
if (BuildManager.IgnoreVirtualPath (fileVirtualPath))
continue;
bp = GetBuildProvider (fileVirtualPath, bpcoll);
if (bp == null)
continue;
if (!AddBuildProvider (bp))
continue;
deps = bp.ExtractDependencies ();
if (deps == null)
continue;
string depDir, s;
dirs.Clear ();
foreach (var dep in deps) {
s = dep.Key;
depDir = VirtualPathUtility.GetDirectory (s); // dependencies are assumed to contain absolute paths
if (cache.ContainsKey (depDir))
continue;
cache.Add (depDir, true);
AddVirtualDir (GetVirtualDirectory (s), bpcoll, cache);
}
}
}
void AddVirtualFile (VirtualFile file, BuildProviderCollection bpcoll)
{
if (file == null || BuildManager.IgnoreVirtualPath (file.VirtualPath))
return;
BuildProvider bp = GetBuildProvider (file.VirtualPath, bpcoll);
if (bp == null)
return;
AddBuildProvider (bp);
}
List <BuildProviderGroup> GetSingleBuildProviderGroup (BuildProvider bp)
{
var ret = new List <BuildProviderGroup> ();
var group = new BuildProviderGroup ();
group.AddProvider (bp);
ret.Add (group);
return ret;
}
VirtualDirectory GetVirtualDirectory (string virtualPath)
{
if (!vpp.DirectoryExists (VirtualPathUtility.GetDirectory (virtualPath)))
return null;
return vpp.GetDirectory (virtualPath);
}
VirtualFile GetVirtualFile (string virtualPath)
{
if (!vpp.FileExists (virtualPath))
return null;
return vpp.GetFile (virtualPath);
}
Type GetBuildProviderCodeDomType (BuildProvider bp)
{
CompilerType ct = bp.CodeCompilerType;
if (ct == null) {
string language = bp.LanguageName;
if (String.IsNullOrEmpty (language))
language = CompilationSection.DefaultLanguage;
ct = BuildManager.GetDefaultCompilerTypeForLanguage (language, CompilationSection, false);
}
Type ret = ct != null ? ct.CodeDomProviderType : null;
if (ret == null)
throw new HttpException ("Unable to determine code compilation language provider for virtual path '" + bp.VirtualPath + "'.");
return ret;
}
void AssignToGroup (BuildProvider buildProvider, List <BuildProviderGroup> groups)
{
if (IsDependencyCycle (buildProvider))
throw new HttpException ("Dependency cycles are not suppported: " + buildProvider.VirtualPath);
BuildProviderGroup myGroup = null;
string bpVirtualPath = buildProvider.VirtualPath;
string bpPath = VirtualPathUtility.GetDirectory (bpVirtualPath);
bool canAdd;
if (BuildManager.HasCachedItemNoLock (buildProvider.VirtualPath))
return;
StringComparison stringComparison = RuntimeHelpers.StringComparison;
if (buildProvider is ApplicationFileBuildProvider || buildProvider is ThemeDirectoryBuildProvider) {
// global.asax and theme directory go into their own assemblies
myGroup = new BuildProviderGroup ();
myGroup.Standalone = true;
InsertGroup (myGroup, groups);
} else {
Type bpCodeDomType = GetBuildProviderCodeDomType (buildProvider);
foreach (BuildProviderGroup group in groups) {
if (group.Standalone)
continue;
if (group.Count == 0) {
myGroup = group;
break;
}
canAdd = true;
foreach (BuildProvider bp in group) {
if (IsDependency (buildProvider, bp)) {
canAdd = false;
break;
}
// There should be one assembly per virtual dir
if (String.Compare (bpPath, VirtualPathUtility.GetDirectory (bp.VirtualPath), stringComparison) != 0) {
canAdd = false;
break;
}
// Different languages go to different assemblies
if (bpCodeDomType != null) {
Type type = GetBuildProviderCodeDomType (bp);
if (type != null) {
if (type != bpCodeDomType) {
canAdd = false;
break;
}
}
}
}
if (!canAdd)
continue;
myGroup = group;
break;
}
if (myGroup == null) {
myGroup = new BuildProviderGroup ();
InsertGroup (myGroup, groups);
}
}
myGroup.AddProvider (buildProvider);
if (String.Compare (bpPath, virtualPathDirectory, stringComparison) == 0)
myGroup.Master = true;
}
void InsertGroup (BuildProviderGroup group, List <BuildProviderGroup> groups)
{
if (group.Application) {
groups.Insert (groups.Count - 1, group);
return;
}
int index;
if (group.Standalone)
index = groups.FindLastIndex (SkipApplicationGroup);
else
index = groups.FindLastIndex (SkipStandaloneGroups);
if (index == -1)
groups.Add (group);
else
groups.Insert (index == 0 ? 0 : index - 1, group);
}
static bool SkipStandaloneGroups (BuildProviderGroup group)
{
if (group == null)
return false;
return group.Standalone;
}
static bool SkipApplicationGroup (BuildProviderGroup group)
{
if (group == null)
return false;
return group.Application;
}
bool IsDependency (BuildProvider bp1, BuildProvider bp2)
{
IDictionary <string, bool> deps = bp1.ExtractDependencies ();
if (deps == null)
return false;
if (deps.ContainsKey (bp2.VirtualPath))
return true;
BuildProvider bp;
// It won't loop forever as by the time this method is called, we are sure there are no cycles
foreach (var dep in deps) {
if (!buildProviders.TryGetValue (dep.Key, out bp))
continue;
if (IsDependency (bp, bp2))
return true;
}
return false;
}
bool IsDependencyCycle (BuildProvider buildProvider)
{
var cache = new Dictionary <BuildProvider, bool> ();
cache.Add (buildProvider, true);
return IsDependencyCycle (cache, buildProvider.ExtractDependencies ());
}
bool IsDependencyCycle (Dictionary <BuildProvider, bool> cache, IDictionary <string, bool> deps)
{
if (deps == null)
return false;
BuildProvider bp;
foreach (var d in deps) {
if (!buildProviders.TryGetValue (d.Key, out bp))
continue;
if (cache.ContainsKey (bp))
return true;
cache.Add (bp, true);
if (IsDependencyCycle (cache, bp.ExtractDependencies ()))
return true;
cache.Remove (bp);
}
return false;
}
public static BuildProvider GetBuildProvider (string virtualPath, BuildProviderCollection coll)
{
return GetBuildProvider (new VirtualPath (virtualPath), coll);
}
public static BuildProvider GetBuildProvider (VirtualPath virtualPath, BuildProviderCollection coll)
{
if (virtualPath == null || String.IsNullOrEmpty (virtualPath.Original) || coll == null)
return null;
string extension = virtualPath.Extension;
BuildProvider bp = coll.GetProviderInstanceForExtension (extension);
if (bp == null) {
if (String.Compare (extension, ".asax", StringComparison.OrdinalIgnoreCase) == 0)
bp = new ApplicationFileBuildProvider ();
else if (StrUtils.StartsWith (virtualPath.AppRelative, "~/App_Themes/"))
bp = new ThemeDirectoryBuildProvider ();
if (bp != null)
bp.SetVirtualPath (virtualPath);
return bp;
}
object[] attrs = bp.GetType ().GetCustomAttributes (typeof (BuildProviderAppliesToAttribute), true);
if (attrs != null && attrs.Length != 0) {
BuildProviderAppliesTo appliesTo = ((BuildProviderAppliesToAttribute)attrs [0]).AppliesTo;
if ((appliesTo & BuildProviderAppliesTo.Web) == 0)
return null;
}
bp.SetVirtualPath (virtualPath);
return bp;
}
}
}

View File

@@ -0,0 +1,54 @@
//
// Authors:
// Marek Habersack <grendel@twistedcode.net>
//
// (C) 2011 Novell, Inc (http://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.
//
using System;
using System.Collections.Concurrent;
using System.Web;
using System.Web.Hosting;
namespace System.Web.Compilation
{
class BuildManagerHost : MarshalByRefObject, IRegisteredObject
{
// This method is used by the Cassini ASP.NET host application (and all of its
// derivatives, e.g. CassiniDev, see http://cassinidev.codeplex.com) to register the
// host assembly with System.Web's assembly resolver in order to enable loading
// types from assemblies not installed in GAC.
//
protected void RegisterAssembly (string assemblyName, string assemblyLocation)
{
if (String.IsNullOrEmpty (assemblyName) || String.IsNullOrEmpty (assemblyLocation))
return;
HttpRuntime.RegisteredAssemblies.InsertOrUpdate ((uint)assemblyName.GetHashCode (), assemblyName, assemblyLocation, assemblyLocation);
HttpRuntime.EnableAssemblyMapping (true);
}
public void Stop (bool immediate)
{}
}
}

Some files were not shown because too many files have changed in this diff Show More