示例#1
0
 public static string[] GetReferences(MonoIsland island, string projectDirectory)
 {
     List<string> list = new List<string>();
     List<string> first = new List<string>();
     IEnumerator<string> enumerator = first.Union<string>(island._references).GetEnumerator();
     try
     {
         while (enumerator.MoveNext())
         {
             string current = enumerator.Current;
             string fileName = Path.GetFileName(current);
             if (string.IsNullOrEmpty(fileName) || (!fileName.Contains("UnityEditor.dll") && !fileName.Contains("UnityEngine.dll")))
             {
                 string file = !Path.IsPathRooted(current) ? Path.Combine(projectDirectory, current) : current;
                 if (AssemblyHelper.IsManagedAssembly(file) && !AssemblyHelper.IsInternalAssembly(file))
                 {
                     list.Add(file);
                 }
             }
         }
     }
     finally
     {
         if (enumerator == null)
         {
         }
         enumerator.Dispose();
     }
     return list.ToArray();
 }
示例#2
0
 public override ScriptCompilerBase CreateCompiler(MonoIsland island, bool buildingForEditor, BuildTarget targetPlatform, bool runUpdater)
 {
     CSharpCompiler compiler = GetCSharpCompiler(targetPlatform, buildingForEditor, island._output);
     if ((compiler != CSharpCompiler.Mono) && (compiler == CSharpCompiler.Microsoft))
     {
         return new MicrosoftCSharpCompiler(island, runUpdater);
     }
     return new MonoCSharpCompiler(island, runUpdater);
 }
 public override ScriptCompilerBase CreateCompiler(MonoIsland island, bool buildingForEditor, BuildTarget targetPlatform, bool runUpdater)
 {
     switch (GetCSharpCompiler(targetPlatform, buildingForEditor, island._output))
     {
         case CSharpCompiler.Microsoft:
             return new MicrosoftCSharpCompiler(island, runUpdater);
     }
     return new MonoCSharpCompiler(island, runUpdater);
 }
示例#4
0
 public static string[] Compile(string[] sources, string[] references, string[] defines, string outputFile)
 {
     MonoIsland island = new MonoIsland(BuildTarget.StandaloneWindows, "unity", sources, references, defines, outputFile);
     using (MonoCSharpCompiler compiler = new MonoCSharpCompiler(island, false))
     {
         compiler.BeginCompiling();
         while (!compiler.Poll())
         {
             Thread.Sleep(50);
         }
         if (<>f__am$cache0 == null)
         {
	public override ScriptCompilerBase CreateCompiler(MonoIsland island, bool buildingForEditor, BuildTarget targetPlatform)
	{
		// This method almost exactly copies CSharpLanguage.CreateCompiler(...)

		if (!buildingForEditor && targetPlatform.ToString().Contains("MetroPlayer") &&
			(PlayerSettings.Metro.compilationOverrides == PlayerSettings.MetroCompilationOverrides.UseNetCore ||
			 (PlayerSettings.Metro.compilationOverrides == PlayerSettings.MetroCompilationOverrides.UseNetCorePartially
			  && !island._output.Contains("Assembly-CSharp-firstpass.dll"))))
		{
			return new MicrosoftCSharpCompiler(island);
		}
		return new CustomCSharpCompiler(island, false); // MonoCSharpCompiler is replaced with CustomCSharpCompiler
	}
	public override ScriptCompilerBase CreateCompiler(MonoIsland island, bool buildingForEditor, BuildTarget targetPlatform, bool runUpdater)
	{
		// This method almost exactly copies CSharpLanguage.CreateCompiler(...)

		CSharpCompiler cSharpCompiler = GetCSharpCompiler(targetPlatform, buildingForEditor, island._output);
		if (cSharpCompiler != CSharpCompiler.Mono)
		{
			if (cSharpCompiler == CSharpCompiler.Microsoft)
			{
				return new MicrosoftCSharpCompiler(island, runUpdater);
			}
		}
		return new CustomCSharpCompiler(island, runUpdater); // MonoCSharpCompiler is replaced with CustomCSharpCompiler
	}
 internal static ScriptCompilerBase CreateCompilerInstance(MonoIsland island, bool buildingForEditor, BuildTarget targetPlatform, bool runUpdater)
 {
   if (island._files.Length == 0)
     throw new ArgumentException("Cannot compile MonoIsland with no files");
   using (List<SupportedLanguage>.Enumerator enumerator = ScriptCompilers._supportedLanguages.GetEnumerator())
   {
     while (enumerator.MoveNext())
     {
       SupportedLanguage current = enumerator.Current;
       if (current.GetExtensionICanCompile() == island.GetExtensionOfSourceFiles())
         return current.CreateCompiler(island, buildingForEditor, targetPlatform, runUpdater);
     }
   }
   throw new ApplicationException(string.Format("Unable to find a suitable compiler for sources with extension '{0}' (Output assembly: {1})", (object) island.GetExtensionOfSourceFiles(), (object) island._output));
 }
示例#8
0
 internal static ScriptCompilerBase CreateCompilerInstance(MonoIsland island, bool buildingForEditor, BuildTarget targetPlatform, bool runUpdater)
 {
     if (island._files.Length == 0)
     {
         throw new ArgumentException("Cannot compile MonoIsland with no files");
     }
     foreach (SupportedLanguage language in _supportedLanguages)
     {
         if (language.GetExtensionICanCompile() == island.GetExtensionOfSourceFiles())
         {
             return language.CreateCompiler(island, buildingForEditor, targetPlatform, runUpdater);
         }
     }
     throw new ApplicationException(string.Format("Unable to find a suitable compiler for sources with extension '{0}' (Output assembly: {1})", island.GetExtensionOfSourceFiles(), island._output));
 }
 public bool ProjectExists(MonoIsland island)
 {
   return File.Exists(this.ProjectFile(island));
 }
示例#10
0
 protected ScriptCompilerBase(MonoIsland island)
 {
     this._island = island;
 }
 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);
   }
 }
		public string ProjectFile(MonoIsland island, bool forVisualStudio)
		{
			ScriptingLanguage key = SolutionSynchronizer.SupportedExtensions[island.GetExtensionOfSourceFiles()];
			string arg = (!forVisualStudio) ? string.Empty : this.vsstub;
			return Path.Combine(this._projectDirectory, string.Format("{0}{1}{2}", Path.GetFileNameWithoutExtension(island._output), arg, SolutionSynchronizer.ProjectExtensions[key]));
		}
		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 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();
 }
