<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>src/Spark.Web.Mvc.Tests/AspNetMvc.Tests.Views/Failure/Show.spark</filename>
    </added>
    <added>
      <filename>src/Spark.Web.Mvc.Tests/AspNetMvc.Tests.Views/Failure/_Failure.spark</filename>
    </added>
    <added>
      <filename>src/Spark.Web.Mvc.Tests/Controllers/FailureController.cs</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -71,6 +71,7 @@
   &lt;/ItemGroup&gt;
   &lt;ItemGroup&gt;
     &lt;Compile Include=&quot;Controllers\ComplexPrecompileController.cs&quot; /&gt;
+    &lt;Compile Include=&quot;Controllers\FailureController.cs&quot; /&gt;
     &lt;Compile Include=&quot;Controllers\SimplePrecompileController.cs&quot; /&gt;
     &lt;Compile Include=&quot;Controllers\StubController.cs&quot; /&gt;
     &lt;Compile Include=&quot;DescriptorBuildingTester.cs&quot; /&gt;
@@ -101,6 +102,12 @@
     &lt;None Include=&quot;AspNetMvc.Tests.Views\Admin\Layouts\speciallayout.spark&quot;&gt;
       &lt;CopyToOutputDirectory&gt;Always&lt;/CopyToOutputDirectory&gt;
     &lt;/None&gt;
+    &lt;None Include=&quot;AspNetMvc.Tests.Views\Failure\Show.spark&quot;&gt;
+      &lt;CopyToOutputDirectory&gt;Always&lt;/CopyToOutputDirectory&gt;
+    &lt;/None&gt;
+    &lt;None Include=&quot;AspNetMvc.Tests.Views\Failure\_Failure.spark&quot;&gt;
+      &lt;CopyToOutputDirectory&gt;Always&lt;/CopyToOutputDirectory&gt;
+    &lt;/None&gt;
     &lt;None Include=&quot;AspNetMvc.Tests.Views\Home\childview.spark&quot;&gt;
       &lt;CopyToOutputDirectory&gt;Always&lt;/CopyToOutputDirectory&gt;
     &lt;/None&gt;</diff>
      <filename>src/Spark.Web.Mvc.Tests/Spark.Web.Mvc.Tests.csproj</filename>
    </modified>
    <modified>
      <diff>@@ -12,7 +12,11 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 // 
+using System;
+using System.IO;
 using System.Linq;
+using System.Linq.Expressions;
+using System.Reflection;
 using NUnit.Framework;
 using Spark.FileSystem;
 using Spark.Web.Mvc.Tests.Controllers;
@@ -52,6 +56,45 @@ namespace Spark.Web.Mvc.Tests
             Assert.AreEqual(3, assembly.GetTypes().Length);
         }
 
+        [Test]
+        public void CanHandleCSharpV3SyntaxWhenLoadedInAppDomainWithoutConfig()
+        {
+            AppDomainSetup setup = new AppDomainSetup
+                                    {
+                                        ApplicationBase = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
+                                    };
+            AppDomain sandbox = null;
+            try
+            {
+                sandbox = AppDomain.CreateDomain(&quot;sandbox&quot;, null, setup);
+                var remoteRunner = (PrecompileRunner) sandbox.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().FullName,
+                                                             typeof(PrecompileRunner).FullName);
+                remoteRunner.Precompile();
+            }
+            finally
+            {
+                if (sandbox != null)
+                {
+                    AppDomain.Unload(sandbox);
+                }
+            }
+        }
+
+        public class PrecompileRunner : MarshalByRefObject
+        {
+            public void Precompile()
+            {
+                var settings = new SparkSettings();
+
+                var factory = new SparkViewFactory(settings) { ViewFolder = new FileSystemViewFolder(&quot;AspNetMvc.Tests.Views&quot;) };
+
+                var batch = new SparkBatchDescriptor();
+
+                batch.For&lt;FailureController&gt;();
+
+                factory.Precompile(batch);
+            }
+        }
 
         [Test]
         public void DefaultMatchingRules()
@@ -146,4 +189,12 @@ namespace Spark.Web.Mvc.Tests
         }
 
     }
+
+    public static class FooExtensions
+    {
+        public static string FooFor&lt;T&gt;(this SparkView view, Expression&lt;Action&lt;T&gt;&gt; action)
+        {
+            return string.Format(&quot;Foo on lambda expression {0}&quot;, action);
+        }
+    }
 }
\ No newline at end of file</diff>
      <filename>src/Spark.Web.Mvc.Tests/SparkBatchCompilerTester.cs</filename>
    </modified>
    <modified>
      <diff>@@ -15,8 +15,8 @@
 using System;
 using System.CodeDom.Compiler;
 using System.Collections.Generic;
+using System.Configuration;
 using System.IO;
-using System.Linq;
 using System.Reflection;
 using System.Reflection.Emit;
 using System.Text;
