Пример #1
0
 public void Sync()
 {
     this.SetupProjectSupportedExtensions();
     if (!AssetPostprocessingInternal.OnPreGeneratingCSProjectFiles())
     {
         ScriptEditorUtility.ScriptEditor scriptEditorFromPreferences = ScriptEditorUtility.GetScriptEditorFromPreferences();
         if (scriptEditorFromPreferences == ScriptEditorUtility.ScriptEditor.SystemDefault || scriptEditorFromPreferences == ScriptEditorUtility.ScriptEditor.Other)
         {
             return;
         }
         IEnumerable <MonoIsland> islands = from i in EditorCompilationInterface.GetAllMonoIslands()
                                            where 0 < i._files.Length && i._files.Any((string f) => this.ShouldFileBePartOfSolution(f))
                                            select i;
         Dictionary <string, string> allAssetsProjectParts = this.GenerateAllAssetProjectParts();
         string[] responseFileDefinesFromFile = ScriptCompilerBase.GetResponseFileDefinesFromFile(MonoCSharpCompiler.ReponseFilename);
         this.SyncSolution(islands);
         List <MonoIsland> list = SolutionSynchronizer.RelevantIslandsForMode(islands, SolutionSynchronizer.ModeForCurrentExternalEditor()).ToList <MonoIsland>();
         foreach (MonoIsland current in list)
         {
             this.SyncProject(current, allAssetsProjectParts, responseFileDefinesFromFile, list);
         }
         if (scriptEditorFromPreferences == ScriptEditorUtility.ScriptEditor.VisualStudioCode)
         {
             this.WriteVSCodeSettingsFiles();
         }
     }
     AssetPostprocessingInternal.CallOnGeneratedCSProjectFiles();
 }
        private string ProjectHeader(MonoIsland island)
        {
            string            str1     = "4.0";
            string            str2     = "10.0.20506";
            ScriptingLanguage language = SolutionSynchronizer.ScriptingLanguageFor(island);

            if (this._settings.VisualStudioVersion == 9)
            {
                str1 = "3.5";
                str2 = "9.0.21022";
            }
            object[] objArray = new object[9] {
                (object)str1, (object)str2, (object)this.ProjectGuid(island._output), (object)this._settings.EngineAssemblyPath, (object)this._settings.EditorAssemblyPath, (object)string.Join(";", ((IEnumerable <string>) new string[2] {
                    "DEBUG", "TRACE"
                }).Concat <string>((IEnumerable <string>) this._settings.Defines).Concat <string>((IEnumerable <string>)island._defines).Distinct <string>().ToArray <string>()), (object)SolutionSynchronizer.MSBuildNamespaceUri, (object)Path.GetFileNameWithoutExtension(island._output), (object)EditorSettings.projectGenerationRootNamespace
            };
            try
            {
                return(string.Format(this._settings.GetProjectHeaderTemplate(language), objArray));
            }
            catch (Exception ex)
            {
                throw new NotSupportedException("Failed creating c# project because the c# project header did not have the correct amount of arguments, which is " + (object)objArray.Length);
            }
        }
