コード例 #1
0
 public string GetExtensionOfSourceFiles()
 {
     if (this._files.Length > 0)
     {
         return(ScriptCompilers.GetExtensionOfSourceFile(this._files[0]));
     }
     return("NA");
 }
コード例 #2
0
        static void Internal_EditorApplicationQuit()
        {
            // VersionControlObject might depend on packages that cleanup themselves using quitting event.
            // Therefore it's important to deactivate it beforehand.
            VersionControlManager.Deactivate();

            foreach (var evt in m_QuittingEvent)
            {
                evt();
            }
            editorApplicationQuit?.Invoke();
            ScriptCompilers.Cleanup();
        }
コード例 #3
0
 private void QueuePendingAssemblies()
 {
     if (this.pendingAssemblies.Count != 0)
     {
         List <ScriptAssembly> list = null;
         foreach (ScriptAssembly current in this.pendingAssemblies)
         {
             bool             flag = true;
             ScriptAssembly[] scriptAssemblyReferences = current.ScriptAssemblyReferences;
             for (int i = 0; i < scriptAssemblyReferences.Length; i++)
             {
                 ScriptAssembly key = scriptAssemblyReferences[i];
                 if (!this.processedAssemblies.ContainsKey(key))
                 {
                     flag = false;
                     break;
                 }
             }
             if (flag)
             {
                 if (list == null)
                 {
                     list = new List <ScriptAssembly>();
                 }
                 list.Add(current);
             }
         }
         if (list != null)
         {
             bool buildingForEditor = (this.options & EditorScriptCompilationOptions.BuildingForEditor) == EditorScriptCompilationOptions.BuildingForEditor;
             foreach (ScriptAssembly current2 in list)
             {
                 this.pendingAssemblies.Remove(current2);
                 MonoIsland         island             = current2.ToMonoIsland(this.options, this.buildOutputDirectory);
                 ScriptCompilerBase scriptCompilerBase = ScriptCompilers.CreateCompilerInstance(island, buildingForEditor, island._target, current2.RunUpdater);
                 this.compilerTasks.Add(current2, scriptCompilerBase);
                 scriptCompilerBase.BeginCompiling();
                 if (this.OnCompilationStarted != null)
                 {
                     this.OnCompilationStarted(current2, this.compilePhase);
                 }
                 if (this.compilerTasks.Count == this.maxConcurrentCompilers)
                 {
                     break;
                 }
             }
             this.compilePhase++;
         }
     }
 }
コード例 #4
0
        public static ScriptAssembly[] GetAllScriptAssemblies(IEnumerable <string> allSourceFiles, string projectDirectory, ScriptAssemblySettings settings, CompilationAssemblies assemblies, TargetAssemblyType onlyIncludeType = TargetAssemblyType.Undefined)
        {
            if (allSourceFiles == null || allSourceFiles.Count() == 0)
            {
                return(new ScriptAssembly[0]);
            }

            var targetAssemblyFiles = new Dictionary <TargetAssembly, HashSet <string> >();

            foreach (var scriptFile in allSourceFiles)
            {
                var targetAssembly = GetTargetAssembly(scriptFile, projectDirectory, assemblies.CustomTargetAssemblies);

                if (!IsCompatibleWithPlatform(targetAssembly, settings))
                {
                    continue;
                }

                // Optionally only include specific TargetAssemblyType assemblies.
                if (onlyIncludeType != TargetAssemblyType.Undefined && targetAssembly.Type != onlyIncludeType)
                {
                    continue;
                }

                var scriptExtension = ScriptCompilers.GetExtensionOfSourceFile(scriptFile);
                var scriptLanguage  = ScriptCompilers.GetLanguageFromExtension(scriptExtension);

                if (targetAssembly.Language == null && targetAssembly.Type == TargetAssemblyType.Custom)
                {
                    targetAssembly.Language = scriptLanguage;
                }

                HashSet <string> assemblySourceFiles;

                if (!targetAssemblyFiles.TryGetValue(targetAssembly, out assemblySourceFiles))
                {
                    assemblySourceFiles = new HashSet <string>();
                    targetAssemblyFiles[targetAssembly] = assemblySourceFiles;
                }

                assemblySourceFiles.Add(AssetPath.Combine(projectDirectory, scriptFile));
            }

            return(ToScriptAssemblies(targetAssemblyFiles, settings, assemblies, null));
        }
