Ejemplo n.º 1
0
        private string ProjectText(MonoIsland island, SolutionSynchronizer.Mode mode, string allAssetsProject)
        {
            StringBuilder stringBuilder           = new StringBuilder(this.ProjectHeader(island));
            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 i = 0; i < files.Length; i++)
            {
                string text  = files[i];
                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);
                }
            }
            stringBuilder.Append(allAssetsProject);
            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 && (mode == SolutionSynchronizer.Mode.UnityScriptAsUnityProj || (int)Enum.Parse(typeof(ScriptingLanguage), match.Groups["language"].Value, true) == 2))
                    {
                        list2.Add(match);
                    }
                    else
                    {
                        string text3 = (!Path.IsPathRooted(current)) ? Path.Combine(this._projectDirectory, current) : current;
                        if (AssemblyHelper.IsManagedAssembly(text3))
                        {
                            if (!AssemblyHelper.IsInternalAssembly(text3) || SolutionSynchronizer.IsInternalAssemblyThatShouldBeReferenced(isBuildingEditorProject, text3))
                            {
                                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)
                {
                    string value = current2.Groups["project"].Value;
                    stringBuilder.AppendFormat("    <ProjectReference Include=\"{0}{1}\">{2}", value, SolutionSynchronizer.GetProjectExtension((ScriptingLanguage)((int)Enum.Parse(typeof(ScriptingLanguage), current2.Groups["language"].Value, true))), SolutionSynchronizer.WindowsNewline);
                    stringBuilder.AppendFormat("      <Project>{{{0}}}</Project>", this.ProjectGuid(Path.Combine("Temp", current2.Groups["project"].Value + ".dll")), SolutionSynchronizer.WindowsNewline);
                    stringBuilder.AppendFormat("      <Name>{0}</Name>", value, SolutionSynchronizer.WindowsNewline);
                    stringBuilder.AppendLine("    </ProjectReference>");
                }
            }
            stringBuilder.Append(this.ProjectFooter(island));
            return(stringBuilder.ToString());
        }
        private string ProjectText(MonoIsland island, SolutionSynchronizer.Mode mode, string allAssetsProject)
        {
            StringBuilder stringBuilder           = new StringBuilder(this.ProjectHeader(island));
            List <string> first                   = new List <string>();
            List <Match>  matchList               = new List <Match>();
            bool          isBuildingEditorProject = island._output.EndsWith("-Editor.dll");

            foreach (string file1 in island._files)
            {
                string lower = Path.GetExtension(file1).ToLower();
                string file2 = !Path.IsPathRooted(file1) ? Path.Combine(this._projectDirectory, file1) : file1;
                if (".dll" != lower)
                {
                    string str = "Compile";
                    stringBuilder.AppendFormat("     <{0} Include=\"{1}\" />{2}", (object)str, (object)this.EscapedRelativePathFor(file2), (object)SolutionSynchronizer.WindowsNewline);
                }
                else
                {
                    first.Add(file2);
                }
            }
            stringBuilder.Append(allAssetsProject);
            foreach (string str1 in first.Union <string>((IEnumerable <string>)island._references))
            {
                if (!str1.EndsWith("/UnityEditor.dll") && !str1.EndsWith("/UnityEngine.dll") && (!str1.EndsWith("\\UnityEditor.dll") && !str1.EndsWith("\\UnityEngine.dll")))
                {
                    Match match = SolutionSynchronizer.scriptReferenceExpression.Match(str1);
                    if (match.Success && (mode == SolutionSynchronizer.Mode.UnityScriptAsUnityProj || (int)Enum.Parse(typeof(ScriptingLanguage), match.Groups["language"].Value, true) == 2))
                    {
                        matchList.Add(match);
                    }
                    else
                    {
                        string str2 = !Path.IsPathRooted(str1) ? Path.Combine(this._projectDirectory, str1) : str1;
                        if (AssemblyHelper.IsManagedAssembly(str2) && (!AssemblyHelper.IsInternalAssembly(str2) || SolutionSynchronizer.IsInternalAssemblyThatShouldBeReferenced(isBuildingEditorProject, str2)))
                        {
                            string path = str2.Replace("\\", "/").Replace("\\\\", "/");
                            stringBuilder.AppendFormat(" <Reference Include=\"{0}\">{1}", (object)Path.GetFileNameWithoutExtension(path), (object)SolutionSynchronizer.WindowsNewline);
                            stringBuilder.AppendFormat(" <HintPath>{0}</HintPath>{1}", (object)path, (object)SolutionSynchronizer.WindowsNewline);
                            stringBuilder.AppendFormat(" </Reference>{0}", (object)SolutionSynchronizer.WindowsNewline);
                        }
                    }
                }
            }
            if (0 < matchList.Count)
            {
                stringBuilder.AppendLine("  </ItemGroup>");
                stringBuilder.AppendLine("  <ItemGroup>");
                using (List <Match> .Enumerator enumerator = matchList.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        Match  current = enumerator.Current;
                        string str     = current.Groups["project"].Value;
                        stringBuilder.AppendFormat("    <ProjectReference Include=\"{0}{1}\">{2}", (object)str, (object)SolutionSynchronizer.GetProjectExtension((ScriptingLanguage)Enum.Parse(typeof(ScriptingLanguage), current.Groups["language"].Value, true)), (object)SolutionSynchronizer.WindowsNewline);
                        stringBuilder.AppendFormat("      <Project>{{{0}}}</Project>", (object)this.ProjectGuid(Path.Combine("Temp", current.Groups["project"].Value + ".dll")), (object)SolutionSynchronizer.WindowsNewline);
                        stringBuilder.AppendFormat("      <Name>{0}</Name>", (object)str, (object)SolutionSynchronizer.WindowsNewline);
                        stringBuilder.AppendLine("    </ProjectReference>");
                    }
                }
            }
            stringBuilder.Append(this.ProjectFooter(island));
            return(stringBuilder.ToString());
        }