@@ -30,19 +30,44 @@ namespace Spark.Compiler
 
         public Assembly Compile(bool debug, string languageOrExtension, params string[] sourceCode)
         {
-            var all = CodeDomProvider.GetAllCompilerInfo();
-
             var language = languageOrExtension;
             if (CodeDomProvider.IsDefinedLanguage(languageOrExtension) == false &amp;&amp;
                 CodeDomProvider.IsDefinedExtension(languageOrExtension))
             {
                 language = CodeDomProvider.GetLanguageFromExtension(languageOrExtension);
             }
-            var compilerInfo = CodeDomProvider.GetCompilerInfo(language);
-            var codeProvider = CodeDomProvider.CreateProvider(language);
+
+        	CodeDomProvider codeProvider;
+            CompilerParameters compilerParameters;
+            
+            if (ConfigurationManager.GetSection(&quot;system.codedom&quot;) != null)
+            {
+                var compilerInfo = CodeDomProvider.GetCompilerInfo(language);
+                codeProvider = compilerInfo.CreateProvider();
+                compilerParameters = compilerInfo.CreateDefaultCompilerParameters();
+            }
+            else
+            {
+                if (!language.Equals(&quot;c#&quot;, StringComparison.OrdinalIgnoreCase) &amp;&amp; 
+                    !language.Equals(&quot;cs&quot;, StringComparison.OrdinalIgnoreCase) &amp;&amp; 
+                    !language.Equals(&quot;csharp&quot;, StringComparison.OrdinalIgnoreCase))
+                {
+                    throw new CompilerException(
+                        string.Format(&quot;When running the {0} in an AppDomain without a system.codedom config section only the csharp language is supported. This happens if you are precompiling your views.&quot;, 
+                            typeof(BatchCompiler).FullName));
+                }
+
+                var providerOptions = new Dictionary&lt;string, string&gt; { { &quot;CompilerVersion&quot;, &quot;v3.5&quot; } };
+                codeProvider = new CSharpCodeProvider(providerOptions);
+                compilerParameters = new CompilerParameters();
+
+				// Note: Could make a map of compiler info objects (to support vb) and rewrite the following uncommented code.
+                //compilerParameters = new CompilerParameters { WarningLevel = 4 };
+                //var compilerInfo = GetCompilerInfoWithoutReadingConfig(compilerParameters);
+                //codeProvider = CreateProviderForCSharpV3(compilerInfo);
+            }
 
             var extension = codeProvider.FileExtension;
-            var compilerParameters = compilerInfo.CreateDefaultCompilerParameters();
 
             foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
             {
@@ -142,5 +167,52 @@ namespace Spark.Compiler
 
             return compilerResults.CompiledAssembly;
         }
+
+        //private static CodeDomProvider CreateProviderForCSharpV3(CompilerInfo compilerInfo)
+        //{
+        //    CodeDomProvider codeProvider;
+        //    var providerOptions = new Dictionary&lt;string, string&gt; { { &quot;CompilerVersion&quot;, &quot;v3.5&quot; } };
+        //    codeProvider = compilerInfo.CreateProvider(providerOptions);
+        //    return codeProvider;
+        //}
+
+        //private static CompilerInfo GetCompilerInfoWithoutReadingConfig(CompilerParameters compilerParameters)
+        //{
+        //    var codeDomProviderTypeName = typeof(CSharpCodeProvider).AssemblyQualifiedName;
+        //    var compilerLanguages = new[] { &quot;c#&quot;, &quot;cs&quot;, &quot;csharp&quot; };
+        //    var compilerExtensions = new[] { &quot;.cs&quot; };
+        //    var compilerInfo = CompilerInfoExtensions.CreateCompilerInfo(compilerParameters, codeDomProviderTypeName, compilerLanguages, compilerExtensions);
+        //    return compilerInfo;
+        //}
     }
+
+    //public static class CompilerInfoExtensions
+    //{
+    //    public static CompilerInfo CreateCompilerInfo(CompilerParameters compilerParams, string codeDomProviderTypeName, 
+    //        string[] compilerLanguages, string[] compilerExtensions)
+    //    {
+    //        var constructor = typeof (CompilerInfo).GetConstructor(
+    //            BindingFlags.NonPublic, null, new[] { typeof (CompilerParameters), typeof (string), typeof (string[]), typeof (string[]) }, null);
+            
+    //        if (constructor == null)
+    //        {
+    //            return null;
+    //        }
+
+    //        return (CompilerInfo) constructor.Invoke(new object[] {compilerParams, codeDomProviderTypeName, compilerLanguages, compilerExtensions});
+    //    }
+
+    //    public static CodeDomProvider CreateProvider(this CompilerInfo compilerInfo, IDictionary&lt;string, string&gt; providerOptions)
+    //    {
+    //        if (providerOptions.Count &gt; 0)
+    //        {
+    //            ConstructorInfo constructor = compilerInfo.CodeDomProviderType.GetConstructor(new [] { typeof(IDictionary&lt;string, string&gt;) });
+    //            if (constructor != null)
+    //            {
+    //                return (CodeDomProvider)constructor.Invoke(new object[] { providerOptions });
+    //            }
+    //        }
+    //        return (CodeDomProvider)Activator.CreateInstance(compilerInfo.CodeDomProviderType);
+    //    }
+    //}
 }</diff>
      <filename>src/Spark/Compiler/BatchCompiler.cs</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>55eea63579579958a699b746e0870a2ae1fcceab</id>
    </parent>
  </parents>
  <author>
    <name>maxild</name>
    <email>mmaxild@gmail.com</email>
  </author>
  <url>http://github.com/loudej/spark/commit/dd45553925d8ee832e27e84582e120bed8777657</url>
  <id>dd45553925d8ee832e27e84582e120bed8777657</id>
  <committed-date>2009-11-07T02:20:00-08:00</committed-date>
  <authored-date>2009-11-06T05:58:38-08:00</authored-date>
  <message>Fixed issue with the BatchCompiler running without system.codedom config which is the case when precompiling views.</message>
  <tree>7695cb7a3d78c23d735ac8508b6dcce08f377e33</tree>
  <committer>
    <name>Louis DeJardin</name>
    <email>louis.dejardin@gmail.com</email>
  </committer>
</commit>