Пример #3
0
        private string ProjectHeader(MonoIsland island, string[] additionalDefines)
        {
            string            text     = "v3.5";
            string            text2    = "4";
            string            text3    = "4.0";
            string            text4    = "10.0.20506";
            string            text5    = ".";
            ScriptingLanguage language = SolutionSynchronizer.ScriptingLanguageFor(island);

            if (PlayerSettingsEditor.IsLatestApiCompatibility(island._api_compatibility_level))
            {
                text  = "v4.6";
                text2 = "6";
            }
            else if (ScriptEditorUtility.GetScriptEditorFromPreferences() == ScriptEditorUtility.ScriptEditor.Rider)
            {
                text = "v4.5";
            }
            else if (this._settings.VisualStudioVersion == 9)
            {
                text3 = "3.5";
                text4 = "9.0.21022";
            }
            object[] array = new object[]
            {
                text3,
                text4,
                this.ProjectGuid(island._output),
                this._settings.EngineAssemblyPath,
                this._settings.EditorAssemblyPath,
                string.Join(";", new string[]
                {
                    "DEBUG",
                    "TRACE"
                }.Concat(this._settings.Defines).Concat(island._defines).Concat(additionalDefines).Distinct <string>().ToArray <string>()),
                SolutionSynchronizer.MSBuildNamespaceUri,
                Path.GetFileNameWithoutExtension(island._output),
                EditorSettings.projectGenerationRootNamespace,
                text,
                text2,
                text5
            };
            string result;

            try
            {
                result = string.Format(this._settings.GetProjectHeaderTemplate(language), array);
            }
            catch (Exception)
            {
                throw new NotSupportedException("Failed creating c# project because the c# project header did not have the correct amount of arguments, which is " + array.Length);
            }
            return(result);
        }
 private static SolutionSynchronizer.Mode ModeForCurrentExternalEditor()
 {
     if (SolutionSynchronizer.IsSelectedEditorVisualStudio())
     {
         return(SolutionSynchronizer.Mode.UntiyScriptAsPrecompiledAssembly);
     }
     if (SolutionSynchronizer.IsSelectedEditorInternalMonoDevelop())
     {
         return(SolutionSynchronizer.Mode.UnityScriptAsUnityProj);
     }
     return((!EditorPrefs.GetBool("kExternalEditorSupportsUnityProj", false)) ? SolutionSynchronizer.Mode.UntiyScriptAsPrecompiledAssembly : SolutionSynchronizer.Mode.UnityScriptAsUnityProj);
 }
        private string GenerateAllAssetProjectPart()
        {
            StringBuilder stringBuilder = new StringBuilder();

            foreach (string allAssetPath in AssetDatabase.GetAllAssetPaths())
            {
                string extension = Path.GetExtension(allAssetPath);
                if (this.IsSupportedExtension(extension) && SolutionSynchronizer.ScriptingLanguageFor(extension) == ScriptingLanguage.None)
                {
                    stringBuilder.AppendFormat("     <None Include=\"{0}\" />{1}", (object)this.EscapedRelativePathFor(allAssetPath), (object)SolutionSynchronizer.WindowsNewline);
                }
            }
            return(stringBuilder.ToString());
        }
        private string SolutionText(IEnumerable <MonoIsland> islands, SolutionSynchronizer.Mode mode)
        {
            string str1 = "11.00";

            if (this._settings.VisualStudioVersion == 9)
            {
                str1 = "10.00";
            }
            IEnumerable <MonoIsland> monoIslands = SolutionSynchronizer.RelevantIslandsForMode(islands, mode);
            string projectEntries = this.GetProjectEntries(monoIslands);
            string str2           = string.Join(SolutionSynchronizer.WindowsNewline, monoIslands.Select <MonoIsland, string>((Func <MonoIsland, string>)(i => this.GetProjectActiveConfigurations(this.ProjectGuid(i._output)))).ToArray <string>());

            return(string.Format(this._settings.SolutionTemplate, (object)str1, (object)projectEntries, (object)str2, (object)this.ReadExistingMonoDevelopSolutionProperties()));
        }
