///<summary>Complies list of file items comprising an Application.</summary>
        public void Compile(CompilationUnit cu)
        {
            try
            {
                AssemblyName = cu.AssemblyName;
                InitCompilerState();

                DefaultNamespace = cu.DefaultNamespace;
                _compilationUnitSourcePath = cu.SourcePath;

                if (!IsLanguageSupported(cu.Language))
                {
                    OnError(new Exception(SR.Get(SRID.UnknownLanguage, cu.Language)));
                    return;
                }

                if (!cu.Pass2)
                {
                    EnsureLanguageSourceExtension();
                }

                if (cu.ApplicationFile.Path != null && cu.ApplicationFile.Path.Length > 0)
                {
                    Initialize(cu.ApplicationFile);
                    ApplicationFile = SourceFileInfo.RelativeSourceFilePath;

                    if (ApplicationFile.Length > 0)
                    {
                        IsCompilingEntryPointClass = true;
                        _Compile(cu.ApplicationFile.Path, cu.Pass2);
                        IsCompilingEntryPointClass = false;

                        if (_pendingLocalFiles != null && _pendingLocalFiles.Count == 1)
                        {
                            Debug.Assert(!cu.Pass2);
                            _localXamlApplication = (string)_pendingLocalFiles[0];
                            _pendingLocalFiles.Clear();
                        }
                    }
                }

                if (cu.FileList != null)
                {
                    for (int i = 0; i < cu.FileList.Length; i++)
                    {
                        FileUnit sourceFile = cu.FileList[i];

                        Initialize(sourceFile);
                        if (SourceFileInfo.RelativeSourceFilePath.Length > 0)
                        {
                            _Compile(sourceFile.Path, cu.Pass2);
                        }
                    }

                    if (_pendingLocalFiles != null && _pendingLocalFiles.Count > 0)
                    {
                        Debug.Assert(!cu.Pass2);
                        _localXamlPages = (string[])_pendingLocalFiles.ToArray(typeof(string));
                        _pendingLocalFiles.Clear();
                    }
                }

                if (!cu.Pass2 && ContentList != null && ContentList.Length > 0)
                {
                    GenerateLooseContentAttributes();
                }

                Debug.Assert(!cu.Pass2 || _pendingLocalFiles == null);
                Debug.Assert(_pendingLocalFiles == null || _pendingLocalFiles.Count == 0);
                _pendingLocalFiles = null;

                if (cu.Pass2)
                {
                    _localAssembly = null;
                    _localXamlApplication = null;
                    _localXamlPages = null;
                }
            }
            finally
            {
                if (_typeMapper != null)
                {
                    _typeMapper.ClearReflectionOnlyAssemblyResolver();
                }

                if (s_md5HashAlgorithm != null)
                {
                    s_md5HashAlgorithm.Clear();
                    s_md5HashAlgorithm = null;
                }
            }
        }
        // <summary>
        // Start the compilation.
        // </summary>
        // <param name="assemblyName"></param>
        // <param name="language"></param>
        // <param name="rootNamespace"></param>
        // <param name="fileList"></param>
        // <param name="isSecondPass"></param>
        // <returns></returns>
        internal bool DoCompilation(string assemblyName, string language, string rootNamespace, FileUnit[] fileList, bool isSecondPass)
        {
            bool ret = true;

            CompilationUnit compUnit = new CompilationUnit(assemblyName, language, rootNamespace, fileList);
            compUnit.Pass2 = isSecondPass;

            // Set some properties required by the CompilationUnit
            compUnit.ApplicationFile = _applicationMarkup;
            compUnit.SourcePath = _sourceDir;

            //Set the properties required by MarkupCompiler

            _mc.SourceFileResolve += new SourceFileResolveEventHandler(OnSourceFileResolve);
            _mc.Error += new MarkupErrorEventHandler(OnCompilerError);

            LocalizationDirectivesToLocFile localizeFlag = (LocalizationDirectivesToLocFile)_localizationDirectivesToLocFile;


            //
            // Localization file should not be generated for Intellisense build. Thus
            // checking IsRealBuild.
            //
            if ((localizeFlag == MS.Internal.LocalizationDirectivesToLocFile.All
                 || localizeFlag == MS.Internal.LocalizationDirectivesToLocFile.CommentsOnly)
                && (TaskFileService.IsRealBuild))
            {
                _mc.ParserHooks = new LocalizationParserHooks(_mc, localizeFlag, isSecondPass);
            }

            if (isSecondPass)
            {
                for (int i = 0; i < _mc.ReferenceAssemblyList.Count; i++)
                {
                    ReferenceAssembly asmReference = _mc.ReferenceAssemblyList[i] as ReferenceAssembly;

                    if (asmReference != null)
                    {
                        if (String.Compare(asmReference.AssemblyName, assemblyName, StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            // Set the local assembly file to markupCompiler
                            _mc.LocalAssemblyFile = asmReference;
                        }
                    }
                }
            }

            // finally compile the app
            _mc.Compile(compUnit);

            return ret;
        }