internal void Configure(ClientBuildManager client)
 {
     this.AddPendingCall();
     try
     {
         this._virtualPathProvider = new ClientVirtualPathProvider();
         HostingEnvironment.RegisterVirtualPathProviderInternal(this._virtualPathProvider);
         this._client = client;
         if (this._client.CBMTypeDescriptionProviderBridge != null)
         {
             TargetFrameworkUtil.CBMTypeDescriptionProviderBridge = this._client.CBMTypeDescriptionProviderBridge;
         }
         this._onAppDomainUnload = new EventHandler(this.OnAppDomainUnload);
         Thread.GetDomain().DomainUnload += this._onAppDomainUnload;
         this._buildManager = BuildManager.TheBuildManager;
         HttpRuntime.AppDomainShutdown += new BuildManagerHostUnloadEventHandler(this.OnAppDomainShutdown);
     }
     finally
     {
         this.RemovePendingCall();
     }
 }
Esempio n. 2
0
        void AssignToGroup(BuildProvider buildProvider, List <BuildProviderGroup> groups)
        {
            if (IsDependencyCycle(buildProvider))
            {
                throw new HttpException("Dependency cycles are not suppported: " + buildProvider.VirtualPath);
            }

            BuildProviderGroup myGroup       = null;
            string             bpVirtualPath = buildProvider.VirtualPath;
            string             bpPath        = VirtualPathUtility.GetDirectory(bpVirtualPath);
            bool canAdd;

            if (BuildManager.HasCachedItemNoLock(buildProvider.VirtualPath))
            {
                return;
            }

            StringComparison stringComparison = RuntimeHelpers.StringComparison;

            if (buildProvider is ApplicationFileBuildProvider || buildProvider is ThemeDirectoryBuildProvider)
            {
                // global.asax and theme directory go into their own assemblies
                myGroup            = new BuildProviderGroup();
                myGroup.Standalone = true;
                InsertGroup(myGroup, groups);
            }
            else
            {
                Type bpCodeDomType = GetBuildProviderCodeDomType(buildProvider);
                foreach (BuildProviderGroup group in groups)
                {
                    if (group.Standalone)
                    {
                        continue;
                    }

                    if (group.Count == 0)
                    {
                        myGroup = group;
                        break;
                    }

                    canAdd = true;
                    foreach (BuildProvider bp in group)
                    {
                        if (IsDependency(buildProvider, bp))
                        {
                            canAdd = false;
                            break;
                        }

                        // There should be one assembly per virtual dir
                        if (String.Compare(bpPath, VirtualPathUtility.GetDirectory(bp.VirtualPath), stringComparison) != 0)
                        {
                            canAdd = false;
                            break;
                        }

                        // Different languages go to different assemblies
                        if (bpCodeDomType != null)
                        {
                            Type type = GetBuildProviderCodeDomType(bp);
                            if (type != null)
                            {
                                if (type != bpCodeDomType)
                                {
                                    canAdd = false;
                                    break;
                                }
                            }
                        }
                    }

                    if (!canAdd)
                    {
                        continue;
                    }

                    myGroup = group;
                    break;
                }

                if (myGroup == null)
                {
                    myGroup = new BuildProviderGroup();
                    InsertGroup(myGroup, groups);
                }
            }

            myGroup.AddProvider(buildProvider);
            if (String.Compare(bpPath, virtualPathDirectory, stringComparison) == 0)
            {
                myGroup.Master = true;
            }
        }
    internal void Configure(ClientBuildManager client) {

        // Add a pending call to make sure our thread doesn't get killed
        AddPendingCall();

        try {
            _virtualPathProvider = new ClientVirtualPathProvider();
            HostingEnvironment.RegisterVirtualPathProviderInternal(_virtualPathProvider);

            _client = client;

            // Type description provider required for multitargeting compilation support in VS.
            if (_client.CBMTypeDescriptionProviderBridge != null) {
                TargetFrameworkUtil.CBMTypeDescriptionProviderBridge = _client.CBMTypeDescriptionProviderBridge;
            }

            // start watching for app domain unloading
            _onAppDomainUnload = new EventHandler(OnAppDomainUnload);
            Thread.GetDomain().DomainUnload += _onAppDomainUnload;

            _buildManager = BuildManager.TheBuildManager;

            // Listen to appdomain shutdown.
            HttpRuntime.AppDomainShutdown += new BuildManagerHostUnloadEventHandler(this.OnAppDomainShutdown);
        }
        finally {
            RemovePendingCall();
        }
    }
 private void FixupReferencedAssemblies(VirtualPath virtualPath, CompilerParameters compilerParameters)
 {
     Util.AddAssembliesToStringCollection(BuildManager.GetReferencedAssemblies(MTConfigUtil.GetCompilationConfig(virtualPath)), compilerParameters.ReferencedAssemblies);
 }