コード例 #5
0
        void QueuePendingAssemblies()
        {
            if (pendingAssemblies.Count == 0)
            {
                return;
            }

            List <ScriptAssembly> assemblyCompileQueue    = null;
            List <ScriptAssembly> removePendingAssemblies = null;

            // Find assemblies that have all their references already compiled.
            foreach (var pendingAssembly in pendingAssemblies)
            {
                bool compileAssembly = true;

                foreach (var reference in pendingAssembly.ScriptAssemblyReferences)
                {
                    CompilerMessage[] messages;

                    if (!processedAssemblies.TryGetValue(reference, out messages))
                    {
                        // If a reference is not compiling and not pending
                        // also remove this assembly from pending.
                        if (!compilerTasks.ContainsKey(reference) && !pendingAssemblies.Contains(reference))
                        {
                            if (removePendingAssemblies == null)
                            {
                                removePendingAssemblies = new List <ScriptAssembly>();
                            }

                            removePendingAssemblies.Add(pendingAssembly);
                        }

                        compileAssembly = false;
                        break;
                    }

                    // If reference has compile errors, do not compile the pending assembly.
                    bool compileErrors = messages.Any(m => m.type == CompilerMessageType.Error);

                    if (compileErrors)
                    {
                        if (removePendingAssemblies == null)
                        {
                            removePendingAssemblies = new List <ScriptAssembly>();
                        }

                        removePendingAssemblies.Add(pendingAssembly);

                        compileAssembly = false;
                        break;
                    }
                }

                if (compileAssembly)
                {
                    if (assemblyCompileQueue == null)
                    {
                        assemblyCompileQueue = new List <ScriptAssembly>();
                    }

                    assemblyCompileQueue.Add(pendingAssembly);
                }
            }

            if (removePendingAssemblies != null)
            {
                foreach (var assembly in removePendingAssemblies)
                {
                    pendingAssemblies.Remove(assembly);
                }

                // All pending assemblies were removed and no assemblies
                // were queued for compilation.
                if (assemblyCompileQueue == null)
                {
                    return;
                }
            }

            // No assemblies to compile, need to wait for more references to finish compiling.
            if (assemblyCompileQueue == null)
            {
                if (compilerTasks.Count() == 0)
                {
                    throw new Exception("No pending assemblies queued for compilation and no compilers running. Compilation will never finish.");
                }
                return;
            }

            // Begin compiling any queued assemblies
            foreach (var assembly in assemblyCompileQueue)
            {
                pendingAssemblies.Remove(assembly);

                if (assembly.CallOnBeforeCompilationStarted && OnBeforeCompilationStarted != null)
                {
                    OnBeforeCompilationStarted(assembly, compilePhase);
                }

                var compiler = ScriptCompilers.CreateCompilerInstance(assembly, options, buildOutputDirectory);

                compilerTasks.Add(assembly, compiler);

                // Start compiler process
                compiler.BeginCompiling();

                if (OnCompilationStarted != null)
                {
                    OnCompilationStarted(assembly, compilePhase);
                }

                if (compilerTasks.Count == maxConcurrentCompilers)
                {
                    break;
                }
            }

            compilePhase++;
        }
