43 changed files with 409 additions and 487 deletions
@ -0,0 +1,116 @@
@@ -0,0 +1,116 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Project |
||||
{ |
||||
/// <summary>
|
||||
/// Represents a mapping between solution and project configurations.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is a simple storage class - just a dictionary of the mappings.
|
||||
/// This class is thread-safe.
|
||||
/// </remarks>
|
||||
public class ConfigurationMapping |
||||
{ |
||||
class Entry |
||||
{ |
||||
public ConfigurationAndPlatform Config; |
||||
public bool Build = true; |
||||
|
||||
public Entry(ConfigurationAndPlatform config) |
||||
{ |
||||
this.Config = config; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// The configuration mapping was changed.
|
||||
/// </summary>
|
||||
public event EventHandler Changed; |
||||
|
||||
Dictionary<ConfigurationAndPlatform, Entry> dict = new Dictionary<ConfigurationAndPlatform, Entry>(); |
||||
|
||||
Entry GetOrCreateEntry(ConfigurationAndPlatform solutionConfiguration) |
||||
{ |
||||
Entry entry; |
||||
if (!dict.TryGetValue(solutionConfiguration, out entry)) { |
||||
var config = new ConfigurationAndPlatform(solutionConfiguration.Configuration, MSBuildInternals.FixPlatformNameForProject(solutionConfiguration.Platform)); |
||||
entry = new Entry(config); |
||||
dict.Add(solutionConfiguration, entry); |
||||
} |
||||
return entry; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the project configuration corresponding to the given solution configuration.
|
||||
/// </summary>
|
||||
public ConfigurationAndPlatform GetProjectConfiguration(ConfigurationAndPlatform solutionConfiguration) |
||||
{ |
||||
lock (dict) { |
||||
Entry entry; |
||||
if (dict.TryGetValue(solutionConfiguration, out entry)) { |
||||
return entry.Config; |
||||
} else { |
||||
return new ConfigurationAndPlatform(solutionConfiguration.Configuration, MSBuildInternals.FixPlatformNameForProject(solutionConfiguration.Platform)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Sets the project configuration corresponding to the given solution configuration.
|
||||
/// </summary>
|
||||
public void SetProjectConfiguration(ConfigurationAndPlatform solutionConfiguration, ConfigurationAndPlatform projectConfiguration) |
||||
{ |
||||
if (string.IsNullOrEmpty(projectConfiguration.Configuration)) |
||||
throw new ArgumentException("Invalid project configuration"); |
||||
if (string.IsNullOrEmpty(projectConfiguration.Platform) || projectConfiguration.Platform == "Any CPU") |
||||
throw new ArgumentException("Invalid project platform"); |
||||
lock (dict) { |
||||
GetOrCreateEntry(solutionConfiguration).Config = projectConfiguration; |
||||
} |
||||
Changed(this, EventArgs.Empty); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets whether building the project is enabled in the given solution configuration.
|
||||
/// </summary>
|
||||
public bool IsBuildEnabled(ConfigurationAndPlatform solutionConfiguration) |
||||
{ |
||||
lock (dict) { |
||||
Entry entry; |
||||
if (dict.TryGetValue(solutionConfiguration, out entry)) { |
||||
return entry.Build; |
||||
} else { |
||||
return true; |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Sets whether building the project is enabled in the given solution configuration.
|
||||
/// </summary>
|
||||
public void SetBuildEnabled(ConfigurationAndPlatform solutionConfiguration, bool value) |
||||
{ |
||||
lock (dict) { |
||||
GetOrCreateEntry(solutionConfiguration).Build = value; |
||||
} |
||||
Changed(this, EventArgs.Empty); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Removes all data stored about the specified solution configuration.
|
||||
/// </summary>
|
||||
public void Remove(ConfigurationAndPlatform solutionConfiguration) |
||||
{ |
||||
bool result; |
||||
lock (dict) { |
||||
result = dict.Remove(solutionConfiguration); |
||||
} |
||||
if (result) |
||||
Changed(this, EventArgs.Empty); |
||||
} |
||||
} |
||||
} |
@ -1,33 +0,0 @@
@@ -1,33 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Project |
||||
{ |
||||
/// <summary>
|
||||
/// Represents a mapping between solution and project configurations.
|
||||
/// </summary>
|
||||
public interface IConfigurationMapping |
||||
{ |
||||
/// <summary>
|
||||
/// Gets the project configuration corresponding to the given solution configuration.
|
||||
/// </summary>
|
||||
ConfigurationAndPlatform GetProjectConfiguration(ConfigurationAndPlatform solutionConfiguration); |
||||
|
||||
/// <summary>
|
||||
/// Sets the project configuration corresponding to the given solution configuration.
|
||||
/// </summary>
|
||||
void SetProjectConfiguration(ConfigurationAndPlatform solutionConfiguration, ConfigurationAndPlatform projectConfiguration); |
||||
|
||||
/// <summary>
|
||||
/// Gets whether building the project is enabled in the given solution configuration.
|
||||
/// </summary>
|
||||
bool IsBuildEnabled(ConfigurationAndPlatform solutionConfiguration); |
||||
|
||||
/// <summary>
|
||||
/// Sets whether building the project is enabled in the given solution configuration.
|
||||
/// </summary>
|
||||
void SetBuildEnabled(ConfigurationAndPlatform solutionConfiguration, bool value); |
||||
} |
||||
} |
@ -0,0 +1,96 @@
@@ -0,0 +1,96 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Project |
||||
{ |
||||
/// <summary>
|
||||
/// Base class for <see cref="ProjectCreateInformation"/> and <see cref="ProjectLoadInformation"/>.
|
||||
/// </summary>
|
||||
public class ProjectInformation |
||||
{ |
||||
public ProjectInformation(ISolution solution, FileName fileName) |
||||
{ |
||||
if (solution == null) |
||||
throw new ArgumentNullException("solution"); |
||||
if (fileName == null) |
||||
throw new ArgumentNullException("fileName"); |
||||
this.Solution = solution; |
||||
this.FileName = fileName; |
||||
this.ProjectName = fileName.GetFileNameWithoutExtension(); |
||||
this.ProjectSections = new List<SolutionSection>(); |
||||
this.ConfigurationMapping = new ConfigurationMapping(); |
||||
var solutionConfig = solution.ActiveConfiguration; |
||||
// In unit tests, ActiveConfiguration mayb return null
|
||||
if (solutionConfig.Configuration != null && solutionConfig.Platform != null) |
||||
this.ActiveProjectConfiguration = this.ConfigurationMapping.GetProjectConfiguration(solution.ActiveConfiguration); |
||||
else |
||||
this.ActiveProjectConfiguration = new ConfigurationAndPlatform("Debug", "AnyCPU"); |
||||
} |
||||
|
||||
public ISolution Solution { get; private set; } |
||||
public FileName FileName { get; private set; } |
||||
public ConfigurationMapping ConfigurationMapping { get; set; } |
||||
public ConfigurationAndPlatform ActiveProjectConfiguration { get; set; } |
||||
public IList<SolutionSection> ProjectSections { get; private set; } |
||||
public string ProjectName { get; set; } |
||||
|
||||
public Guid IdGuid { get; set; } |
||||
public Guid TypeGuid { get; set; } |
||||
|
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Parameter object for loading an existing project.
|
||||
/// </summary>
|
||||
public class ProjectLoadInformation : ProjectInformation |
||||
{ |
||||
internal bool? upgradeToolsVersion; |
||||
|
||||
IProgressMonitor progressMonitor = new DummyProgressMonitor(); |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the progress monitor used during the load.
|
||||
/// This property never returns null.
|
||||
/// </summary>
|
||||
public IProgressMonitor ProgressMonitor { |
||||
get { return progressMonitor; } |
||||
set { |
||||
if (value == null) |
||||
throw new ArgumentNullException(); |
||||
progressMonitor = value; |
||||
} |
||||
} |
||||
|
||||
public ProjectLoadInformation(ISolution parentSolution, FileName fileName, string projectName) |
||||
: base(parentSolution, fileName) |
||||
{ |
||||
if (projectName == null) |
||||
throw new ArgumentNullException("projectName"); |
||||
this.ProjectName = projectName; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// This class holds all information the language binding need to create
|
||||
/// a predefined project for their language, if no project template for a
|
||||
/// specific language is avaiable, the language binding shouldn't care about
|
||||
/// this stuff.
|
||||
/// </summary>
|
||||
public class ProjectCreateInformation : ProjectInformation |
||||
{ |
||||
public ProjectCreateInformation(ISolution solution, FileName outputFileName) |
||||
: base(solution, outputFileName) |
||||
{ |
||||
this.IdGuid = Guid.NewGuid(); |
||||
this.RootNamespace = string.Empty; |
||||
} |
||||
|
||||
public string RootNamespace { get; set; } |
||||
public TargetFramework TargetFramework { get; set; } |
||||
public bool InitializeTypeSystem { get; set; } |
||||
} |
||||
} |
@ -1,57 +0,0 @@
@@ -1,57 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Collections.ObjectModel; |
||||
using System.IO; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Internal.Templates |
||||
{ |
||||
/// <summary>
|
||||
/// This class holds all information the language binding need to create
|
||||
/// a predefined project for their language, if no project template for a
|
||||
/// specific language is avaiable, the language binding shouldn't care about
|
||||
/// this stuff.
|
||||
/// </summary>
|
||||
public class ProjectCreateInformation |
||||
{ |
||||
internal List<IProject> createdProjects = new List<IProject>(); |
||||
|
||||
public ProjectCreateInformation() |
||||
: this(new IProject[0]) |
||||
{ |
||||
} |
||||
|
||||
public ProjectCreateInformation(IEnumerable<IProject> projects) |
||||
{ |
||||
this.ProjectConfiguration = new ConfigurationAndPlatform("Debug", "AnyCPU"); |
||||
createdProjects.AddRange(projects); |
||||
} |
||||
|
||||
public IReadOnlyList<IProject> CreatedProjects { |
||||
get { return createdProjects.AsReadOnly(); } |
||||
} |
||||
|
||||
public FileName OutputProjectFileName { get; set; } |
||||
public IConfigurationMapping ConfigurationMapping { get; set; } |
||||
public ConfigurationAndPlatform ProjectConfiguration { get; set; } |
||||
public string ProjectName { get; set; } |
||||
public string SolutionName { get; set; } |
||||
public string RootNamespace { get; set; } |
||||
public DirectoryName SolutionPath { get; set; } |
||||
public DirectoryName ProjectBasePath { get; set; } |
||||
public TargetFramework TargetFramework { get; set; } |
||||
public ISolution Solution { get; set; } |
||||
|
||||
/// <summary>
|
||||
/// Whether to initialize the type system for the newly created project.
|
||||
/// The default is <c>false</c> because SharpDevelop saves and re-loads newly created projects,
|
||||
/// so we don't need a type system if we're going to re-load it anyways.
|
||||
/// </summary>
|
||||
public bool InitializeTypeSystem { get; set; } |
||||
} |
||||
} |
@ -1,55 +0,0 @@
@@ -1,55 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Project |
||||
{ |
||||
/// <summary>
|
||||
/// Parameter object for loading an existing project.
|
||||
/// </summary>
|
||||
public class ProjectLoadInformation |
||||
{ |
||||
public ISolution Solution { get; private set; } |
||||
public FileName FileName { get; private set; } |
||||
public IConfigurationMapping ConfigurationMapping { get; set; } |
||||
public ConfigurationAndPlatform ProjectConfiguration { get; set; } |
||||
public List<SolutionSection> ProjectSections { get; set; } |
||||
public string ProjectName { get; private set; } |
||||
public Guid IdGuid { get; set; } |
||||
public Guid TypeGuid { get; set; } |
||||
|
||||
internal bool? upgradeToolsVersion; |
||||
|
||||
IProgressMonitor progressMonitor = new DummyProgressMonitor(); |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the progress monitor used during the load.
|
||||
/// This property never returns null.
|
||||
/// </summary>
|
||||
public IProgressMonitor ProgressMonitor { |
||||
get { return progressMonitor; } |
||||
set { |
||||
if (value == null) |
||||
throw new ArgumentNullException(); |
||||
progressMonitor = value; |
||||
} |
||||
} |
||||
|
||||
public ProjectLoadInformation(ISolution parentSolution, FileName fileName, string projectName) |
||||
{ |
||||
if (parentSolution == null) |
||||
throw new ArgumentNullException("parentSolution"); |
||||
if (fileName == null) |
||||
throw new ArgumentNullException("fileName"); |
||||
if (projectName == null) |
||||
throw new ArgumentNullException("projectName"); |
||||
this.Solution = parentSolution; |
||||
this.FileName = fileName; |
||||
this.ProjectName = projectName; |
||||
this.ProjectSections = new List<SolutionSection>(); |
||||
} |
||||
} |
||||
} |
@ -1,85 +0,0 @@
@@ -1,85 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics; |
||||
using System.Diagnostics; |
||||
using System.Linq; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Project |
||||
{ |
||||
class ConfigurationMapping : IConfigurationMapping |
||||
{ |
||||
class Entry |
||||
{ |
||||
public ConfigurationAndPlatform Config; |
||||
public bool Build = true; |
||||
|
||||
public Entry(ConfigurationAndPlatform config) |
||||
{ |
||||
this.Config = config; |
||||
} |
||||
} |
||||
|
||||
readonly Solution parentSolution; |
||||
Dictionary<ConfigurationAndPlatform, Entry> dict = new Dictionary<ConfigurationAndPlatform, Entry>(); |
||||
|
||||
public ConfigurationMapping(Solution parentSolution) |
||||
{ |
||||
this.parentSolution = parentSolution; |
||||
} |
||||
|
||||
Entry GetEntry(ConfigurationAndPlatform solutionConfiguration) |
||||
{ |
||||
Entry entry; |
||||
lock (dict) { |
||||
if (!dict.TryGetValue(solutionConfiguration, out entry)) { |
||||
var config = new ConfigurationAndPlatform(solutionConfiguration.Configuration, MSBuildInternals.FixPlatformNameForProject(solutionConfiguration.Platform)); |
||||
entry = new Entry(config); |
||||
dict.Add(solutionConfiguration, entry); |
||||
} |
||||
} |
||||
return entry; |
||||
} |
||||
|
||||
#region IConfigurationMapping implementation
|
||||
public ConfigurationAndPlatform GetProjectConfiguration(ConfigurationAndPlatform solutionConfiguration) |
||||
{ |
||||
return GetEntry(solutionConfiguration).Config; |
||||
} |
||||
|
||||
public void SetProjectConfiguration(ConfigurationAndPlatform solutionConfiguration, ConfigurationAndPlatform projectConfiguration) |
||||
{ |
||||
Debug.Assert(projectConfiguration.Platform != "Any CPU"); |
||||
GetEntry(solutionConfiguration).Config = projectConfiguration; |
||||
if (parentSolution != null) |
||||
parentSolution.IsDirty = true; |
||||
} |
||||
|
||||
public bool IsBuildEnabled(ConfigurationAndPlatform solutionConfiguration) |
||||
{ |
||||
return GetEntry(solutionConfiguration).Build; |
||||
} |
||||
|
||||
public void SetBuildEnabled(ConfigurationAndPlatform solutionConfiguration, bool value) |
||||
{ |
||||
GetEntry(solutionConfiguration).Build = value; |
||||
if (parentSolution != null) |
||||
parentSolution.IsDirty = true; |
||||
} |
||||
#endregion
|
||||
|
||||
public void RenameSolutionConfig(string oldName, string newName, bool isPlatform) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
lock (dict) { |
||||
foreach (var pair in dict.ToArray()) { |
||||
if (oldName == (isPlatform ? pair.Key.Platform : pair.Key.Configuration)) { |
||||
|
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue