internal string[] GetTopLevelAssemblyReferences(VirtualPath virtualPath) { this.AddPendingCall(); List<Assembly> fromList = new List<Assembly>(); try { virtualPath.CombineWithAppRoot(); foreach (AssemblyInfo info in MTConfigUtil.GetCompilationConfig(virtualPath).Assemblies) { Assembly[] assemblyInternal = info.AssemblyInternal; for (int i = 0; i < assemblyInternal.Length; i++) { if (assemblyInternal[i] != null) { fromList.Add(assemblyInternal[i]); } } } } finally { this.RemovePendingCall(); } StringCollection toList = new StringCollection(); Util.AddAssembliesToStringCollection(fromList, toList); string[] array = new string[toList.Count]; toList.CopyTo(array, 0); return array; }
internal string[] GetCompiledTypeAndAssemblyName(VirtualPath virtualPath, ClientBuildManagerCallback callback) { string[] strArray; this.AddPendingCall(); try { virtualPath.CombineWithAppRoot(); Type compiledType = BuildManager.GetCompiledType(virtualPath, callback); if (compiledType == null) { return null; } string assemblyPathFromType = Util.GetAssemblyPathFromType(compiledType); strArray = new string[] { compiledType.FullName, assemblyPathFromType }; } finally { this.RemovePendingCall(); } return strArray; }
private System.Web.Compilation.BuildProvider GetCompilerParamsAndBuildProvider(VirtualPath virtualPath, out Type codeDomProviderType, out CompilerParameters compilerParameters) { virtualPath.CombineWithAppRoot(); CompilationSection compilationConfig = MTConfigUtil.GetCompilationConfig(virtualPath); ICollection referencedAssemblies = BuildManager.GetReferencedAssemblies(compilationConfig); System.Web.Compilation.BuildProvider provider = null; if (StringUtil.EqualsIgnoreCase(virtualPath.VirtualPathString, BuildManager.GlobalAsaxVirtualPath.VirtualPathString)) { ApplicationBuildProvider provider2 = new ApplicationBuildProvider(); provider2.SetVirtualPath(virtualPath); provider2.SetReferencedAssemblies(referencedAssemblies); provider = provider2; } else { provider = BuildManager.CreateBuildProvider(virtualPath, compilationConfig, referencedAssemblies, true); } provider.IgnoreParseErrors = true; provider.IgnoreControlProperties = true; provider.ThrowOnFirstParseError = false; CompilerType codeCompilerType = provider.CodeCompilerType; if (codeCompilerType == null) { codeDomProviderType = null; compilerParameters = null; return null; } codeDomProviderType = codeCompilerType.CodeDomProviderType; compilerParameters = codeCompilerType.CompilerParameters; IAssemblyDependencyParser assemblyDependencyParser = provider.AssemblyDependencyParser; if ((assemblyDependencyParser != null) && (assemblyDependencyParser.AssemblyDependencies != null)) { Util.AddAssembliesToStringCollection(assemblyDependencyParser.AssemblyDependencies, compilerParameters.ReferencedAssemblies); } AssemblyBuilder.FixUpCompilerParameters(codeDomProviderType, compilerParameters); return provider; }
internal void GetCodeDirectoryInformation(VirtualPath virtualCodeDir, out Type codeDomProviderType, out CompilerParameters compParams, out string generatedFilesDir) { this.AddPendingCall(); try { BuildManager.SkipTopLevelCompilationExceptions = true; this._buildManager.EnsureTopLevelFilesCompiled(); virtualCodeDir = virtualCodeDir.CombineWithAppRoot(); this._buildManager.GetCodeDirectoryInformation(virtualCodeDir, out codeDomProviderType, out compParams, out generatedFilesDir); } finally { BuildManager.SkipTopLevelCompilationExceptions = false; this.RemovePendingCall(); } }
private BuildProvider GetCompilerParamsAndBuildProvider(VirtualPath virtualPath, out Type codeDomProviderType, out CompilerParameters compilerParameters) { virtualPath.CombineWithAppRoot(); CompilationSection compConfig = MTConfigUtil.GetCompilationConfig(virtualPath); ICollection referencedAssemblies = BuildManager.GetReferencedAssemblies(compConfig); // Create the buildprovider for the passed in virtualPath BuildProvider buildProvider = null; // Special case global asax build provider here since we do not want to compile every files with ".asax" extension. if (StringUtil.EqualsIgnoreCase(virtualPath.VirtualPathString, BuildManager.GlobalAsaxVirtualPath.VirtualPathString)) { ApplicationBuildProvider provider = new ApplicationBuildProvider(); provider.SetVirtualPath(virtualPath); provider.SetReferencedAssemblies(referencedAssemblies); buildProvider = provider; } else { buildProvider = BuildManager.CreateBuildProvider(virtualPath, compConfig, referencedAssemblies, true /*failIfUnknown*/); } // DevDiv 69017 // The methods restricted to internalBuildProvider have been moved up to BuildProvider // to allow WCFBuildProvider to support .svc syntax highlighting. // Ignore parse errors, since they should not break the designer buildProvider.IgnoreParseErrors = true; // Ignore all control properties, since we do not generate code for the properties buildProvider.IgnoreControlProperties = true; // Process as many errors as possible, do not rethrow on first error buildProvider.ThrowOnFirstParseError = false; // Get the language (causes the file to be parsed) CompilerType compilerType = buildProvider.CodeCompilerType; // compilerType could be null in the no-compile case (VSWhidbey 221749) if (compilerType == null) { codeDomProviderType = null; compilerParameters = null; return null; } // Return the provider type and compiler params codeDomProviderType = compilerType.CodeDomProviderType; compilerParameters = compilerType.CompilerParameters; IAssemblyDependencyParser parser = buildProvider.AssemblyDependencyParser; // Add all the assemblies that the page depends on (e.g. user controls) if (parser != null && parser.AssemblyDependencies != null) { Util.AddAssembliesToStringCollection(parser.AssemblyDependencies, compilerParameters.ReferencedAssemblies); } // Make any fix up adjustments to the CompilerParameters to work around some issues AssemblyBuilder.FixUpCompilerParameters(compConfig, codeDomProviderType, compilerParameters); return buildProvider; }
/* * Returns an array of the assemblies defined in the bin and assembly reference config section */ internal String[] GetTopLevelAssemblyReferences(VirtualPath virtualPath) { // Add a pending call to make sure our thread doesn't get killed AddPendingCall(); List<Assembly> assemblyList = new List<Assembly>(); try { // Treat it as relative to the app root virtualPath.CombineWithAppRoot(); CompilationSection compConfig = MTConfigUtil.GetCompilationConfig(virtualPath); // Add all the config assemblies to the list foreach (AssemblyInfo assemblyInfo in compConfig.Assemblies) { Assembly[] assemblies = assemblyInfo.AssemblyInternal; for (int i = 0; i < assemblies.Length; i++) { if (assemblies[i] != null) { assemblyList.Add(assemblies[i]); } } } } finally { RemovePendingCall(); } StringCollection paths = new StringCollection(); Util.AddAssembliesToStringCollection(assemblyList, paths); string[] references = new string[paths.Count]; paths.CopyTo(references, 0); return references; }
internal string[] GetCompiledTypeAndAssemblyName(VirtualPath virtualPath, ClientBuildManagerCallback callback) { // Add a pending call to make sure our thread doesn't get killed AddPendingCall(); try { // Treat it as relative to the app root virtualPath.CombineWithAppRoot(); Type t = BuildManager.GetCompiledType(virtualPath, callback); if (t == null) return null; string assemblyPath = Util.GetAssemblyPathFromType(t); return new string[] { t.FullName, assemblyPath }; } finally { RemovePendingCall(); } }
internal void GetCodeDirectoryInformation(VirtualPath virtualCodeDir, out Type codeDomProviderType, out CompilerParameters compParams, out string generatedFilesDir) { // Add a pending call to make sure our thread doesn't get killed AddPendingCall(); try { BuildManager.SkipTopLevelCompilationExceptions = true; _buildManager.EnsureTopLevelFilesCompiled(); // Treat it as relative to the app root virtualCodeDir = virtualCodeDir.CombineWithAppRoot(); _buildManager.GetCodeDirectoryInformation(virtualCodeDir, out codeDomProviderType, out compParams, out generatedFilesDir); } finally { BuildManager.SkipTopLevelCompilationExceptions = false; RemovePendingCall(); } }