Esempio n. 5
0
        internal CompilerResults BuildAssembly(VirtualPath virtualPath, CompilerParameters options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }
            options.TempFiles = temp_files;
            if (options.OutputAssembly == null)
            {
                options.OutputAssembly = OutputAssemblyName;
            }

            ProcessPartialTypes();

            CompilerResults results;

            CodeUnit [] units = GetUnitsAsArray();

            // Since we may have some source files and some code
            // units, we generate code from all of them and then
            // compile the assembly from the set of temporary source
            // files. This also facilates possible debugging for the
            // end user, since they get the code beforehand.
            List <string> files = SourceFiles;
            Dictionary <string, string> resources = ResourceFiles;

            if (units.Length == 0 && files.Count == 0 && resources.Count == 0 && options.EmbeddedResources.Count == 0)
            {
                return(null);
            }

            string compilerOptions = options.CompilerOptions;

            if (options.IncludeDebugInformation)
            {
                if (String.IsNullOrEmpty(compilerOptions))
                {
                    compilerOptions = "/d:DEBUG";
                }
                else if (compilerOptions.IndexOf("d:DEBUG", StringComparison.OrdinalIgnoreCase) == -1)
                {
                    compilerOptions += " /d:DEBUG";
                }

                options.CompilerOptions = compilerOptions;
            }

            if (String.IsNullOrEmpty(compilerOptions))
            {
                compilerOptions = "/noconfig";
            }
            else if (compilerOptions.IndexOf("noconfig", StringComparison.OrdinalIgnoreCase) == -1)
            {
                compilerOptions += " /noconfig";
            }
            options.CompilerOptions = compilerOptions;

            string       filename;
            StreamWriter sw = null;

            foreach (CodeUnit unit in units)
            {
                filename = GetTempFilePhysicalPath(provider.FileExtension);
                try {
                    sw = new StreamWriter(File.OpenWrite(filename), Encoding.UTF8);
                    provider.GenerateCodeFromCompileUnit(unit.Unit, sw, null);
                    files.Add(filename);
                } catch {
                    throw;
                } finally {
                    if (sw != null)
                    {
                        sw.Flush();
                        sw.Close();
                    }
                }

                if (unit.BuildProvider != null)
                {
                    AddPathToBuilderMap(filename, unit.BuildProvider);
                }
            }

            foreach (KeyValuePair <string, string> de in resources)
            {
                options.EmbeddedResources.Add(de.Value);
            }

            AddAssemblyReference(BuildManager.GetReferencedAssemblies());
            List <Assembly>  referencedAssemblies = ReferencedAssemblies;
            StringCollection optRefAsm            = options.ReferencedAssemblies;
            Type             appType = HttpApplicationFactory.AppType;

            if (appType != null && !referencedAssemblies.Contains(appType.Assembly))
            {
                referencedAssemblies.Add(appType.Assembly);
            }

            foreach (Assembly refasm in ReferencedAssemblies)
            {
                string path         = new Uri(refasm.CodeBase).LocalPath;
                string originalPath = refasm.Location;
                if (!optRefAsm.Contains(path) && !optRefAsm.Contains(originalPath))
                {
                    optRefAsm.Add(path);
                }
            }



            results = provider.CompileAssemblyFromFile(options, files.ToArray());

            if (results.NativeCompilerReturnValue != 0)
            {
                string fileText = null;
                CompilerErrorCollection errors = results.Errors;
                try {
                    if (errors != null && errors.Count > 0)
                    {
                        using (StreamReader sr = File.OpenText(results.Errors [0].FileName))
                            fileText = sr.ReadToEnd();
                    }
                } catch (Exception) {}

#if DEBUG
                Console.WriteLine("********************************************************************");
                Console.WriteLine("Compilation failed.");
                Console.WriteLine("Output:");
                foreach (string s in results.Output)
                {
                    Console.WriteLine("  " + s);
                }
                Console.WriteLine("\nErrors:");
                foreach (CompilerError err in results.Errors)
                {
                    Console.WriteLine(err);
                }
                if (errors != null && errors.Count > 0)
                {
                    Console.WriteLine("File name: {0}", results.Errors [0].FileName);
                }
                else
                {
                    Console.WriteLine("File name not available");
                }
                if (!String.IsNullOrEmpty(fileText))
                {
                    Console.WriteLine("File text:\n{0}\n", fileText);
                }
                else
                {
                    Console.WriteLine("No file text available");
                }
                Console.WriteLine("********************************************************************");
#endif
                throw new CompilationException(virtualPath != null ? virtualPath.Original : String.Empty, results, fileText);
            }

            Assembly assembly = results.CompiledAssembly;
            if (assembly == null)
            {
                if (!File.Exists(options.OutputAssembly))
                {
                    results.TempFiles.Delete();
                    throw new CompilationException(virtualPath != null ? virtualPath.Original : String.Empty, results.Errors,
                                                   "No assembly returned after compilation!?");
                }

                try {
                    results.CompiledAssembly = Assembly.LoadFrom(options.OutputAssembly);
                } catch (Exception ex) {
                    results.TempFiles.Delete();
                    throw new HttpException("Unable to load compiled assembly", ex);
                }
            }

            if (!KeepFiles)
            {
                results.TempFiles.Delete();
            }
            return(results);
        }
        internal CodeCompileUnit GenerateCodeCompileUnit(VirtualPath virtualPath, string virtualFileString, out Type codeDomProviderType, out CompilerParameters compilerParameters, out IDictionary linePragmasTable)
        {
            CodeCompileUnit codeCompileUnit;

            this.AddPendingCall();
            try
            {
                BuildManager.SkipTopLevelCompilationExceptions = true;
                this._buildManager.EnsureTopLevelFilesCompiled();
                if (virtualFileString == null)
                {
                    using (Stream stream = virtualPath.OpenFile())
                    {
                        virtualFileString = Util.ReaderFromStream(stream, virtualPath).ReadToEnd();
                    }
                }
                this._virtualPathProvider.RegisterVirtualFile(virtualPath, virtualFileString);
                string cacheKey = BuildManager.GetCacheKeyFromVirtualPath(virtualPath) + "_CBMResult";
                BuildResultCodeCompileUnit buildResultFromCache = (BuildResultCodeCompileUnit)BuildManager.GetBuildResultFromCache(cacheKey, virtualPath);
                if (buildResultFromCache == null)
                {
                    lock (this._lock)
                    {
                        DateTime utcNow = DateTime.UtcNow;
                        System.Web.Compilation.BuildProvider provider = this.GetCompilerParamsAndBuildProvider(virtualPath, out codeDomProviderType, out compilerParameters);
                        if (provider == null)
                        {
                            linePragmasTable = null;
                            return(null);
                        }
                        CodeCompileUnit unit2 = provider.GetCodeCompileUnit(out linePragmasTable);
                        buildResultFromCache = new BuildResultCodeCompileUnit(codeDomProviderType, unit2, compilerParameters, linePragmasTable)
                        {
                            VirtualPath = virtualPath
                        };
                        buildResultFromCache.SetCacheKey(cacheKey);
                        this.FixupReferencedAssemblies(virtualPath, compilerParameters);
                        if (unit2 != null)
                        {
                            foreach (string str2 in compilerParameters.ReferencedAssemblies)
                            {
                                unit2.ReferencedAssemblies.Add(str2);
                            }
                        }
                        ICollection virtualPathDependencies = provider.VirtualPathDependencies;
                        if (virtualPathDependencies != null)
                        {
                            buildResultFromCache.AddVirtualPathDependencies(virtualPathDependencies);
                        }
                        BuildManager.CacheBuildResult(cacheKey, buildResultFromCache, utcNow);
                        return(unit2);
                    }
                }
                codeDomProviderType = buildResultFromCache.CodeDomProviderType;
                compilerParameters  = buildResultFromCache.CompilerParameters;
                linePragmasTable    = buildResultFromCache.LinePragmasTable;
                this.FixupReferencedAssemblies(virtualPath, compilerParameters);
                codeCompileUnit = buildResultFromCache.CodeCompileUnit;
            }
            finally
            {
                if (virtualFileString != null)
                {
                    this._virtualPathProvider.RevertVirtualFile(virtualPath);
                }
                BuildManager.SkipTopLevelCompilationExceptions = false;
                this.RemovePendingCall();
            }
            return(codeCompileUnit);
        }
 internal bool IsCodeAssembly(string assemblyName)
 {
     return(BuildManager.GetNormalizedCodeAssemblyName(assemblyName) != null);
 }
