//
// (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.CodeDom.Compiler;
using System.Collections;
bool debug;
string compilerOptions;
string language;
+ bool strictOn = false;
+ bool explicitOn = false;
bool output_cache;
int oc_duration;
string oc_header, oc_custom, oc_param, oc_controls;
bool oc_shared;
OutputCacheLocation oc_location;
Assembly srcAssembly;
+ int appAssemblyIndex = -1;
internal TemplateParser ()
{
internal void AddApplicationAssembly ()
{
string location = Context.ApplicationInstance.AssemblyLocation;
- if (location != typeof (TemplateParser).Assembly.Location)
- assemblies.Add (location);
+ if (location != typeof (TemplateParser).Assembly.Location) {
+ appAssemblyIndex = assemblies.Add (location);
+ }
}
protected abstract Type CompileIntoType ();
internal Type LoadType (string typeName)
{
// First try loaded assemblies, then try assemblies in Bin directory.
- // By now i do this 'by hand' but may be this is a runtime/gac task.
Type type = null;
+ bool seenBin = false;
Assembly [] assemblies = AppDomain.CurrentDomain.GetAssemblies ();
foreach (Assembly ass in assemblies) {
type = ass.GetType (typeName);
- if (type != null) {
- AddAssembly (ass, (Path.GetDirectoryName (ass.Location) == PrivateBinPath));
- AddDependency (ass.Location);
- return type;
+ if (type == null)
+ continue;
+
+ if (Path.GetDirectoryName (ass.Location) != PrivateBinPath) {
+ AddAssembly (ass, false);
+ } else {
+ seenBin = true;
}
+
+ AddDependency (ass.Location);
+ return type;
}
- return null;
- }
+ if (seenBin)
+ return null;
- void AddAssembliesInBin ()
- {
+ // Load from bin
if (!Directory.Exists (PrivateBinPath))
- return;
+ return null;
string [] binDlls = Directory.GetFiles (PrivateBinPath, "*.dll");
- foreach (string dll in binDlls) {
- Assembly assembly = Assembly.LoadFrom (dll);
- AddAssembly (assembly, true);
+ foreach (string s in binDlls) {
+ Assembly binA = Assembly.LoadFrom (s);
+ type = binA.GetType (typeName);
+ if (type == null)
+ continue;
+
+ AddDependency (binA.Location);
+ return type;
}
+
+ return null;
}
- Assembly LoadAssemblyFromBin (string name)
+ void AddAssembliesInBin ()
{
- Assembly assembly;
if (!Directory.Exists (PrivateBinPath))
- return null;
+ return;
string [] binDlls = Directory.GetFiles (PrivateBinPath, "*.dll");
- foreach (string dll in binDlls) {
- string fn = Path.GetFileName (dll);
- fn = Path.ChangeExtension (fn, null);
- if (fn != name)
- continue;
-
- assembly = Assembly.LoadFrom (dll);
- return assembly;
+ foreach (string s in binDlls) {
+ assemblies.Add (s);
}
-
- return null;
}
internal virtual void AddInterface (string iface)
return (Assembly) o;
}
- bool fullpath = true;
- Assembly assembly = LoadAssemblyFromBin (name);
- if (assembly != null) {
- AddAssembly (assembly, fullpath);
- return assembly;
- }
-
+ bool fullpath = false;
+ Assembly assembly = null;
try {
assembly = Assembly.Load (name);
string loc = assembly.Location;
atts.Remove ("AspCompat"); // ignored
debug = GetBool (atts, "Debug", true);
- compilerOptions = GetString (atts, "CompilerOptions", null);
+ compilerOptions = GetString (atts, "CompilerOptions", "");
language = GetString (atts, "Language", CompilationConfig.DefaultLanguage);
+ strictOn = GetBool (atts, "Strict", CompilationConfig.Strict);
+ explicitOn = GetBool (atts, "Explicit", CompilationConfig.Explicit);
string src = GetString (atts, "Src", null);
if (src != null)
srcAssembly = GetAssemblyFromSource (src);
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);
throw new CompilationException (realPath, result.Errors, reader.ReadToEnd ());
}
}
internal ArrayList Assemblies {
- get { return assemblies; }
+ get {
+ if (appAssemblyIndex != -1) {
+ object o = assemblies [appAssemblyIndex];
+ assemblies.RemoveAt (appAssemblyIndex);
+ assemblies.Add (o);
+ appAssemblyIndex = -1;
+ }
+
+ return assemblies;
+ }
}
internal ArrayList Interfaces {
get { return language; }
}
+ internal bool StrictOn {
+ get { return strictOn; }
+ }
+
+ internal bool ExplicitOn {
+ get { return explicitOn; }
+ }
+
internal bool Debug {
get { return debug; }
}
internal PagesConfiguration PagesConfig {
get { return PagesConfiguration.GetInstance (Context); }
}
-
}
}