コード例 #6
0
        string ProjectText(MonoIsland island,
                           Mode mode,
                           Dictionary <string, string> allAssetsProjectParts,
                           IEnumerable <ResponseFileData> responseFilesData,
                           List <MonoIsland> allProjectIslands)
        {
            var   projectBuilder    = new StringBuilder(ProjectHeader(island, responseFilesData));
            var   references        = new List <string>();
            var   projectReferences = new List <Match>();
            Match match;
            bool  isBuildingEditorProject = island._editor;

            foreach (string file in island._files)
            {
                if (!ShouldFileBePartOfSolution(file))
                {
                    continue;
                }

                var extension = Path.GetExtension(file).ToLower();
                var fullFile  = EscapedRelativePathFor(file);
                if (".dll" != extension)
                {
                    var tagName = "Compile";
                    projectBuilder.Append("     <").Append(tagName).Append(" Include=\"").Append(fullFile).Append("\" />").Append(WindowsNewline);
                }
                else
                {
                    references.Add(fullFile);
                }
            }

            string additionalAssetsForProject;
            var    assemblyName = Utility.FileNameWithoutExtension(island._output);

            // Append additional non-script files that should be included in project generation.
            if (allAssetsProjectParts.TryGetValue(assemblyName, out additionalAssetsForProject))
            {
                projectBuilder.Append(additionalAssetsForProject);
            }

            var allAdditionalReferenceFilenames = new List <string>();
            var islandRefs = references.Union(island._references);

            foreach (string reference in islandRefs)
            {
                if (reference.EndsWith("/UnityEditor.dll", StringComparison.Ordinal) ||
                    reference.EndsWith("/UnityEngine.dll", StringComparison.Ordinal) ||
                    reference.EndsWith("\\UnityEditor.dll", StringComparison.Ordinal) ||
                    reference.EndsWith("\\UnityEngine.dll", StringComparison.Ordinal))
                {
                    continue;
                }

                match = scriptReferenceExpression.Match(reference);
                if (match.Success)
                {
                    var language       = ScriptCompilers.GetLanguageFromExtension(island.GetExtensionOfSourceFiles());
                    var targetLanguage = (ScriptingLanguage)Enum.Parse(typeof(ScriptingLanguage), language.GetLanguageName(), true);
                    if (mode == Mode.UnityScriptAsUnityProj || ScriptingLanguage.CSharp == targetLanguage)
                    {
                        // Add a reference to a project except if it's a reference to a script assembly
                        // that we are not generating a project for. This will be the case for assemblies
                        // coming from .assembly.json files in non-internalized packages.
                        var dllName = match.Groups["dllname"].Value;
                        if (allProjectIslands.Any(i => Path.GetFileName(i._output) == dllName))
                        {
                            projectReferences.Add(match);
                            continue;
                        }
                    }
                }

                string fullReference = Path.IsPathRooted(reference) ? reference : Path.Combine(_projectDirectory, reference);
                if (!AssemblyHelper.IsManagedAssembly(fullReference))
                {
                    continue;
                }
                if (AssemblyHelper.IsInternalAssembly(fullReference))
                {
                    if (!IsAdditionalInternalAssemblyReference(isBuildingEditorProject, fullReference))
                    {
                        continue;
                    }
                    var referenceName = Path.GetFileName(fullReference);
                    if (allAdditionalReferenceFilenames.Contains(referenceName))
                    {
                        continue;
                    }
                    allAdditionalReferenceFilenames.Add(referenceName);
                }

                AppendReference(fullReference, projectBuilder);
            }

            var responseRefs = responseFilesData.SelectMany(x => x.FullPathReferences);

            foreach (var reference in responseRefs)
            {
                AppendReference(reference, projectBuilder);
            }

            if (0 < projectReferences.Count)
            {
                string referencedProject;
                projectBuilder.AppendLine("  </ItemGroup>");
                projectBuilder.AppendLine("  <ItemGroup>");
                foreach (Match reference in projectReferences)
                {
                    var targetAssembly = EditorCompilationInterface.Instance.GetTargetAssemblyDetails(reference.Groups["dllname"].Value);
                    ScriptingLanguage targetLanguage = ScriptingLanguage.None;
                    if (targetAssembly != null)
                    {
                        targetLanguage = (ScriptingLanguage)Enum.Parse(typeof(ScriptingLanguage), targetAssembly.Language.GetLanguageName(), true);
                    }
                    referencedProject = reference.Groups["project"].Value;
                    projectBuilder.Append("    <ProjectReference Include=\"").Append(referencedProject).Append(GetProjectExtension(targetLanguage)).Append("\">").Append(WindowsNewline);
                    projectBuilder.Append("      <Project>{").Append(ProjectGuid(Path.Combine("Temp", reference.Groups["project"].Value + ".dll"))).Append("}</Project>").Append(WindowsNewline);
                    projectBuilder.Append("      <Name>").Append(referencedProject).Append("</Name>").Append(WindowsNewline);
                    projectBuilder.AppendLine("    </ProjectReference>");
                }
            }

            projectBuilder.Append(ProjectFooter(island));
            return(projectBuilder.ToString());
        }
