static void ProcessReferences (DotNetAssemblyProject project, MonoIsland update) { var referencesToAdd = update.References.Where (r => project.References.All(r2 => r2.Reference != r)).ToArray (); foreach (var reference in referencesToAdd) project.References.Add (ProjectReferenceFor (reference)); var referencesToRemove = project.References.Where (r => update.References.All(r2 => r.Reference != r2)).ToArray (); project.References.RemoveRange (referencesToRemove); }
static void ProcessDefines (DotNetAssemblyProject project, MonoIsland update) { var compilationParameters = (CSharpCompilerParameters)((DotNetProjectConfiguration)project.DefaultConfiguration).CompilationParameters; var toAdd = update.Defines.Where (d => !compilationParameters.HasDefineSymbol (d)).ToArray (); var toRemove = compilationParameters.GetDefineSymbols().Where (d => !update.Defines.Contains (d)).ToArray (); foreach (var define in toAdd) compilationParameters.AddDefineSymbol (define); foreach (var define in toRemove) compilationParameters.RemoveDefineSymbol (define); }
public void TestSetup() { _project = new DotNetAssemblyProject ("C#"); var p = new CSharpCompilerParameters (); var config = new DotNetProjectConfiguration () { CompilationParameters = p }; _project.DefaultConfiguration = config; _update = new MonoIsland (); _update.BaseDirectory = "/mybase"; }
static void ProcessFiles (DotNetAssemblyProject project, MonoIsland update) { var updateFiles = update.Files.Select (f => Path.GetFullPath(project.BaseDirectory + "/" + f)).ToArray(); var toRemove = project.Files.Where (f => updateFiles.All(f2 => f.FilePath.FullPath != f2)).ToArray (); var toAdd = updateFiles.Where(f => project.Files.All(f2 => f2.FilePath.FullPath != f)).ToArray(); if(toRemove.Length > 0) project.Files.RemoveRange (toRemove); if(toAdd.Length > 0) project.AddFiles (toAdd.Select (f => new FilePath (f))); }
public static void Update (DotNetAssemblyProject project, MonoIsland update) { if (update.BaseDirectory != project.BaseDirectory) project.BaseDirectory = update.BaseDirectory; ProcessFiles (project, update); ProcessDefines (project, update); ProcessReferences (project, update); project.Name = update.Name; var dotNetProjectConfiguration = ((DotNetProjectConfiguration)project.DefaultConfiguration); dotNetProjectConfiguration.OutputAssembly = project.Name + ".dll"; }
public void UpdateWithProjectThatReferencesOtherProject() { var project1 = new MonoIsland () { Name = "p1", Language = "C#" }; _update.Islands.Add (project1); var project2 = new MonoIsland () { Name = "p2", Language = "C#", References = new List<string> { "p1" } }; _update.Islands.Add (project2); DoUpdate (); Assert.AreEqual (2, MDProjects.Length); var p1 = MDProjects.Single (p => p.Name == "p1"); var p2 = MDProjects.Single (p => p.Name == "p2"); //assertion in form of .Single(); p2.References.Single (pr => pr.ReferenceType == ReferenceType.Project && pr.Reference == p1.Name); }
static DotNetAssemblyProject CreateMonoDevelopProjectFromProjectUpdate (UnitySolution solution, MonoIsland projectUpdate) { var p = new DotNetAssemblyProject (projectUpdate.Language); // FIXME switch (projectUpdate.Language) { default: var dotNetProjectConfig = (DotNetProjectConfiguration)p.AddNewConfiguration ("Debug"); dotNetProjectConfig.CompilationParameters = new CSharpCompilerParameters(); p.DefaultConfiguration = dotNetProjectConfig; break; } var rootFolder = solution.RootFolder; rootFolder.AddItem (p); solution.DefaultConfiguration.AddItem (p).Build = true; return p; }