private void AddCodeForGetProfileForUser(CodeTypeDeclaration type) { CodeMemberMethod method = new CodeMemberMethod(); method.Name = "GetProfile"; method.Attributes = MemberAttributes.Public; method.ReturnType = new CodeTypeReference(/*BaseCodeDomTreeGenerator.defaultNamespace + "." + */ ProfileTypeName); method.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "username")); CodeMethodInvokeExpression cmie = new CodeMethodInvokeExpression(); cmie.Method.TargetObject = new CodeTypeReferenceExpression("ProfileBase"); cmie.Method.MethodName = "Create"; cmie.Parameters.Add(new CodeArgumentReferenceExpression("username")); CodeMethodReturnStatement returnSatement = new CodeMethodReturnStatement(new CodeCastExpression(method.ReturnType, cmie)); ProfileSection config = MTConfigUtil.GetProfileAppConfig(); //if (config != null) //{ // PropertyInformation prop = config.ElementInformation.Properties["inherits"]; // if (prop != null && prop.Source != null && prop.LineNumber > 0) // returnSatement.LinePragma = new CodeLinePragma(HttpRuntime.GetSafePath(prop.Source), prop.LineNumber); //} method.Statements.Add(returnSatement); type.Members.Add(method); }
// Add the referenced assemblies into the compileParameters. Notice that buildProviders do not have // the correct referenced assemblies and we don't cache them since the assemblies could change // between appdomains. (removing assemblies from bin, etc) private void FixupReferencedAssemblies(VirtualPath virtualPath, CompilerParameters compilerParameters) { CompilationSection compConfig = MTConfigUtil.GetCompilationConfig(virtualPath); ICollection referencedAssemblies = BuildManager.GetReferencedAssemblies(compConfig); Util.AddAssembliesToStringCollection(referencedAssemblies, compilerParameters.ReferencedAssemblies); }
////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// // Private stuff private static void InitializeEnabled(bool initProviders) { if (!s_Initialized || !s_InitializedProviders || !s_InitializeDefaultProvider) { lock (s_Lock) { if (!s_Initialized || !s_InitializedProviders || !s_InitializeDefaultProvider) { try { ProfileSection config = MTConfigUtil.GetProfileAppConfig(); if (!s_InitializedEnabled) { s_Enabled = config.Enabled && HttpRuntime.HasAspNetHostingPermission(AspNetHostingPermissionLevel.Low); s_AutomaticSaveEnabled = s_Enabled && config.AutomaticSaveEnabled; s_InitializedEnabled = true; } if (initProviders && s_Enabled && (!s_InitializedProviders || !s_InitializeDefaultProvider)) { InitProviders(config); } } catch (Exception e) { s_InitException = e; } s_Initialized = true; } } } }
/* * Return a CompilerType that a language maps to. */ internal static CompilerType GetCompilerInfoFromLanguage(VirtualPath configPath, string language) { // Get the <compilation> config object CompilationSection config = MTConfigUtil.GetCompilationConfig(configPath); return(config.GetCompilerInfoFromLanguage(language)); }
/* * Return a CompilerType that a extension maps to. */ private static CompilerType GetCompilerInfoFromExtension(VirtualPath configPath, string extension) { // Get the <compilation> config object CompilationSection config = MTConfigUtil.GetCompilationConfig(configPath); return(config.GetCompilerInfoFromExtension(extension, true /*throwOnFail*/)); }
internal WebDirectoryBatchCompiler(VirtualDirectory vdir) { this._vdir = vdir; this._utcStart = DateTime.UtcNow; this._compConfig = MTConfigUtil.GetCompilationConfig(this._vdir.VirtualPath); this._referencedAssemblies = BuildManager.GetReferencedAssemblies(this._compConfig); }
/* * 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); }
public static string ParsePropertyDeviceFilter(string input, out string propName) { string str = string.Empty; if (input.IndexOf(':') < 0) { propName = input; return(str); } if (StringUtil.StringStartsWithIgnoreCase(input, "xmlns:")) { propName = input; return(str); } string[] strArray = input.Split(new char[] { ':' }); if (strArray.Length > 2) { throw new HttpException(System.Web.SR.GetString("Too_many_filters", new object[] { input })); } if (MTConfigUtil.GetPagesConfig().IgnoreDeviceFilters[strArray[0]] != null) { propName = input; return(str); } str = strArray[0]; propName = strArray[1]; return(str); }
protected override void ComputeHashCode(HashCodeCombiner hashCodeCombiner) { base.ComputeHashCode(hashCodeCombiner); CompilationSection compilationConfig = MTConfigUtil.GetCompilationConfig(base.VirtualPath); hashCodeCombiner.AddObject(compilationConfig.RecompilationHash); }
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 static Hashtable GetPropertiesForCompilation() { if (!ProfileManager.Enabled) { return(null); } if (s_PropertiesForCompilation != null) { return(s_PropertiesForCompilation); } lock (s_InitializeLock) { if (s_PropertiesForCompilation != null) { return(s_PropertiesForCompilation); } Hashtable ht = new Hashtable(); ProfileSection config = MTConfigUtil.GetProfileAppConfig(); if (config.PropertySettings == null) { s_PropertiesForCompilation = ht; return(s_PropertiesForCompilation); } AddProfilePropertySettingsForCompilation(config.PropertySettings, ht, null); foreach (ProfileGroupSettings pgs in config.PropertySettings.GroupSettings) { AddProfilePropertySettingsForCompilation(pgs.PropertySettings, ht, pgs.Name); } AddProfilePropertySettingsForCompilation(ProfileManager.DynamicProfileProperties, ht, null); s_PropertiesForCompilation = ht; } return(s_PropertiesForCompilation); }
protected override void ComputeHashCode(HashCodeCombiner hashCodeCombiner) { base.ComputeHashCode(hashCodeCombiner); PagesSection pagesConfig = MTConfigUtil.GetPagesConfig(base.VirtualPath); hashCodeCombiner.AddObject(Util.GetRecompilationHash(pagesConfig)); }
internal BuildProvidersCompiler(VirtualPath configPath, bool supportLocalization, string generatedFilesDir, int index) { this._configPath = configPath; this._supportLocalization = supportLocalization; this._compConfig = MTConfigUtil.GetCompilationConfig(this._configPath); this._referencedAssemblies = BuildManager.GetReferencedAssemblies(this.CompConfig, index); this._generatedFilesDir = generatedFilesDir; }
/* * Return a file provider Type that an extension maps to. */ internal static Type GetBuildProviderTypeFromExtension(VirtualPath configPath, string extension, BuildProviderAppliesTo neededFor, bool failIfUnknown) { // Get the <compilation> config object CompilationSection config = MTConfigUtil.GetCompilationConfig(configPath); return(GetBuildProviderTypeFromExtension(config, extension, neededFor, failIfUnknown)); }
internal BuildProvidersCompiler(VirtualPath configPath, bool supportLocalization, string outputAssemblyName) { this._configPath = configPath; this._supportLocalization = supportLocalization; this._compConfig = MTConfigUtil.GetCompilationConfig(this._configPath); this._referencedAssemblies = BuildManager.GetReferencedAssemblies(this.CompConfig); this._outputAssemblyName = outputAssemblyName; }
internal static CodeSubDirectoriesCollection GetCodeSubDirectories() { CodeSubDirectoriesCollection codeSubDirectories = MTConfigUtil.GetCompilationAppConfig().CodeSubDirectories; if (codeSubDirectories != null) { codeSubDirectories.EnsureRuntimeValidation(); } return(codeSubDirectories); }
internal static CompilerType GetCSharpCompilerInfo(CompilationSection compConfig, VirtualPath configPath) { if (compConfig == null) { compConfig = MTConfigUtil.GetCompilationConfig(configPath); } if (compConfig.DefaultLanguage == null) { return(new CompilerType(typeof(CSharpCodeProvider), null)); } return(compConfig.GetCompilerInfoFromLanguage("c#")); }
internal static CompilerType GetDefaultLanguageCompilerInfo(CompilationSection compConfig, VirtualPath configPath) { if (compConfig == null) { compConfig = MTConfigUtil.GetCompilationConfig(configPath); } if (compConfig.DefaultLanguage == null) { return(GetCodeDefaultLanguageCompilerInfo()); } return(compConfig.GetCompilerInfoFromLanguage(compConfig.DefaultLanguage)); }
internal static System.Web.Compilation.ExpressionBuilder GetExpressionBuilder(string expressionPrefix, VirtualPath virtualPath, IDesignerHost host) { if (expressionPrefix.Length == 0) { if (dataBindingExpressionBuilder == null) { dataBindingExpressionBuilder = new DataBindingExpressionBuilder(); } return(dataBindingExpressionBuilder); } CompilationSection compilationConfig = null; if (host != null) { IWebApplication application = (IWebApplication)host.GetService(typeof(IWebApplication)); if (application != null) { compilationConfig = application.OpenWebConfiguration(true).GetSection("system.web/compilation") as CompilationSection; } } if (compilationConfig == null) { compilationConfig = MTConfigUtil.GetCompilationConfig(virtualPath); } System.Web.Configuration.ExpressionBuilder builder = compilationConfig.ExpressionBuilders[expressionPrefix]; if (builder == null) { throw new HttpParseException(System.Web.SR.GetString("InvalidExpressionPrefix", new object[] { expressionPrefix })); } Type c = null; if (host != null) { ITypeResolutionService service = (ITypeResolutionService)host.GetService(typeof(ITypeResolutionService)); if (service != null) { c = service.GetType(builder.Type); } } if (c == null) { c = builder.TypeInternal; } if (!typeof(System.Web.Compilation.ExpressionBuilder).IsAssignableFrom(c)) { throw new HttpParseException(System.Web.SR.GetString("ExpressionBuilder_InvalidType", new object[] { c.FullName })); } return((System.Web.Compilation.ExpressionBuilder)HttpRuntime.FastCreatePublicInstance(c)); }
internal static CodeSubDirectoriesCollection GetCodeSubDirectories() { // Get the <compilation> config object CompilationSection config = MTConfigUtil.GetCompilationAppConfig(); CodeSubDirectoriesCollection codeSubDirectories = config.CodeSubDirectories; // Make sure the config data is valid if (codeSubDirectories != null) { codeSubDirectories.EnsureRuntimeValidation(); } return(codeSubDirectories); }
internal static CompilerType GetDefaultLanguageCompilerInfo(CompilationSection compConfig, VirtualPath configPath) { if (compConfig == null) { // Get the <compilation> config object compConfig = MTConfigUtil.GetCompilationConfig(configPath); } // If no default language was specified in config, use VB if (compConfig.DefaultLanguage == null) { return(GetCodeDefaultLanguageCompilerInfo()); } else { return(compConfig.GetCompilerInfoFromLanguage(compConfig.DefaultLanguage)); } }
private static void AddVBGlobalNamespaceImports(CompilerParameters compilParams) { if (s_vbImportsString == null) { PagesSection pagesAppConfig = MTConfigUtil.GetPagesAppConfig(); if (pagesAppConfig.Namespaces == null) { s_vbImportsString = string.Empty; } else { StringBuilder builder = new StringBuilder(); builder.Append("/imports:"); bool flag = false; if (pagesAppConfig.Namespaces.AutoImportVBNamespace) { builder.Append("Microsoft.VisualBasic"); flag = true; } foreach (NamespaceInfo info in pagesAppConfig.Namespaces) { if (flag) { builder.Append(','); } builder.Append(info.Namespace); flag = true; } s_vbImportsString = builder.ToString(); } } if (s_vbImportsString.Length > 0) { if (compilParams.CompilerOptions == null) { compilParams.CompilerOptions = s_vbImportsString; } else { compilParams.CompilerOptions = s_vbImportsString + " " + compilParams.CompilerOptions; } } }
internal static bool NeedToCopyFile(VirtualPath virtualPath, bool updatable, out bool createStub) { createStub = false; CompilationSection compilationConfig = MTConfigUtil.GetCompilationConfig(virtualPath); string extension = virtualPath.Extension; BuildProviderInfo buildProviderInfo = System.Web.Compilation.BuildProvider.GetBuildProviderInfo(compilationConfig, extension); if (buildProviderInfo != null) { if ((BuildProviderAppliesTo.Web & buildProviderInfo.AppliesTo) == 0) { return(true); } if (buildProviderInfo.Type == typeof(ForceCopyBuildProvider)) { return(true); } if ((buildProviderInfo.Type != typeof(IgnoreFileBuildProvider)) && BuildManager.PrecompilingForUpdatableDeployment) { return(true); } createStub = true; if (((buildProviderInfo.Type == typeof(UserControlBuildProvider)) || (buildProviderInfo.Type == typeof(MasterPageBuildProvider))) || (buildProviderInfo.Type == typeof(IgnoreFileBuildProvider))) { createStub = false; } return(false); } if (compilationConfig.GetCompilerInfoFromExtension(extension, false) != null) { return(false); } if (System.Web.Util.StringUtil.EqualsIgnoreCase(extension, ".asax")) { return(false); } if (!updatable && System.Web.Util.StringUtil.EqualsIgnoreCase(extension, ".skin")) { return(false); } return(true); }
private void AddCodeForGetProfileForUser(CodeTypeDeclaration type) { CodeMemberMethod method = new CodeMemberMethod { Name = "GetProfile", Attributes = MemberAttributes.Public, ReturnType = new CodeTypeReference("ProfileCommon") }; method.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "username")); CodeMethodInvokeExpression expression = new CodeMethodInvokeExpression { Method = { TargetObject = new CodeTypeReferenceExpression("ProfileBase"), MethodName = "Create" } }; expression.Parameters.Add(new CodeArgumentReferenceExpression("username")); CodeMethodReturnStatement statement = new CodeMethodReturnStatement(new CodeCastExpression(method.ReturnType, expression)); MTConfigUtil.GetProfileAppConfig(); method.Statements.Add(statement); type.Members.Add(method); }
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); }
private static Type GetPropType(string typeName) { Exception exception = null; try { return(Type.GetType(typeName, true, true)); } catch (Exception exception2) { exception = exception2; } try { CompilationSection compilationAppConfig = MTConfigUtil.GetCompilationAppConfig(); if (compilationAppConfig != null) { AssemblyCollection assemblies = compilationAppConfig.Assemblies; if (assemblies != null) { foreach (Assembly assembly in assemblies) { Type type = assembly.GetType(typeName, false, true); if (type != null) { return(type); } } } } } catch { } throw exception; }
internal NonBatchDirectoryCompiler(VirtualDirectory vdir) { _vdir = vdir; _compConfig = MTConfigUtil.GetCompilationConfig(_vdir.VirtualPath); }
private static void EnsureSettingsLoaded() { if (!_settingsInitialized) { lock (_appSettingsLock) { if (!_settingsInitialized) { NameValueCollection settings = null; try { settings = GetAppSettingsSection(); } finally { // GetApplicationPathData may throw. That's fine. Let the user see the exception // once, but just fall back on default settings for the future. if (settings == null || !Boolean.TryParse(settings["aspnet:UseHostHeaderForRequestUrl"], out _useHostHeaderForRequestUrl)) { _useHostHeaderForRequestUrl = false; } if (settings == null || !Boolean.TryParse(settings["aspnet:AllowAnonymousImpersonation"], out _allowAnonymousImpersonation)) { _allowAnonymousImpersonation = false; } if (settings == null || !Boolean.TryParse(settings["aspnet:ScriptResourceAllowNonJsFiles"], out _scriptResourceAllowNonJsFiles)) { _scriptResourceAllowNonJsFiles = false; } if (settings == null || !Boolean.TryParse(settings["aspnet:UseLegacyEncryption"], out _useLegacyEncryption)) { _useLegacyEncryption = false; } if (settings == null || !Boolean.TryParse(settings["aspnet:UseLegacyMachineKeyEncryption"], out _useLegacyMachineKeyEncryption)) { _useLegacyMachineKeyEncryption = false; } if (settings == null || !Boolean.TryParse(settings["aspnet:UseLegacyFormsAuthenticationTicketCompatibility"], out _useLegacyFormsAuthenticationTicketCompatibility)) { _useLegacyFormsAuthenticationTicketCompatibility = false; } if (settings == null || !Boolean.TryParse(settings["aspnet:UseLegacyEventValidationCompatibility"], out _useLegacyEventValidationCompatibility)) { _useLegacyEventValidationCompatibility = false; } if (settings == null || !Boolean.TryParse(settings["aspnet:AllowRelaxedHttpUserName"], out _allowRelaxedHttpUserName)) { _allowRelaxedHttpUserName = false; } if (settings == null || !Boolean.TryParse(settings["aspnet:JavaScriptDoNotEncodeAmpersand"], out _javaScriptDoNotEncodeAmpersand)) { _javaScriptDoNotEncodeAmpersand = false; } if (settings == null || !Boolean.TryParse(settings["aspnet:UseTaskFriendlySynchronizationContext"], out _useTaskFriendlySynchronizationContext)) { _useTaskFriendlySynchronizationContext = (BinaryCompatibility.Current.TargetsAtLeastFramework45) ? true : false; } if (settings == null || !Boolean.TryParse(settings["aspnet:AllowAsyncDuringSyncStages"], out _allowAsyncDuringSyncStages)) { _allowAsyncDuringSyncStages = false; } if (settings == null || !int.TryParse(settings["aspnet:MaxHttpCollectionKeys"], out _maxHttpCollectionKeys) || _maxHttpCollectionKeys < 0) { _maxHttpCollectionKeys = DefaultMaxHttpCollectionKeys; } if (settings == null || !int.TryParse(settings["aspnet:MaxJsonDeserializerMembers"], out _maxJsonDeserializerMembers) || _maxJsonDeserializerMembers < 0) { _maxJsonDeserializerMembers = DefaultMaxJsonDeserializerMembers; } if (settings == null || !Boolean.TryParse(settings["aspnet:DoNotDisposeSpecialHttpApplicationInstances"], out _doNotDisposeSpecialHttpApplicationInstances)) { _doNotDisposeSpecialHttpApplicationInstances = false; } if (settings != null) { _formsAuthReturnUrlVar = settings["aspnet:FormsAuthReturnUrlVar"]; } if (settings == null || !Boolean.TryParse(settings["aspnet:RestrictXmlControls"], out _restrictXmlControls)) { _restrictXmlControls = false; } if (settings == null || !Boolean.TryParse(settings["aspnet:AllowRelaxedRelativeUrl"], out _allowRelaxedRelativeUrl)) { _allowRelaxedRelativeUrl = false; } if (settings == null || !Boolean.TryParse(settings["aspnet:UseLegacyRequestUrlGeneration"], out _useLegacyRequestUrlGeneration)) { _useLegacyRequestUrlGeneration = false; } if (settings == null || !Boolean.TryParse(settings["aspnet:AllowUtf7RequestContentEncoding"], out _allowUtf7RequestContentEncoding)) { _allowUtf7RequestContentEncoding = false; } if (settings == null || !Boolean.TryParse(settings["aspnet:AllowRelaxedUnicodeDecoding"], out _allowRelaxedUnicodeDecoding)) { _allowRelaxedUnicodeDecoding = false; } if (settings == null || !int.TryParse(settings["aspnet:UpdatePanelMaxScriptLength"], out _updatePanelMaxScriptLength) || _updatePanelMaxScriptLength < 0) { _updatePanelMaxScriptLength = 0; } // AppSettings override allows users to build against 4.5 but run against 4.0 or 4.5 if (settings == null || !int.TryParse(settings["aspnet:MaxConcurrentCompilations"], out _maxConcurrentCompilations) || _maxConcurrentCompilations < 0) { CompilationSection config = MTConfigUtil.GetCompilationAppConfig(); _maxConcurrentCompilations = config.MaxConcurrentCompilations; } if (_maxConcurrentCompilations <= 0) { _maxConcurrentCompilations = Environment.ProcessorCount; } if (settings == null || !int.TryParse(settings["aspnet:MaxAcceptLanguageFallbackCount"], out _maxAcceptLanguageFallbackCount) || _maxAcceptLanguageFallbackCount <= 0) { _maxAcceptLanguageFallbackCount = DefaultMaxAcceptLanguageFallbackCount; } if (settings == null || !Boolean.TryParse(settings["aspnet:PortableCompilationOutput"], out _portableCompilationOutput)) { _portableCompilationOutput = false; } if (settings == null || string.IsNullOrWhiteSpace(_portableCompilationOutputSnapshotType = settings["aspnet:PortableCompilationOutputSnapshotType"])) { _portableCompilationOutputSnapshotType = null; } if (settings == null || string.IsNullOrWhiteSpace(_portableCompilationOutputSnapshotTypeOptions = settings["aspnet:PortableCompilationOutputSnapshotTypeOptions"])) { _portableCompilationOutputSnapshotTypeOptions = null; } _settingsInitialized = true; } } } } }
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); }
internal void Init(VirtualPath virtualPath) { CurrentVirtualPath = virtualPath; _virtualPath = virtualPath; _pagesConfig = MTConfigUtil.GetPagesConfig(virtualPath); }