示例#15
0
        internal static ScriptCompilerBase CreateCompilerInstance(ScriptAssembly scriptAssembly, MonoIsland island, bool buildingForEditor, BuildTarget targetPlatform, bool runUpdater)
        {
            if (island._files.Length == 0)
            {
                throw new ArgumentException("Cannot compile MonoIsland with no files");
            }

            foreach (var lang in SupportedLanguages)
            {
                if (lang.GetExtensionICanCompile() == island.GetExtensionOfSourceFiles())
                {
                    return(lang.CreateCompiler(scriptAssembly, island, buildingForEditor, targetPlatform, runUpdater));
                }
            }

            throw new ApplicationException(string.Format("Unable to find a suitable compiler for sources with extension '{0}' (Output assembly: {1})", island.GetExtensionOfSourceFiles(), island._output));
        }
		private string ProjectFooter(MonoIsland island)
		{
			ScriptingLanguage language = SolutionSynchronizer.SupportedExtensions[island.GetExtensionOfSourceFiles()];
			return string.Format(this._settings.GetProjectFooterTemplate(language), this.ReadExistingMonoDevelopProjectProperties(island));
		}
		private string ProjectHeader(MonoIsland island)
		{
			string text = "4.0";
			string text2 = "10.0.20506";
			ScriptingLanguage language = SolutionSynchronizer.SupportedExtensions[island.GetExtensionOfSourceFiles()];
			if (this._settings.VisualStudioVersion == 9)
			{
				text = "3.5";
				text2 = "9.0.21022";
			}
			return string.Format(this._settings.GetProjectHeaderTemplate(language), new object[]
			{
				text,
				text2,
				this.ProjectGuid(island._output),
				this._settings.EngineAssemblyPath,
				this._settings.EditorAssemblyPath,
				string.Join(";", this._settings.Defines.Union(island._defines).ToArray<string>()),
				SolutionSynchronizer.MSBuildNamespaceUri,
				Path.GetFileNameWithoutExtension(island._output)
			});
		}
