Exemplo n.º 1
0
        public virtual void Parse()
        {
            if (References.Where(t => t.IndexOf("mscorlib.dll", StringComparison.InvariantCultureIgnoreCase) >= 0).FirstOrDefault() == null) //Don't add mscorlib twice
            {
                string mscorlib = null;
                if (!String.IsNullOrEmpty(TargetFrameworkVersion))
                {
                    if (TargetFrameworkVersion == "v2.0" ||
                        TargetFrameworkVersion == "v3.0" ||
                        TargetFrameworkVersion == "v3.5")
                    {
                        mscorlib = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), @"assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll");
                    }
                }
                if (mscorlib == null)
                {
                    mscorlib = typeof(string).Assembly.Location;
                }
                References.Add(mscorlib);
            }

            NFiles       = new List <NFile>();
            CSharpParser = new CSharpParser();
            if (Defines != null)
            {
                Defines.ForEach(t => CSharpParser.CompilerSettings.ConditionalSymbols.Add(t));
            }
            NFiles = SourceFiles.Select(t => new NFile {
                Filename = t, Project = this
            }).ToList();
            AssemblyReferences = References.Select(t => new NAssembly {
                Filename = t
            }).ToList();
            //danel: parser.ErrorPrinter

            ParseCsFiles();
            LoadAssemblies();
            var ms = StopwatchHelper.TimeInMs(LoadAssemblies);

            FormatLine("{0} References End: {1}ms", AssemblyReferences.Count, ms);
            ProjectContent     = new CSharpProjectContent();
            ProjectContent     = (CSharpProjectContent)ProjectContent.SetAssemblyName(AssemblyName);
            ProjectContent     = (CSharpProjectContent)ProjectContent.AddAssemblyReferences(AssemblyReferences.Select(t => t.UnresolvedAssembly).Where(t => t != null));
            ProjectContent     = (CSharpProjectContent)ProjectContent.AddOrUpdateFiles(NFiles.Select(t => t.UnresolvedFile));
            ProjectContent.Tag = this;
            ms = StopwatchHelper.TimeInMs(() => Compilation = ProjectContent.CreateCompilation());
            Compilation.CacheManager.SetShared(typeof(NProject), this);
            FormatLine("CreateCompilation {0}ms", ms);
            //Navigator = CreateNavigator(null);
            //ApplyNavigator will happen BeforeExport only on needed files, in parallel
        }
Exemplo n.º 2
0
        protected virtual void ParseCsFiles()
        {
            var ms = StopwatchHelper.TimeInMs(() => NFiles.ForEach(ParseSkFile));

            FormatLine("{0} Sources files {1}ms", NFiles.Count, ms);
        }