コード例 #7
0
        public static ScriptAssembly[] GenerateChangedScriptAssemblies(GenerateChangedScriptAssembliesArgs args)
        {
            var dirtyTargetAssemblies = new Dictionary <TargetAssembly, HashSet <string> >();

            var allTargetAssemblies = args.Assemblies.CustomTargetAssemblies == null ?
                                      predefinedTargetAssemblies :
                                      predefinedTargetAssemblies.Concat(args.Assemblies.CustomTargetAssemblies).ToArray();

            // Mark all assemblies that the script updater must be run on as dirty.
            if (args.RunUpdaterAssemblies != null)
            {
                foreach (var assemblyFilename in args.RunUpdaterAssemblies)
                {
                    var targetAssembly = allTargetAssemblies.First(a => a.FilenameWithSuffix(args.Settings.FilenameSuffix) == assemblyFilename);
                    dirtyTargetAssemblies[targetAssembly] = new HashSet <string>();
                }
            }

            // Collect all dirty TargetAssemblies
            foreach (var dirtySourceFile in args.DirtySourceFiles)
            {
                var targetAssembly = GetTargetAssembly(dirtySourceFile, args.ProjectDirectory, args.Assemblies.CustomTargetAssemblies);

                if (!IsCompatibleWithPlatform(targetAssembly, args.Settings))
                {
                    continue;
                }

                HashSet <string> assemblySourceFiles;

                var scriptExtension = ScriptCompilers.GetExtensionOfSourceFile(dirtySourceFile);
                var scriptLanguage  = ScriptCompilers.GetLanguageFromExtension(scriptExtension);

                if (!dirtyTargetAssemblies.TryGetValue(targetAssembly, out assemblySourceFiles))
                {
                    assemblySourceFiles = new HashSet <string>();
                    dirtyTargetAssemblies[targetAssembly] = assemblySourceFiles;

                    if (targetAssembly.Type == TargetAssemblyType.Custom)
                    {
                        targetAssembly.Language = scriptLanguage;
                    }
                }

                assemblySourceFiles.Add(AssetPath.Combine(args.ProjectDirectory, dirtySourceFile));

                // If there are mixed languages in a custom script folder, mark the assembly to not be compiled.
                if (scriptLanguage != targetAssembly.Language)
                {
                    args.NotCompiledTargetAssemblies.Add(targetAssembly);
                }
            }

            bool isAnyCustomScriptAssemblyDirty = dirtyTargetAssemblies.Any(entry => entry.Key.Type == TargetAssemblyType.Custom);

            // If we have any dirty custom target assemblies, then the predefined target assemblies are marked as dirty,
            // as the predefined assemblies always reference the custom script assemblies.
            if (isAnyCustomScriptAssemblyDirty)
            {
                foreach (var assembly in predefinedTargetAssemblies)
                {
                    if (!IsCompatibleWithPlatform(assembly, args.Settings))
                    {
                        continue;
                    }

                    if (!dirtyTargetAssemblies.ContainsKey(assembly))
                    {
                        dirtyTargetAssemblies[assembly] = new HashSet <string>();
                    }
                }
            }

            // Collect any TargetAssemblies that reference the dirty TargetAssemblies, as they will also be dirty.
            int dirtyAssemblyCount;

            do
            {
                dirtyAssemblyCount = 0;

                foreach (var assembly in allTargetAssemblies)
                {
                    if (!IsCompatibleWithPlatform(assembly, args.Settings))
                    {
                        continue;
                    }

                    // If already dirty, skip.
                    if (dirtyTargetAssemblies.ContainsKey(assembly))
                    {
                        continue;
                    }

                    foreach (var reference in assembly.References)
                    {
                        if (dirtyTargetAssemblies.ContainsKey(reference))
                        {
                            dirtyTargetAssemblies[assembly] = new HashSet <string>();
                            dirtyAssemblyCount++;
                            break;
                        }
                    }
                }
            }while (dirtyAssemblyCount > 0);

            // Add any non-dirty source files that belong to dirty TargetAssemblies
            foreach (var sourceFile in args.AllSourceFiles)
            {
                var targetAssembly = GetTargetAssembly(sourceFile, args.ProjectDirectory, args.Assemblies.CustomTargetAssemblies);

                if (!IsCompatibleWithPlatform(targetAssembly, args.Settings))
                {
                    continue;
                }

                HashSet <string> assemblySourceFiles;

                var scriptExtension = ScriptCompilers.GetExtensionOfSourceFile(sourceFile);
                var scriptLanguage  = ScriptCompilers.GetLanguageFromExtension(scriptExtension);

                if (targetAssembly.Language == null && targetAssembly.Type == TargetAssemblyType.Custom)
                {
                    targetAssembly.Language = scriptLanguage;
                }

                // If there are mixed languages in a custom script folder, mark the assembly to not be compiled.
                if (scriptLanguage != targetAssembly.Language)
                {
                    args.NotCompiledTargetAssemblies.Add(targetAssembly);
                }

                if (dirtyTargetAssemblies.TryGetValue(targetAssembly, out assemblySourceFiles))
                {
                    assemblySourceFiles.Add(AssetPath.Combine(args.ProjectDirectory, sourceFile));
                }
            }

            // Remove any target assemblies which have no source files associated with them.
            dirtyTargetAssemblies = dirtyTargetAssemblies.Where(e => e.Value.Count > 0).ToDictionary(e => e.Key, e => e.Value);

            // Remove any target assemblies which have been marked as do not compile.
            foreach (var removeAssembly in args.NotCompiledTargetAssemblies)
            {
                dirtyTargetAssemblies.Remove(removeAssembly);
            }


            // Convert TargetAssemblies to ScriptAssembiles
            var scriptAssemblies = ToScriptAssemblies(dirtyTargetAssemblies, args.Settings, args.Assemblies, args.RunUpdaterAssemblies);

            return(scriptAssemblies);
        }