Esempio n. 8
0
        private static BuildResultCompiledType GetThemeBuildResultType(string themeName)
        {
            string cacheKey = null;
            string str      = "Theme_" + Util.MakeValidTypeNameFromString(themeName);
            BuildResultCompiledType buildResultFromCache = (BuildResultCompiledType)BuildManager.GetBuildResultFromCache(str);

            if (buildResultFromCache == null)
            {
                cacheKey             = "GlobalTheme_" + themeName;
                buildResultFromCache = (BuildResultCompiledType)BuildManager.GetBuildResultFromCache(cacheKey);
            }
            if (buildResultFromCache == null)
            {
                bool gotLock = false;
                try
                {
                    CompilationLock.GetLock(ref gotLock);
                    buildResultFromCache = (BuildResultCompiledType)BuildManager.GetBuildResultFromCache(str);
                    if (buildResultFromCache == null)
                    {
                        buildResultFromCache = (BuildResultCompiledType)BuildManager.GetBuildResultFromCache(cacheKey);
                    }
                    if (buildResultFromCache != null)
                    {
                        return(buildResultFromCache);
                    }
                    VirtualPath            virtualDirPath     = null;
                    VirtualPath            appThemeVirtualDir = GetAppThemeVirtualDir(themeName);
                    PageThemeBuildProvider themeBuildProvider = null;
                    VirtualPath            configPath         = appThemeVirtualDir;
                    string str3 = str;
                    if (appThemeVirtualDir.DirectoryExists())
                    {
                        themeBuildProvider = new PageThemeBuildProvider(appThemeVirtualDir);
                    }
                    else
                    {
                        virtualDirPath = GetGlobalThemeVirtualDir(themeName);
                        if (!virtualDirPath.DirectoryExists())
                        {
                            throw new HttpException(System.Web.SR.GetString("Page_theme_not_found", new object[] { themeName }));
                        }
                        configPath         = virtualDirPath;
                        str3               = cacheKey;
                        themeBuildProvider = new GlobalPageThemeBuildProvider(virtualDirPath);
                    }
                    DateTime utcNow = DateTime.UtcNow;
                    AddThemeFilesToBuildProvider(configPath.GetDirectory(), themeBuildProvider, true);
                    BuildProvidersCompiler compiler = new BuildProvidersCompiler(configPath, themeBuildProvider.AssemblyNamePrefix + BuildManager.GenerateRandomAssemblyName(themeName));
                    compiler.SetBuildProviders(new SingleObjectCollection(themeBuildProvider));
                    CompilerResults results = compiler.PerformBuild();
                    buildResultFromCache = (BuildResultCompiledType)themeBuildProvider.GetBuildResult(results);
                    BuildManager.CacheBuildResult(str3, buildResultFromCache, utcNow);
                }
                finally
                {
                    if (gotLock)
                    {
                        CompilationLock.ReleaseLock();
                    }
                }
            }
            return(buildResultFromCache);
        }