Пример #7
0
        private Dictionary <string, string> GenerateAllAssetProjectParts()
        {
            Dictionary <string, StringBuilder> dictionary = new Dictionary <string, StringBuilder>();

            string[] allAssetPaths = AssetDatabase.GetAllAssetPaths();
            int      i             = 0;

            while (i < allAssetPaths.Length)
            {
                string text = allAssetPaths[i];
                if (!AssetDatabase.IsPackagedAssetPath(text))
                {
                    goto IL_4B;
                }
                string text2 = Path.GetFullPath(text).ConvertSeparatorsToUnity();
                if (text2.StartsWith(this._projectDirectory))
                {
                    goto IL_4B;
                }
IL_FE:
                i++;
                continue;
IL_4B:
                string extension = Path.GetExtension(text);
                if (this.IsSupportedExtension(extension) && SolutionSynchronizer.ScriptingLanguageFor(extension) == ScriptingLanguage.None)
                {
                    string text3 = CompilationPipeline.GetAssemblyNameFromScriptPath(text + ".cs");
                    text3 = (text3 ?? CompilationPipeline.GetAssemblyNameFromScriptPath(text + ".js"));
                    text3 = (text3 ?? CompilationPipeline.GetAssemblyNameFromScriptPath(text + ".boo"));
                    text3 = Path.GetFileNameWithoutExtension(text3);
                    StringBuilder stringBuilder = null;
                    if (!dictionary.TryGetValue(text3, out stringBuilder))
                    {
                        stringBuilder     = new StringBuilder();
                        dictionary[text3] = stringBuilder;
                    }
                    stringBuilder.AppendFormat("     <None Include=\"{0}\" />{1}", this.EscapedRelativePathFor(text), SolutionSynchronizer.WindowsNewline);
                }
                goto IL_FE;
            }
            Dictionary <string, string> dictionary2 = new Dictionary <string, string>();

            foreach (KeyValuePair <string, StringBuilder> current in dictionary)
            {
                dictionary2[current.Key] = current.Value.ToString();
            }
            return(dictionary2);
        }
        private string GenerateAllAssetProjectPart()
        {
            StringBuilder stringBuilder = new StringBuilder();

            string[] allAssetPaths = AssetDatabase.GetAllAssetPaths();
            for (int i = 0; i < allAssetPaths.Length; i++)
            {
                string text      = allAssetPaths[i];
                string extension = Path.GetExtension(text);
                if (this.IsSupportedExtension(extension) && SolutionSynchronizer.ScriptingLanguageFor(extension) == ScriptingLanguage.None)
                {
                    stringBuilder.AppendFormat("     <None Include=\"{0}\" />{1}", this.EscapedRelativePathFor(text), SolutionSynchronizer.WindowsNewline);
                }
            }
            return(stringBuilder.ToString());
        }
 public void Sync()
 {
     this.SetupProjectSupportedExtensions();
     if (!AssetPostprocessingInternal.OnPreGeneratingCSProjectFiles())
     {
         IEnumerable <MonoIsland> islands = from i in InternalEditorUtility.GetMonoIslands()
                                            where 0 < i._files.Length
                                            select i;
         string otherAssetsProjectPart = this.GenerateAllAssetProjectPart();
         this.SyncSolution(islands);
         foreach (MonoIsland current in SolutionSynchronizer.RelevantIslandsForMode(islands, SolutionSynchronizer.ModeForCurrentExternalEditor()))
         {
             this.SyncProject(current, otherAssetsProjectPart);
         }
     }
     AssetPostprocessingInternal.CallOnGeneratedCSProjectFiles();
 }
        public void Sync()
        {
            this.SetupProjectSupportedExtensions();
            if (AssetPostprocessingInternal.OnPreGeneratingCSProjectFiles())
            {
                return;
            }
            IEnumerable <MonoIsland> islands = ((IEnumerable <MonoIsland>)InternalEditorUtility.GetMonoIslands()).Where <MonoIsland>((Func <MonoIsland, bool>)(i => 0 < i._files.Length));
            string assetProjectPart          = this.GenerateAllAssetProjectPart();

            this.SyncSolution(islands);
            foreach (MonoIsland island in SolutionSynchronizer.RelevantIslandsForMode(islands, SolutionSynchronizer.ModeForCurrentExternalEditor()))
            {
                this.SyncProject(island, assetProjectPart);
            }
            AssetPostprocessingInternal.CallOnGeneratedCSProjectFiles();
        }
        private string SolutionText(IEnumerable <MonoIsland> islands, SolutionSynchronizer.Mode mode)
        {
            string text = "11.00";

            if (this._settings.VisualStudioVersion == 9)
            {
                text = "10.00";
            }
            IEnumerable <MonoIsland> enumerable = SolutionSynchronizer.RelevantIslandsForMode(islands, mode);
            string projectEntries = this.GetProjectEntries(enumerable);
            string text2          = string.Join(SolutionSynchronizer.WindowsNewline, (from i in enumerable
                                                                                      select this.GetProjectActiveConfigurations(this.ProjectGuid(i._output))).ToArray <string>());

            return(string.Format(this._settings.SolutionTemplate, new object[]
            {
                text,
                projectEntries,
                text2,
                this.ReadExistingMonoDevelopSolutionProperties()
            }));
        }
        private string ProjectHeader(MonoIsland island)
        {
            string            text     = "4.0";
            string            text2    = "10.0.20506";
            ScriptingLanguage language = SolutionSynchronizer.ScriptingLanguageFor(island);

            if (this._settings.VisualStudioVersion == 9)
            {
                text  = "3.5";
                text2 = "9.0.21022";
            }
            object[] array = new object[]
            {
                text,
                text2,
                this.ProjectGuid(island._output),
                this._settings.EngineAssemblyPath,
                this._settings.EditorAssemblyPath,
                string.Join(";", new string[]
                {
                    "DEBUG",
                    "TRACE"
                }.Concat(this._settings.Defines).Concat(island._defines).Distinct <string>().ToArray <string>()),
                SolutionSynchronizer.MSBuildNamespaceUri,
                Path.GetFileNameWithoutExtension(island._output),
                EditorSettings.projectGenerationRootNamespace
            };
            string result;

            try
            {
                result = string.Format(this._settings.GetProjectHeaderTemplate(language), array);
            }
            catch (Exception)
            {
                throw new NotSupportedException("Failed creating c# project because the c# project header did not have the correct amount of arguments, which is " + array.Length);
            }
            return(result);
        }