コード例 #8
0
        private string ProjectText(MonoIsland island, SolutionSynchronizer.Mode mode, Dictionary <string, string> allAssetsProjectParts, string[] additionalDefines, List <MonoIsland> allProjectIslands)
        {
            StringBuilder stringBuilder           = new StringBuilder(this.ProjectHeader(island, additionalDefines));
            List <string> list                    = new List <string>();
            List <Match>  list2                   = new List <Match>();
            bool          isBuildingEditorProject = island._output.EndsWith("-Editor.dll");

            string[] files = island._files;
            for (int j = 0; j < files.Length; j++)
            {
                string text = files[j];
                if (this.ShouldFileBePartOfSolution(text))
                {
                    string b     = Path.GetExtension(text).ToLower();
                    string text2 = (!Path.IsPathRooted(text)) ? Path.Combine(this._projectDirectory, text) : text;
                    if (".dll" != b)
                    {
                        string arg = "Compile";
                        stringBuilder.AppendFormat("     <{0} Include=\"{1}\" />{2}", arg, this.EscapedRelativePathFor(text2), SolutionSynchronizer.WindowsNewline);
                    }
                    else
                    {
                        list.Add(text2);
                    }
                }
            }
            string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(island._output);
            string value;

            if (allAssetsProjectParts.TryGetValue(fileNameWithoutExtension, out value))
            {
                stringBuilder.Append(value);
            }
            List <string> list3 = new List <string>();

            foreach (string current in list.Union(island._references))
            {
                if (!current.EndsWith("/UnityEditor.dll") && !current.EndsWith("/UnityEngine.dll") && !current.EndsWith("\\UnityEditor.dll") && !current.EndsWith("\\UnityEngine.dll"))
                {
                    Match match = SolutionSynchronizer.scriptReferenceExpression.Match(current);
                    if (match.Success)
                    {
                        SupportedLanguage languageFromExtension = ScriptCompilers.GetLanguageFromExtension(island.GetExtensionOfSourceFiles());
                        ScriptingLanguage scriptingLanguage     = (ScriptingLanguage)Enum.Parse(typeof(ScriptingLanguage), languageFromExtension.GetLanguageName(), true);
                        if (mode == SolutionSynchronizer.Mode.UnityScriptAsUnityProj || scriptingLanguage == ScriptingLanguage.CSharp)
                        {
                            string dllName = match.Groups["dllname"].Value;
                            if (allProjectIslands.Any((MonoIsland i) => Path.GetFileName(i._output) == dllName))
                            {
                                list2.Add(match);
                                continue;
                            }
                        }
                    }
                    string text3 = (!Path.IsPathRooted(current)) ? Path.Combine(this._projectDirectory, current) : current;
                    if (AssemblyHelper.IsManagedAssembly(text3))
                    {
                        if (AssemblyHelper.IsInternalAssembly(text3))
                        {
                            if (!SolutionSynchronizer.IsAdditionalInternalAssemblyReference(isBuildingEditorProject, text3))
                            {
                                continue;
                            }
                            string fileName = Path.GetFileName(text3);
                            if (list3.Contains(fileName))
                            {
                                continue;
                            }
                            list3.Add(fileName);
                        }
                        text3 = text3.Replace("\\", "/");
                        text3 = text3.Replace("\\\\", "/");
                        stringBuilder.AppendFormat(" <Reference Include=\"{0}\">{1}", Path.GetFileNameWithoutExtension(text3), SolutionSynchronizer.WindowsNewline);
                        stringBuilder.AppendFormat(" <HintPath>{0}</HintPath>{1}", text3, SolutionSynchronizer.WindowsNewline);
                        stringBuilder.AppendFormat(" </Reference>{0}", SolutionSynchronizer.WindowsNewline);
                    }
                }
            }
            if (0 < list2.Count)
            {
                stringBuilder.AppendLine("  </ItemGroup>");
                stringBuilder.AppendLine("  <ItemGroup>");
                foreach (Match current2 in list2)
                {
                    EditorBuildRules.TargetAssembly targetAssemblyDetails = EditorCompilationInterface.Instance.GetTargetAssemblyDetails(current2.Groups["dllname"].Value);
                    ScriptingLanguage language = ScriptingLanguage.None;
                    if (targetAssemblyDetails != null)
                    {
                        language = (ScriptingLanguage)Enum.Parse(typeof(ScriptingLanguage), targetAssemblyDetails.Language.GetLanguageName(), true);
                    }
                    string value2 = current2.Groups["project"].Value;
                    stringBuilder.AppendFormat("    <ProjectReference Include=\"{0}{1}\">{2}", value2, SolutionSynchronizer.GetProjectExtension(language), SolutionSynchronizer.WindowsNewline);
                    stringBuilder.AppendFormat("      <Project>{{{0}}}</Project>", this.ProjectGuid(Path.Combine("Temp", current2.Groups["project"].Value + ".dll")), SolutionSynchronizer.WindowsNewline);
                    stringBuilder.AppendFormat("      <Name>{0}</Name>", value2, SolutionSynchronizer.WindowsNewline);
                    stringBuilder.AppendLine("    </ProjectReference>");
                }
            }
            stringBuilder.Append(this.ProjectFooter(island));
            return(stringBuilder.ToString());
        }