示例#18
0
 public override ScriptCompilerBase CreateCompiler(MonoIsland island, bool buildingForEditor, BuildTarget targetPlatform, bool runUpdater)
 {
     return new BooCompiler(island, runUpdater);
 }
 private string ReadExistingMonoDevelopProjectProperties(MonoIsland island)
 {
   if (!this.ProjectExists(island))
     return string.Empty;
   XmlDocument xmlDocument = new XmlDocument();
   XmlNamespaceManager nsmgr;
   try
   {
     xmlDocument.Load(this.ProjectFile(island));
     nsmgr = new XmlNamespaceManager(xmlDocument.NameTable);
     nsmgr.AddNamespace("msb", SolutionSynchronizer.MSBuildNamespaceUri);
   }
   catch (Exception ex)
   {
     if (ex is IOException || ex is XmlException)
       return string.Empty;
     throw;
   }
   XmlNodeList xmlNodeList = xmlDocument.SelectNodes("/msb:Project/msb:ProjectExtensions", nsmgr);
   if (xmlNodeList.Count == 0)
     return string.Empty;
   StringBuilder stringBuilder = new StringBuilder();
   foreach (XmlNode xmlNode in xmlNodeList)
     stringBuilder.AppendLine(xmlNode.OuterXml);
   return stringBuilder.ToString();
 }
 private void SyncProject(MonoIsland island, string otherAssetsProjectPart)
 {
   SolutionSynchronizer.SyncFileIfNotChanged(this.ProjectFile(island), this.ProjectText(island, SolutionSynchronizer.ModeForCurrentExternalEditor(), otherAssetsProjectPart));
 }
		private string ProjectText(MonoIsland island, bool forVisualStudio, 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;
					if ((match = SolutionSynchronizer.scriptReferenceExpression.Match(current)) != null && match.Success && (!forVisualStudio || (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 text4 = current2.Groups["project"].Value;
					if (forVisualStudio)
					{
						text4 += this.vsstub;
					}
					stringBuilder.AppendFormat("    <ProjectReference Include=\"{0}{1}\">{2}", text4, 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>", text4, SolutionSynchronizer.WindowsNewline);
					stringBuilder.AppendLine("    </ProjectReference>");
				}
			}
			stringBuilder.Append(this.ProjectFooter(island));
			return stringBuilder.ToString();
		}
 public string ProjectFile(MonoIsland island)
 {
   ScriptingLanguage index = SolutionSynchronizer.ScriptingLanguageFor(island);
   return Path.Combine(this._projectDirectory, string.Format("{0}{1}", (object) Path.GetFileNameWithoutExtension(island._output), (object) SolutionSynchronizer.ProjectExtensions[index]));
 }
示例#23
0
 public BooCompiler(MonoIsland island, bool runUpdater) : base(island, runUpdater)
 {
 }
 private string ProjectFooter(MonoIsland island)
 {
   return string.Format(this._settings.GetProjectFooterTemplate(SolutionSynchronizer.ScriptingLanguageFor(island)), (object) this.ReadExistingMonoDevelopProjectProperties(island));
 }
	public CustomCSharpCompiler(MonoIsland island, bool runUpdater) : base(island)
	{
	}
 private static ScriptingLanguage ScriptingLanguageFor(MonoIsland island)
 {
   return SolutionSynchronizer.ScriptingLanguageFor(island.GetExtensionOfSourceFiles());
 }
示例#27
0
 public MonoCSharpCompiler(MonoIsland island, bool runUpdater) : base(island, runUpdater)
 {
 }
 private static void DumpIsland(MonoIsland island)
 {
   Console.WriteLine("{0} ({1})", (object) island._output, (object) island._classlib_profile);
   Console.WriteLine("Files: ");
   Console.WriteLine(string.Join("\n", island._files));
   Console.WriteLine("References: ");
   Console.WriteLine(string.Join("\n", island._references));
   Console.WriteLine(string.Empty);
 }
 public UnityScriptCompiler(MonoIsland island, bool runUpdater) : base(island, runUpdater)
 {
 }
示例#30
0
 public abstract ScriptCompilerBase CreateCompiler(MonoIsland island, bool buildingForEditor, BuildTarget targetPlatform, bool runUpdater);
 protected MonoScriptCompilerBase(MonoIsland island, bool runUpdater) : base(island)
 {
     this.runUpdater = runUpdater;
 }