Пример #13
0
 public void Sync()
 {
     this.SetupProjectSupportedExtensions();
     if (!AssetPostprocessingInternal.OnPreGeneratingCSProjectFiles())
     {
         IEnumerable <MonoIsland> islands = from i in InternalEditorUtility.GetMonoIslands()
                                            where 0 < i._files.Length
                                            select i;
         string   otherAssetsProjectPart      = this.GenerateAllAssetProjectPart();
         string[] responseFileDefinesFromFile = ScriptCompilerBase.GetResponseFileDefinesFromFile(MonoCSharpCompiler.ReponseFilename);
         this.SyncSolution(islands);
         foreach (MonoIsland current in SolutionSynchronizer.RelevantIslandsForMode(islands, SolutionSynchronizer.ModeForCurrentExternalEditor()))
         {
             this.SyncProject(current, otherAssetsProjectPart, responseFileDefinesFromFile);
         }
         if (ScriptEditorUtility.GetScriptEditorFromPreferences() == ScriptEditorUtility.ScriptEditor.VisualStudioCode)
         {
             this.WriteVSCodeSettingsFiles();
         }
     }
     AssetPostprocessingInternal.CallOnGeneratedCSProjectFiles();
 }
 private static IEnumerable <MonoIsland> RelevantIslandsForMode(IEnumerable <MonoIsland> islands, SolutionSynchronizer.Mode mode)
 {
     return(from i in islands
            where mode == SolutionSynchronizer.Mode.UnityScriptAsUnityProj || ScriptingLanguage.CSharp == SolutionSynchronizer.ScriptingLanguageFor(i)
            select i);
 }
        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());
        }
 private void SyncSolution(IEnumerable <MonoIsland> islands)
 {
     SolutionSynchronizer.SyncFileIfNotChanged(this.SolutionFile(), this.SolutionText(islands, SolutionSynchronizer.ModeForCurrentExternalEditor()));
 }
Пример #17
0
 private void SyncProject(MonoIsland island, Dictionary <string, string> allAssetsProjectParts, string[] additionalDefines, List <MonoIsland> allProjectIslands)
 {
     SolutionSynchronizer.SyncFileIfNotChanged(this.ProjectFile(island), this.ProjectText(island, SolutionSynchronizer.ModeForCurrentExternalEditor(), allAssetsProjectParts, additionalDefines, allProjectIslands));
 }
 private string SolutionText(IEnumerable<MonoIsland> islands, SolutionSynchronizer.Mode mode)
 {
   string str1 = "11.00";
   if (this._settings.VisualStudioVersion == 9)
     str1 = "10.00";
   IEnumerable<MonoIsland> monoIslands = SolutionSynchronizer.RelevantIslandsForMode(islands, mode);
   string projectEntries = this.GetProjectEntries(monoIslands);
   string str2 = string.Join(SolutionSynchronizer.WindowsNewline, monoIslands.Select<MonoIsland, string>((Func<MonoIsland, string>) (i => this.GetProjectActiveConfigurations(this.ProjectGuid(i._output)))).ToArray<string>());
   return string.Format(this._settings.SolutionTemplate, (object) str1, (object) projectEntries, (object) str2, (object) this.ReadExistingMonoDevelopSolutionProperties());
 }
Пример #19
0
		static SyncVS()
		{
			SyncVS.Synchronizer = new SolutionSynchronizer(Directory.GetParent(Application.dataPath).FullName, new SyncVS.SolutionSynchronizationSettings());
			EditorUserBuildSettings.activeBuildTargetChanged = (Action)Delegate.Combine(EditorUserBuildSettings.activeBuildTargetChanged, new Action(SyncVS.SyncVisualStudioProjectIfItAlreadyExists));
			try
			{
				SyncVS.InstalledVisualStudios = (SyncVS.GetInstalledVisualStudios() as Dictionary<VisualStudioVersion, string>);
			}
			catch (Exception ex)
			{
				Console.WriteLine("Error detecting Visual Studio installations: {0}{1}{2}", ex.Message, Environment.NewLine, ex.StackTrace);
				SyncVS.InstalledVisualStudios = new Dictionary<VisualStudioVersion, string>();
			}
		}
 private void SyncProject(MonoIsland island, string otherAssetsProjectPart)
 {
     SolutionSynchronizer.SyncFileIfNotChanged(this.ProjectFile(island), this.ProjectText(island, SolutionSynchronizer.ModeForCurrentExternalEditor(), otherAssetsProjectPart));
 }
