Merge pull request #2781 from alexanderkyte/inflated_method_header_leak
[mono.git] / mcs / class / System.Web / System.Web.Compilation / AppCodeCompiler.cs
index 2e6b3155b87a5d516689afcfd794af4cacdb69e6..fef206848afe71ca028e375aeb3b6932decaa4de 100644 (file)
 // 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;
 using System.CodeDom.Compiler;
 using System.Configuration;
 using System.Collections;
 using System.Collections.Generic;
+using System.Collections.Specialized;
 using System.Globalization;
 using System.IO;
 using System.Reflection;
@@ -80,8 +81,9 @@ namespace System.Web.Compilation
                                if (asm == null)
                                        throw new HttpException (String.Format ("Unable to find assembly {0}", assemblyName), error);
 
-                               assemblyCache.Add (assemblyName, asm.Location);
-                               return asm.Location;
+                               string path = new Uri (asm.CodeBase).LocalPath;
+                               assemblyCache.Add (assemblyName, path);
+                               return path;
                        }
                }
        }
@@ -221,8 +223,15 @@ namespace System.Web.Compilation
                        CompilerParameters parameters = compilerInfo.CreateDefaultCompilerParameters ();
                        parameters.IncludeDebugInformation = compilationSection.Debug;
                        
-                       if (binAssemblies != null && binAssemblies.Length > 0)
-                               parameters.ReferencedAssemblies.AddRange (binAssemblies);
+                       if (binAssemblies != null && binAssemblies.Length > 0) {
+                               StringCollection parmRefAsm = parameters.ReferencedAssemblies;
+                               foreach (string binAsm in binAssemblies) {
+                                       if (parmRefAsm.Contains (binAsm))
+                                               continue;
+                                       
+                                       parmRefAsm.Add (binAsm);
+                               }
+                       }
                        
                        if (compilationSection != null) {
                                foreach (AssemblyInfo ai in compilationSection.Assemblies)
@@ -273,7 +282,7 @@ namespace System.Web.Compilation
                
                VirtualPath PhysicalToVirtual (string file)
                {
-                       return new VirtualPath (file.Replace (HttpRuntime.AppDomainAppPath, "/").Replace (Path.DirectorySeparatorChar, '/'));
+                       return new VirtualPath (file.Replace (HttpRuntime.AppDomainAppPath, "~/").Replace (Path.DirectorySeparatorChar, '/'));
                }
                
                BuildProvider GetBuildProviderFor (string file, BuildProviderCollection buildProviders)
@@ -281,7 +290,7 @@ namespace System.Web.Compilation
                        if (file == null || file.Length == 0 || buildProviders == null || buildProviders.Count == 0)
                                return null;
 
-                       BuildProvider ret = buildProviders.GetProviderForExtension (Path.GetExtension (file));
+                       BuildProvider ret = buildProviders.GetProviderInstanceForExtension (Path.GetExtension (file));
                        if (ret != null && IsCorrectBuilderType (ret)) {
                                ret.SetVirtualPath (PhysicalToVirtual (file));
                                return ret;
@@ -614,7 +623,11 @@ namespace System.Web.Compilation
                {
                        if (ps == null || !ps.Enabled)
                                return false;
-                       if (!String.IsNullOrEmpty (ps.Inherits) || (ps.PropertySettings != null && ps.PropertySettings.Count > 0))
+
+                       RootProfilePropertySettingsCollection props = ps.PropertySettings;
+                       ProfileGroupSettingsCollection groups = props != null ? props.GroupSettings : null;
+                       
+                       if (!String.IsNullOrEmpty (ps.Inherits) || (props != null && props.Count > 0) || (groups != null && groups.Count > 0))
                                return true;
 
                        return false;
@@ -742,4 +755,4 @@ namespace System.Web.Compilation
                }
        }
 }
-#endif
+