Esempio n. 9
0
        public override void GenerateCode(AssemblyBuilder assemblyBuilder)
        {
            string str2;

            if (!s_triedToGetWebRefType)
            {
                s_indigoWebRefProviderType = BuildManager.GetType("System.Web.Compilation.WCFBuildProvider", false);
                s_triedToGetWebRefType     = true;
            }
            if (s_indigoWebRefProviderType != null)
            {
                BuildProvider provider = (BuildProvider)HttpRuntime.CreateNonPublicInstance(s_indigoWebRefProviderType);
                provider.SetVirtualPath(base.VirtualPathObject);
                provider.GenerateCode(assemblyBuilder);
            }
            VirtualPath webRefDirectoryVirtualPath = HttpRuntime.WebRefDirectoryVirtualPath;
            string      virtualPath = this._vdir.VirtualPath;

            if (webRefDirectoryVirtualPath.VirtualPathString.Length == virtualPath.Length)
            {
                str2 = string.Empty;
            }
            else
            {
                string[] strArray = UrlPath.RemoveSlashFromPathIfNeeded(virtualPath).Substring(webRefDirectoryVirtualPath.VirtualPathString.Length).Split(new char[] { '/' });
                for (int i = 0; i < strArray.Length; i++)
                {
                    strArray[i] = Util.MakeValidTypeNameFromString(strArray[i]);
                }
                str2 = string.Join(".", strArray);
            }
            CodeNamespace          proxyCode     = new CodeNamespace(str2);
            WebReferenceCollection webReferences = new WebReferenceCollection();
            bool flag = false;

            foreach (VirtualFile file in this._vdir.Files)
            {
                if (UrlPath.GetExtension(file.VirtualPath).ToLower(CultureInfo.InvariantCulture) == ".discomap")
                {
                    string topLevelFilename          = HostingEnvironment.MapPath(file.VirtualPath);
                    DiscoveryClientProtocol protocol = new DiscoveryClientProtocol {
                        AllowAutoRedirect = true,
                        Credentials       = CredentialCache.DefaultCredentials
                    };
                    protocol.ReadAll(topLevelFilename);
                    WebReference reference        = new WebReference(protocol.Documents, proxyCode);
                    string       str5             = Path.ChangeExtension(UrlPath.GetFileName(file.VirtualPath), null);
                    string       appSettingUrlKey = str2 + "." + str5;
                    WebReference webReference     = new WebReference(protocol.Documents, proxyCode, reference.ProtocolName, appSettingUrlKey, null);
                    webReferences.Add(webReference);
                    flag = true;
                }
            }
            if (flag)
            {
                CodeCompileUnit codeCompileUnit = new CodeCompileUnit();
                codeCompileUnit.Namespaces.Add(proxyCode);
                WebReferenceOptions options = new WebReferenceOptions {
                    CodeGenerationOptions = CodeGenerationOptions.GenerateOldAsync | CodeGenerationOptions.GenerateNewAsync | CodeGenerationOptions.GenerateProperties,
                    Style   = ServiceDescriptionImportStyle.Client,
                    Verbose = true
                };
                ServiceDescriptionImporter.GenerateWebReferences(webReferences, assemblyBuilder.CodeDomProvider, codeCompileUnit, options);
                assemblyBuilder.AddCodeCompileUnit(this, codeCompileUnit);
            }
        }