Пример #21
0
 public static void OnGeneratedCSProjectFiles()
 {
     if (UnityVSSupport.IsUnityVSEnabled())
     {
         try
         {
             string   currentDirectory = Directory.GetCurrentDirectory();
             string[] files            = Directory.GetFiles(currentDirectory, string.Format("*{0}", SolutionSynchronizer.GetProjectExtension(ScriptingLanguage.CSharp)), SearchOption.TopDirectoryOnly);
             string[] array            = files;
             for (int i = 0; i < array.Length; i++)
             {
                 string text        = array[i];
                 string projectFile = text.Substring(currentDirectory.Length + 1);
                 SolutionPostProcessor.ReplacePathsInProjectFile(projectFile, currentDirectory);
             }
         }
         catch (Exception ex)
         {
             Debug.LogWarning("Post processing of CS project files failed, reason: " + ex.Message);
         }
     }
 }
 private static ScriptingLanguage ScriptingLanguageFor(MonoIsland island)
 {
     return(SolutionSynchronizer.ScriptingLanguageFor(island.GetExtensionOfSourceFiles()));
 }
 private void SyncSolution(IEnumerable <MonoIsland> islands)
 {
     SolutionSynchronizer.SyncFileIfNotChanged(this.SolutionFile(false), this.SolutionText(islands, false));
     SolutionSynchronizer.SyncFileIfNotChanged(this.SolutionFile(true), this.SolutionText(islands, true));
 }
 private void SyncProject(MonoIsland island, string otherAssetsProjectPart)
 {
     SolutionSynchronizer.SyncFileIfNotChanged(this.ProjectFile(island, false), this.ProjectText(island, false, otherAssetsProjectPart));
     SolutionSynchronizer.SyncFileIfNotChanged(this.ProjectFile(island, true), this.ProjectText(island, true, otherAssetsProjectPart));
 }
 private string ProjectFooter(MonoIsland island)
 {
     return(string.Format(this._settings.GetProjectFooterTemplate(SolutionSynchronizer.ScriptingLanguageFor(island)), this.ReadExistingMonoDevelopProjectProperties(island)));
 }
Пример #26
0
        /// <summary>
        /// Callback from AssetPostprocessor which is called after CSProj file(s) are generated.
        /// </summary>
        public static void OnGeneratedCSProjectFiles()
        {
            if (!UnityVSSupport.IsUnityVSEnabled())
            {
                return;
            }

            try
            {
                var projectDir   = Directory.GetCurrentDirectory();
                var projectFiles = Directory.GetFiles(projectDir, string.Format("*{0}", SolutionSynchronizer.GetProjectExtension(ScriptingLanguage.CSharp)), SearchOption.TopDirectoryOnly);
                foreach (string projectFile in projectFiles)
                {
                    var file = projectFile.Substring(projectDir.Length + 1);
                    ReplacePathsInProjectFile(file, projectDir);
                }
            }
            catch (Exception e)
            {
                UnityEngine.Debug.LogWarning("Post processing of CS project files failed, reason: " + e.Message);
            }
        }
        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>();

            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))
                            {
                                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();
 }
        public string ProjectFile(MonoIsland island)
        {
            ScriptingLanguage key = SolutionSynchronizer.ScriptingLanguageFor(island);

            return(Path.Combine(this._projectDirectory, string.Format("{0}{1}", Path.GetFileNameWithoutExtension(island._output), SolutionSynchronizer.ProjectExtensions[key])));
        }
 private static IEnumerable<MonoIsland> RelevantIslandsForMode(IEnumerable<MonoIsland> islands, SolutionSynchronizer.Mode mode)
 {
   // ISSUE: object of a compiler-generated type is created
   // ISSUE: reference to a compiler-generated method
   return islands.Where<MonoIsland>(new Func<MonoIsland, bool>(new SolutionSynchronizer.\u003CRelevantIslandsForMode\u003Ec__AnonStoreyC3() { mode = mode }.\u003C\u003Em__235));
 }
Пример #31
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());
        }