Esempio n. 1
0
 private static void CheckCyclicAssemblyReferences(CustomScriptAssembly[] customScriptAssemblies)
 {
     if (customScriptAssemblies != null && customScriptAssemblies.Length >= 2)
     {
         Dictionary <string, CustomScriptAssembly> dictionary = new Dictionary <string, CustomScriptAssembly>();
         for (int i = 0; i < customScriptAssemblies.Length; i++)
         {
             CustomScriptAssembly customScriptAssembly = customScriptAssemblies[i];
             dictionary[customScriptAssembly.Name] = customScriptAssembly;
         }
         HashSet <CustomScriptAssembly> visited = new HashSet <CustomScriptAssembly>();
         for (int j = 0; j < customScriptAssemblies.Length; j++)
         {
             CustomScriptAssembly visitAssembly = customScriptAssemblies[j];
             EditorCompilation.CheckCyclicAssemblyReferencesDFS(visitAssembly, visited, dictionary);
         }
     }
 }
Esempio n. 2
0
 private static void CheckCyclicAssemblyReferencesDFS(CustomScriptAssembly visitAssembly, HashSet <CustomScriptAssembly> visited, IDictionary <string, CustomScriptAssembly> nameToCustomScriptAssembly)
 {
     if (visited.Contains(visitAssembly))
     {
         throw new Exception(string.Format("Cyclic assembly references detected. Assemblies: {0}", string.Join(", ", (from a in visited
                                                                                                                      select string.Format("'{0}'", a.Name)).ToArray <string>())));
     }
     visited.Add(visitAssembly);
     string[] references = visitAssembly.References;
     for (int i = 0; i < references.Length; i++)
     {
         string text = references[i];
         CustomScriptAssembly visitAssembly2;
         if (!nameToCustomScriptAssembly.TryGetValue(text, out visitAssembly2))
         {
             throw new Exception(string.Format("Reference to non-existent assembly. Assembly {0} has a reference to {1}", visitAssembly.Name, text));
         }
         EditorCompilation.CheckCyclicAssemblyReferencesDFS(visitAssembly2, visited, nameToCustomScriptAssembly);
     }
     visited.Remove(visitAssembly);
 }