Esempio n. 10
0
        // Cache the various compile errors found during batching
        private void CacheCompileErrors(AssemblyBuilder assemblyBuilder, CompilerResults results)
        {
            BuildProvider previous = null;

            // Go through all the compile errors
            foreach (CompilerError error in results.Errors)
            {
                // Skip warnings
                if (error.IsWarning)
                {
                    continue;
                }

                // Try to map the error back to a BuildProvider.  If we can't, skip the error.
                BuildProvider buildProvider = assemblyBuilder.GetBuildProviderFromLinePragma(error.FileName);
                if (buildProvider == null)
                {
                    continue;
                }

                // Only cache the error for template controls.  Otherwise, for file types like
                // asmx/ashx, it's too likely that two of them define the same class.
                if (!(buildProvider is BaseTemplateBuildProvider))
                {
                    continue;
                }

                // If the error is for the same page as the previous one, ignore it
                if (buildProvider == previous)
                {
                    continue;
                }
                previous = buildProvider;

                // Create a new CompilerResults for this error
                CompilerResults newResults = new CompilerResults(null /*tempFiles*/);

                // Copy all the output to the new result.  Note that this will include all the
                // error lines, not just the ones for this BuildProvider.  But that's not a big deal,
                // and we can't easily filter the output here.
                foreach (string s in results.Output)
                {
                    newResults.Output.Add(s);
                }

                // Copy various other fields to the new CompilerResults object
                newResults.PathToAssembly            = results.PathToAssembly;
                newResults.NativeCompilerReturnValue = results.NativeCompilerReturnValue;

                // Add this error.  It will be the only one in the CompilerResults object.
                newResults.Errors.Add(error);

                // Create a new HttpCompileException & BuildResultCompileError to wrap this error
                HttpCompileException e = new HttpCompileException(newResults,
                                                                  assemblyBuilder.GetGeneratedSourceFromBuildProvider(buildProvider));
                BuildResult result = new BuildResultCompileError(buildProvider.VirtualPathObject, e);

                // Add the dependencies to the compile error build provider, so that
                // we will retry compilation when a dependency changes
                buildProvider.SetBuildResultDependencies(result);

                // Cache it
                BuildManager.CacheVPathBuildResult(buildProvider.VirtualPathObject, result, _utcStart);
            }
        }
