From b67664f55b9b414fe3f31a33f9fd94ab62f43ba9 Mon Sep 17 00:00:00 2001 From: Andre Rodrigues Date: Thu, 18 Nov 2010 13:18:42 -0800 Subject: [PATCH] Medium Trust: Removing dead code that is generating secannotate warnings. --HG-- branch : dev --- .../CSharpExtensionDirectoryCompiler.cs | 56 ------------------- .../CSharpProjectFullTrustCompiler.cs | 54 ------------------ src/Orchard/Orchard.Framework.csproj | 2 - 3 files changed, 112 deletions(-) delete mode 100644 src/Orchard/Environment/Extensions/Compilers/CSharpExtensionDirectoryCompiler.cs delete mode 100644 src/Orchard/Environment/Extensions/Compilers/CSharpProjectFullTrustCompiler.cs diff --git a/src/Orchard/Environment/Extensions/Compilers/CSharpExtensionDirectoryCompiler.cs b/src/Orchard/Environment/Extensions/Compilers/CSharpExtensionDirectoryCompiler.cs deleted file mode 100644 index d90f55bf9..000000000 --- a/src/Orchard/Environment/Extensions/Compilers/CSharpExtensionDirectoryCompiler.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.CodeDom.Compiler; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Security; -using System.Web.Compilation; - -namespace Orchard.Environment.Extensions.Compilers { - /// - /// Compile a C# extension into an assembly given a directory location - /// Note: Currently not used... - /// - public class CSharpExtensionDirectoryCompiler { - private readonly IBuildManager _buildManager; - - public CSharpExtensionDirectoryCompiler(IBuildManager buildManager) { - _buildManager = buildManager; - } - - public CompilerResults CompileProject(string location) { - var codeProvider = CodeDomProvider.CreateProvider("cs"); - - var references = GetAssemblyReferenceNames(); - var options = new CompilerParameters(references.ToArray()); - - var fileNames = GetSourceFileNames(location); - var results = codeProvider.CompileAssemblyFromFile(options, fileNames.ToArray()); - return results; - } - - private IEnumerable GetAssemblyReferenceNames() { - return _buildManager - .GetReferencedAssemblies() - .Select(x => x.Location) - .Where(x => !string.IsNullOrEmpty(x)) - .Distinct(StringComparer.OrdinalIgnoreCase); - } - - private IEnumerable GetSourceFileNames(string path) { - foreach (var file in Directory.GetFiles(path, "*.cs")) { - yield return file; - } - - foreach (var folder in Directory.GetDirectories(path)) { - if (Path.GetFileName(folder).StartsWith(".")) - continue; - - foreach (var file in GetSourceFileNames(folder)) { - yield return file; - } - } - } - } -} \ No newline at end of file diff --git a/src/Orchard/Environment/Extensions/Compilers/CSharpProjectFullTrustCompiler.cs b/src/Orchard/Environment/Extensions/Compilers/CSharpProjectFullTrustCompiler.cs deleted file mode 100644 index 936a22fef..000000000 --- a/src/Orchard/Environment/Extensions/Compilers/CSharpProjectFullTrustCompiler.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System.CodeDom.Compiler; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Security; -using Orchard.FileSystems.VirtualPath; - -namespace Orchard.Environment.Extensions.Compilers { - /// - /// Compile a C# extension into an assembly given a directory location - /// Note: currently not used... - /// - public class CSharpProjectFullTrustCompiler { - private readonly IVirtualPathProvider _virtualPathProvider; - private readonly IBuildManager _buildManager; - - public CSharpProjectFullTrustCompiler(IVirtualPathProvider virtualPathProvider, IBuildManager buildManager) { - _virtualPathProvider = virtualPathProvider; - _buildManager = buildManager; - } - - /// - /// Compile a csproj file given its virtual path. Use the CSharp CodeDomProvider - /// class, which is only available in full trust. - /// - public CompilerResults CompileProject(string virtualPath, string outputDirectory) { - var codeProvider = CodeDomProvider.CreateProvider("cs"); - var directory = _virtualPathProvider.GetDirectoryName(virtualPath); - - using (var stream = _virtualPathProvider.OpenFile(virtualPath)) { - var descriptor = new DefaultProjectFileParser().Parse(stream); - - var references = GetReferencedAssembliesLocation(); - var options = new CompilerParameters(references.ToArray()); - options.GenerateExecutable = false; - options.OutputAssembly = Path.Combine(outputDirectory, descriptor.AssemblyName + ".dll"); - - var fileNames = descriptor.SourceFilenames - .Select(f => _virtualPathProvider.Combine(directory, f)) - .Select(f => _virtualPathProvider.MapPath(f)); - - var results = codeProvider.CompileAssemblyFromFile(options, fileNames.ToArray()); - return results; - } - } - - private IEnumerable GetReferencedAssembliesLocation() { - return _buildManager.GetReferencedAssemblies() - .Select(a => a.Location) - .Where(a => !string.IsNullOrEmpty(a)) - .Distinct(); - } - } -} \ No newline at end of file diff --git a/src/Orchard/Orchard.Framework.csproj b/src/Orchard/Orchard.Framework.csproj index 06ecea4d6..69d504080 100644 --- a/src/Orchard/Orchard.Framework.csproj +++ b/src/Orchard/Orchard.Framework.csproj @@ -555,9 +555,7 @@ - -