コード例 #9
0
        public static ScriptAssembly[] GenerateChangedScriptAssemblies(EditorBuildRules.GenerateChangedScriptAssembliesArgs args)
        {
            bool flag = (args.BuildFlags & BuildFlags.BuildingForEditor) == BuildFlags.BuildingForEditor;
            Dictionary <EditorBuildRules.TargetAssembly, HashSet <string> > dictionary = new Dictionary <EditorBuildRules.TargetAssembly, HashSet <string> >();

            EditorBuildRules.TargetAssembly[] array = (args.Assemblies.CustomTargetAssemblies != null) ? EditorBuildRules.predefinedTargetAssemblies.Concat(args.Assemblies.CustomTargetAssemblies).ToArray <EditorBuildRules.TargetAssembly>() : EditorBuildRules.predefinedTargetAssemblies;
            if (args.RunUpdaterAssemblies != null)
            {
                using (HashSet <string> .Enumerator enumerator = args.RunUpdaterAssemblies.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        string assemblyFilename             = enumerator.Current;
                        EditorBuildRules.TargetAssembly key = array.First((EditorBuildRules.TargetAssembly a) => a.FilenameWithSuffix(args.Settings.FilenameSuffix) == assemblyFilename);
                        dictionary[key] = new HashSet <string>();
                    }
                }
            }
            foreach (string current in args.DirtySourceFiles)
            {
                EditorBuildRules.TargetAssembly targetAssembly = EditorBuildRules.GetTargetAssembly(current, args.ProjectDirectory, args.Assemblies.CustomTargetAssemblies);
                if (flag || !targetAssembly.EditorOnly)
                {
                    string            extensionOfSourceFile = ScriptCompilers.GetExtensionOfSourceFile(current);
                    SupportedLanguage languageFromExtension = ScriptCompilers.GetLanguageFromExtension(extensionOfSourceFile);
                    HashSet <string>  hashSet;
                    if (!dictionary.TryGetValue(targetAssembly, out hashSet))
                    {
                        hashSet = new HashSet <string>();
                        dictionary[targetAssembly] = hashSet;
                        if (targetAssembly.Type == EditorBuildRules.TargetAssemblyType.Custom)
                        {
                            targetAssembly.Language = languageFromExtension;
                        }
                    }
                    hashSet.Add(Path.Combine(args.ProjectDirectory, current));
                    if (languageFromExtension != targetAssembly.Language)
                    {
                        args.NotCompiledTargetAssemblies.Add(targetAssembly);
                    }
                }
            }
            bool flag2 = dictionary.Any((KeyValuePair <EditorBuildRules.TargetAssembly, HashSet <string> > entry) => entry.Key.Type == EditorBuildRules.TargetAssemblyType.Custom);

            if (flag2)
            {
                EditorBuildRules.TargetAssembly[] array2 = EditorBuildRules.predefinedTargetAssemblies;
                for (int i = 0; i < array2.Length; i++)
                {
                    EditorBuildRules.TargetAssembly targetAssembly2 = array2[i];
                    if (flag || !targetAssembly2.EditorOnly)
                    {
                        if (!dictionary.ContainsKey(targetAssembly2))
                        {
                            dictionary[targetAssembly2] = new HashSet <string>();
                        }
                    }
                }
            }
            int num;

            do
            {
                num = 0;
                EditorBuildRules.TargetAssembly[] array3 = array;
                for (int j = 0; j < array3.Length; j++)
                {
                    EditorBuildRules.TargetAssembly targetAssembly3 = array3[j];
                    if (flag || !targetAssembly3.EditorOnly)
                    {
                        if (!dictionary.ContainsKey(targetAssembly3))
                        {
                            foreach (EditorBuildRules.TargetAssembly current2 in targetAssembly3.References)
                            {
                                if (dictionary.ContainsKey(current2))
                                {
                                    dictionary[targetAssembly3] = new HashSet <string>();
                                    num++;
                                    break;
                                }
                            }
                        }
                    }
                }
            }while (num > 0);
            foreach (string current3 in args.AllSourceFiles)
            {
                EditorBuildRules.TargetAssembly targetAssembly4 = EditorBuildRules.GetTargetAssembly(current3, args.ProjectDirectory, args.Assemblies.CustomTargetAssemblies);
                if (flag || !targetAssembly4.EditorOnly)
                {
                    string            extensionOfSourceFile2 = ScriptCompilers.GetExtensionOfSourceFile(current3);
                    SupportedLanguage languageFromExtension2 = ScriptCompilers.GetLanguageFromExtension(extensionOfSourceFile2);
                    if (targetAssembly4.Language == null && targetAssembly4.Type == EditorBuildRules.TargetAssemblyType.Custom)
                    {
                        targetAssembly4.Language = languageFromExtension2;
                    }
                    if (languageFromExtension2 != targetAssembly4.Language)
                    {
                        args.NotCompiledTargetAssemblies.Add(targetAssembly4);
                    }
                    HashSet <string> hashSet2;
                    if (dictionary.TryGetValue(targetAssembly4, out hashSet2))
                    {
                        hashSet2.Add(Path.Combine(args.ProjectDirectory, current3));
                    }
                }
            }
            dictionary = (from e in dictionary
                          where e.Value.Count > 0
                          select e).ToDictionary((KeyValuePair <EditorBuildRules.TargetAssembly, HashSet <string> > e) => e.Key, (KeyValuePair <EditorBuildRules.TargetAssembly, HashSet <string> > e) => e.Value);
            foreach (EditorBuildRules.TargetAssembly current4 in args.NotCompiledTargetAssemblies)
            {
                dictionary.Remove(current4);
            }
            return(EditorBuildRules.ToScriptAssemblies(dictionary, args.Settings, args.BuildFlags, args.Assemblies, args.RunUpdaterAssemblies));
        }