Esempio n. 11
0
        private void AddBuildProviders(bool retryIfDeletionHappens)
        {
            DiskBuildResultCache.ResetAssemblyDeleted();

            foreach (VirtualFile vfile in _vdir.Files)
            {
                // If it's already built and up to date, skip it
                BuildResult result = null;
                try {
                    result = BuildManager.GetVPathBuildResultFromCache(vfile.VirtualPathObject);
                }
                catch {
                    // Ignore the cached error in batch compilation mode, since we want to compile
                    // as many files as possible.
                    // But don't ignore it in CBM or precompile cases, since we always want to try
                    // to compile everything that had failed before.
                    if (!BuildManager.PerformingPrecompilation)
                    {
                        // Skip it if an exception occurs (e.g. if a compile error was cached for it)
                        continue;
                    }
                }

                if (result != null)
                {
                    continue;
                }

                BuildProvider buildProvider = BuildManager.CreateBuildProvider(vfile.VirtualPathObject,
                                                                               _compConfig, _referencedAssemblies, false /*failIfUnknown*/);

                // Non-supported file type
                if (buildProvider == null)
                {
                    continue;
                }

                // IgnoreFileBuildProvider's should never be created
                Debug.Assert(!(buildProvider is IgnoreFileBuildProvider));

                _buildProviders[vfile.VirtualPath] = buildProvider;
            }

            // If an assembly had to be deleted/renamed as a result of calling GetVPathBuildResultFromCache,
            // me way need to run the AddBuildProviders logic again.  The reason is that as a result of
            // deleting the assembly, we may have invalidated other BuildResult that we had earlier found
            // to be up to date (VSWhidbey 269297)
            if (DiskBuildResultCache.InUseAssemblyWasDeleted)
            {
                Debug.Assert(retryIfDeletionHappens);

                // Only retry if we're doing precompilation.  For standard batching, we can live
                // with the fact that not everything will be built after we're done (and we want to
                // be done as quickly as possible since the user is waiting).
                if (retryIfDeletionHappens && BuildManager.PerformingPrecompilation)
                {
                    Debug.Trace("WebDirectoryBatchCompiler", "Rerunning AddBuildProviders for '" +
                                _vdir.VirtualPath + "' because an assembly was out of date.");

                    // Pass false for retryIfDeletionHappens to make sure we don't get in an
                    // infinite recursion.
                    AddBuildProviders(false /*retryIfDeletionHappens*/);
                }
            }
        }
        protected override void CreateConstructor(CodeStatementCollection localVars,
                                                  CodeStatementCollection trueStmt)
        {
            MainDirectiveAttribute <string> masterPageFile = pageParser.MasterPageFile;

            if (masterPageFile != null && !masterPageFile.IsExpression)
            {
                // This is here just to trigger master page build, so that its type
                // is available when compiling the page itself.
                BuildManager.GetCompiledType(masterPageFile.Value);
            }

            MainDirectiveAttribute <string> clientTarget;

            clientTarget = pageParser.ClientTarget;
            if (clientTarget != null)
            {
                CodeExpression prop;
                prop = new CodePropertyReferenceExpression(thisRef, "ClientTarget");
                CodeExpression ct = null;

                if (clientTarget.IsExpression)
                {
                    var pi = GetFieldOrProperty(typeof(Page), "ClientTarget") as PropertyInfo;
                    if (pi != null)
                    {
                        ct = CompileExpression(pi, pi.PropertyType, clientTarget.UnparsedValue, false);
                    }
                }

                if (ct == null)
                {
                    ct = new CodePrimitiveExpression(clientTarget.Value);
                }
                if (localVars == null)
                {
                    localVars = new CodeStatementCollection();
                }
                localVars.Add(new CodeAssignStatement(prop, ct));
            }

            List <string> deps      = pageParser.Dependencies;
            int           depsCount = deps != null ? deps.Count : 0;

            if (depsCount > 0)
            {
                if (localVars == null)
                {
                    localVars = new CodeStatementCollection();
                }
                if (trueStmt == null)
                {
                    trueStmt = new CodeStatementCollection();
                }

                CodeAssignStatement assign;
                localVars.Add(
                    new CodeVariableDeclarationStatement(
                        typeof(string[]),
                        "dependencies")
                    );

                CodeVariableReferenceExpression dependencies = new CodeVariableReferenceExpression("dependencies");
                trueStmt.Add(
                    new CodeAssignStatement(dependencies, new CodeArrayCreateExpression(typeof(string), depsCount))
                    );

                CodeArrayIndexerExpression arrayIndex;
                object o;

                for (int i = 0; i < depsCount; i++)
                {
                    o          = deps [i];
                    arrayIndex = new CodeArrayIndexerExpression(dependencies, new CodeExpression[] { new CodePrimitiveExpression(i) });
                    assign     = new CodeAssignStatement(arrayIndex, new CodePrimitiveExpression(o));
                    trueStmt.Add(assign);
                }

                CodeMethodInvokeExpression getDepsCall = new CodeMethodInvokeExpression(
                    thisRef,
                    "GetWrappedFileDependencies",
                    new CodeExpression[] { dependencies }
                    );
                assign = new CodeAssignStatement(GetMainClassFieldReferenceExpression("__fileDependencies"), getDepsCall);

                trueStmt.Add(assign);
            }

            base.CreateConstructor(localVars, trueStmt);
        }