105 changed files with 931 additions and 724 deletions
@ -1,15 +0,0 @@
@@ -1,15 +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.ObjectModel; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom |
||||
{ |
||||
/// <summary>
|
||||
/// A model collection implementation that is based on a ObservableCollection.
|
||||
/// </summary>
|
||||
public class SimpleModelCollection<T> : ObservableCollection<T>, IModelCollection<T> |
||||
{ |
||||
} |
||||
} |
||||
@ -0,0 +1,104 @@
@@ -0,0 +1,104 @@
|
||||
// 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.Text.RegularExpressions; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Project |
||||
{ |
||||
/// <summary>
|
||||
/// Represents a configuration/platform pair.
|
||||
/// </summary>
|
||||
public struct ConfigurationAndPlatform : IEquatable<ConfigurationAndPlatform> |
||||
{ |
||||
readonly static Regex configurationRegEx = new Regex(@"'(?<property>[^']*)'\s*==\s*'(?<value>[^']*)'", RegexOptions.Compiled); |
||||
|
||||
/// <summary>
|
||||
/// Gets configuration and platform from an MSBuild condition in the format "'$(Configuration)|$(Platform)' == 'configuration|platform'".
|
||||
/// </summary>
|
||||
public static ConfigurationAndPlatform FromCondition(string condition) |
||||
{ |
||||
Match match = configurationRegEx.Match(condition); |
||||
if (match.Success) { |
||||
string conditionProperty = match.Result("${property}"); |
||||
string conditionValue = match.Result("${value}"); |
||||
if (conditionProperty == "$(Configuration)|$(Platform)") { |
||||
// configuration is ok
|
||||
return FromKey(conditionValue); |
||||
} else if (conditionProperty == "$(Configuration)") { |
||||
return new ConfigurationAndPlatform(conditionValue, null); |
||||
} else if (conditionProperty == "$(Platform)") { |
||||
return new ConfigurationAndPlatform(null, conditionValue); |
||||
} else { |
||||
return default(ConfigurationAndPlatform); |
||||
} |
||||
} else { |
||||
return default(ConfigurationAndPlatform); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets configuration and platform from a key string in the format 'configuration|platform'.
|
||||
/// </summary>
|
||||
public static ConfigurationAndPlatform FromKey(string key) |
||||
{ |
||||
int pos = key.IndexOf('|'); |
||||
if (pos < 0) |
||||
return default(ConfigurationAndPlatform); |
||||
else |
||||
return new ConfigurationAndPlatform(key.Substring(0, pos), key.Substring(pos + 1)); |
||||
} |
||||
|
||||
readonly string configuration; |
||||
readonly string platform; |
||||
|
||||
public ConfigurationAndPlatform(string configuration, string platform) |
||||
{ |
||||
this.configuration = configuration; |
||||
this.platform = platform; |
||||
} |
||||
|
||||
public string Platform { |
||||
get { return platform; } |
||||
} |
||||
|
||||
public string Configuration { |
||||
get { return configuration; } |
||||
} |
||||
|
||||
#region Equals and GetHashCode implementation
|
||||
public override bool Equals(object obj) |
||||
{ |
||||
if (obj is ConfigurationAndPlatform) |
||||
return Equals((ConfigurationAndPlatform)obj); // use Equals method below
|
||||
else |
||||
return false; |
||||
} |
||||
|
||||
public bool Equals(ConfigurationAndPlatform other) |
||||
{ |
||||
return this.configuration == other.configuration && this.platform == other.platform; |
||||
} |
||||
|
||||
public override int GetHashCode() |
||||
{ |
||||
return (configuration != null ? configuration.GetHashCode() : 0) ^ (platform != null ? platform.GetHashCode() : 0); |
||||
} |
||||
|
||||
public static bool operator ==(ConfigurationAndPlatform left, ConfigurationAndPlatform right) |
||||
{ |
||||
return left.Equals(right); |
||||
} |
||||
|
||||
public static bool operator !=(ConfigurationAndPlatform left, ConfigurationAndPlatform right) |
||||
{ |
||||
return !left.Equals(right); |
||||
} |
||||
#endregion
|
||||
|
||||
public override string ToString() |
||||
{ |
||||
return configuration + "|" + platform; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,42 @@
@@ -0,0 +1,42 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Daniel |
||||
* Date: 2/26/2013 |
||||
* Time: 16:27 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Project |
||||
{ |
||||
/// <summary>
|
||||
/// Description of IConfigurable.
|
||||
/// </summary>
|
||||
public interface IConfigurable |
||||
{ |
||||
/// <summary>
|
||||
/// Gets the list of available configuration names.
|
||||
/// </summary>
|
||||
IConfigurationOrPlatformNameCollection ConfigurationNames { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the list of available platform names.
|
||||
/// </summary>
|
||||
IConfigurationOrPlatformNameCollection PlatformNames { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the active configuration+platform of the solution.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// After changing this property on the solution, the change will be automatically applied
|
||||
/// to the projects (using the solution <-> project configuration mapping).
|
||||
/// </remarks>
|
||||
ConfigurationAndPlatform ActiveConfiguration { get; set; } |
||||
|
||||
/// <summary>
|
||||
/// Is raised after the ActiveConfiguration property has changed.
|
||||
/// </summary>
|
||||
event EventHandler ActiveConfigurationChanged; |
||||
} |
||||
} |
||||
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
// 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,54 @@
@@ -0,0 +1,54 @@
|
||||
// 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.Specialized; |
||||
|
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Project |
||||
{ |
||||
/// <summary>
|
||||
/// Represents a collection of configuration or platform names.
|
||||
/// </summary>
|
||||
public interface IConfigurationOrPlatformNameCollection : IReadOnlyCollection<string>, INotifyCollectionChanged |
||||
{ |
||||
/// <summary>
|
||||
/// Validates the input name.
|
||||
///
|
||||
/// If the name is valid, this method returns the normalized form of the input name.
|
||||
/// If the name is invalid, this method returns null.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Normalization will trim spaces around the name; and it will normalize between "AnyCPU" and "Any CPU".
|
||||
/// </remarks>
|
||||
string ValidateName(string name); |
||||
/* |
||||
* if (MSBuildInternals.Escape(newName) != newName |
||||
|| !FileUtility.IsValidDirectoryEntryName(newName) |
||||
|| newName.Contains("'")) |
||||
{ |
||||
return false; |
||||
} |
||||
*/ |
||||
|
||||
/// <summary>
|
||||
/// Creates a new configuration/platform.
|
||||
/// Settings will be copied from the existing configuration/platform <paramref name="copyFrom"/>.
|
||||
/// If <paramref name="copyFrom"/> is null, no settings will be copied.
|
||||
/// </summary>
|
||||
void Add(string newName, string copyFrom); |
||||
|
||||
/// <summary>
|
||||
/// Removes the configuration/platform with the specified name.
|
||||
/// </summary>
|
||||
void Remove(string name); |
||||
|
||||
/// <summary>
|
||||
/// Renames the configuration or platform from 'oldName' to 'newName'.
|
||||
/// If the configuration or platform is active, the <see cref="IConfigurable.ActiveConfiguration"/> property will be changed.
|
||||
/// </summary>
|
||||
void Rename(string oldName, string newName); |
||||
} |
||||
} |
||||
@ -0,0 +1,80 @@
@@ -0,0 +1,80 @@
|
||||
// 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 ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Project |
||||
{ |
||||
/// <summary>
|
||||
/// Deals with loading projects and solutions.
|
||||
/// </summary>
|
||||
[SDService("SD.ProjectService")] |
||||
public interface IProjectService |
||||
{ |
||||
/// <summary>
|
||||
/// Gets the solution that is currently opened within the IDE.
|
||||
/// </summary>
|
||||
ISolution OpenSolution { get; } |
||||
|
||||
event EventHandler OpenSolutionChanged; |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the project that is currently considered 'active' within the IDE.
|
||||
/// </summary>
|
||||
IProject CurrentProject { get; set; } |
||||
|
||||
event EventHandler CurrentProjectChanged; |
||||
|
||||
/// <summary>
|
||||
/// Gets the list of projects that are currently opened within the IDE.
|
||||
/// </summary>
|
||||
IModelCollection<IProject> Projects { get; } |
||||
|
||||
/// <summary>
|
||||
/// Finds the project that contains the specified file.
|
||||
/// Returns null if none of the open projects contains the file.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If multiple projects contain the file, any one of them is returned.
|
||||
/// </remarks>
|
||||
IProject FindProjectContainingFile(FileName fileName); |
||||
|
||||
/// <summary>
|
||||
/// If the given filename is a solution file (.sln), it is loaded and opened in the IDE.
|
||||
/// Otherwise, SharpDevelop looks for a .sln file corresponding to the project file, and opens that instead.
|
||||
/// If no such .sln file is found, SharpDevelop will create one.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If any errors occur, this method may display an error dialog.
|
||||
/// </remarks>
|
||||
void OpenSolutionOrProject(FileName fileName); |
||||
|
||||
/// <summary>
|
||||
/// Closes the currently open solution.
|
||||
/// </summary>
|
||||
void CloseSolution(); |
||||
|
||||
/// <summary>
|
||||
/// Returns if the given file is considered a project or solution file.
|
||||
/// This method looks at the list of registered file extensions in /SharpDevelop/Workbench/ProjectBinding.
|
||||
/// </summary>
|
||||
bool IsProjectOrSolutionFile(FileName fileName); |
||||
|
||||
/// <summary>
|
||||
/// Loads a solution file without opening it in the IDE.
|
||||
/// </summary>
|
||||
/// <exception cref="ProjectLoadException">
|
||||
/// The .sln file is malformed or an unsupported version, and cannot be loaded.
|
||||
/// This exception does not occur if only individual projects within the solution are invalid.
|
||||
/// </exception>
|
||||
ISolution LoadSolutionFile(FileName fileName); |
||||
|
||||
/// <summary>
|
||||
/// Creates a new, empty solution and loads it without opening it in the IDE.
|
||||
/// The file is not saved to disk until <see cref="ISolution.Save"/> is called.
|
||||
/// </summary>
|
||||
ISolution CreateEmptySolutionFile(FileName fileName); |
||||
} |
||||
} |
||||
@ -0,0 +1,88 @@
@@ -0,0 +1,88 @@
|
||||
// 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 ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Project |
||||
{ |
||||
public enum SolutionFormatVersion // TODO: change IProject.MinimumSolutionFormatVersion to this enum type
|
||||
{ |
||||
VS2005 = 9, |
||||
VS2008 = 10, |
||||
VS2010 = 11, |
||||
VS2012 = 12 |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Represents a solution.
|
||||
/// </summary>
|
||||
public interface ISolution : ISolutionFolder, ICanBeDirty, IConfigurable, IDisposable |
||||
{ |
||||
Microsoft.Build.Evaluation.ProjectCollection MSBuildProjectCollection { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the full path of the .sln file.
|
||||
/// </summary>
|
||||
FileName FileName { get; } |
||||
|
||||
event EventHandler FileNameChanged; |
||||
|
||||
/// <summary>
|
||||
/// Gets the full path of the directory containing the .sln file.
|
||||
/// </summary>
|
||||
string Directory { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the startup project.
|
||||
/// </summary>
|
||||
IProject StartupProject { get; set; } |
||||
|
||||
event EventHandler StartupProjectChanged; |
||||
|
||||
/// <summary>
|
||||
/// Gets all projects in the solution.
|
||||
/// </summary>
|
||||
IModelCollection<IProject> Projects { get; } |
||||
|
||||
/// <summary>
|
||||
/// Loads an existing project from disk and adds it to this solution.
|
||||
/// </summary>
|
||||
/// <param name="fileName">Path to the project file</param>
|
||||
/// <param name="parentFolder">
|
||||
/// Optional: The parent folder to which the new project should be added.
|
||||
/// If this parameter is not specified, the project is added to the root folder of the solution.
|
||||
/// </param>
|
||||
void AddExistingProject(FileName fileName, ISolutionFolder parentFolder = null); |
||||
|
||||
/// <summary>
|
||||
/// Gets all file items in the solution.
|
||||
/// </summary>
|
||||
IModelCollection<ISolutionFileItem> FileItems { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets a container that can be used to store data about the solution.
|
||||
/// This data is stored in SharpDevelop's config directory, not directly with the .sln file.
|
||||
/// </summary>
|
||||
Properties Preferences { get; } |
||||
|
||||
/// <summary>
|
||||
/// Saves the preferences for this solution; and also for any projects within this solution.
|
||||
/// </summary>
|
||||
void SavePreferences(); |
||||
|
||||
/// <summary>
|
||||
/// Gets whether the solution is read-only.
|
||||
/// </summary>
|
||||
bool IsReadOnly { get; } |
||||
|
||||
/// <summary>
|
||||
/// Saves the solution.
|
||||
/// This will also save all modified projects within this solution.
|
||||
/// </summary>
|
||||
void Save(); |
||||
|
||||
|
||||
} |
||||
} |
||||
@ -0,0 +1,40 @@
@@ -0,0 +1,40 @@
|
||||
// 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 ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Project |
||||
{ |
||||
/// <summary>
|
||||
/// Represents a solution folder.
|
||||
/// </summary>
|
||||
public interface ISolutionFolder : ISolutionItem |
||||
{ |
||||
/// <summary>
|
||||
/// Gets/Sets the name of the folder.
|
||||
/// </summary>
|
||||
/// <exception cref="ArgumentException">newName is not a valid solution name.</exception>
|
||||
/// <remarks>
|
||||
/// For the solution itself, setting this property will rename the .sln file.
|
||||
/// </remarks>
|
||||
string Name { get; set; } |
||||
|
||||
/* if (solution.Name == newName) |
||||
return; |
||||
if (!FileService.CheckFileName(newName)) |
||||
return; |
||||
string newFileName = Path.Combine(solution.Directory, newName + ".sln"); |
||||
if (!FileService.RenameFile(solution.FileName, newFileName, false)) { |
||||
return; |
||||
} |
||||
solution.FileName = newFileName; |
||||
solution.Name = newName; |
||||
*/ |
||||
|
||||
/// <summary>
|
||||
/// Gets the list of direct child items in this solution folder.
|
||||
/// </summary>
|
||||
IMutableModelCollection<ISolutionItem> Items { get; } |
||||
} |
||||
} |
||||
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
// 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 ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Project |
||||
{ |
||||
/// <summary>
|
||||
/// Represents an item within a solution folder.
|
||||
/// This may be a file, a project, or another solution folder.
|
||||
/// </summary>
|
||||
public interface ISolutionItem |
||||
{ |
||||
/// <summary>
|
||||
/// Gets the parent folder.
|
||||
/// This property will return null for the solution (which acts as the top-level folder).
|
||||
/// It will also return null for folders that were removed from their parent.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The parent folder of an item can change, e.g. when a project is moved into a different folder.
|
||||
/// The setter of this property should be used by the <see cref="ISolutionFolder"/> implementation only.
|
||||
/// </remarks>
|
||||
ISolutionFolder ParentFolder { get; set; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the parent solution.
|
||||
/// This property is thread-safe, and will never returns null.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The parent solution of a solution item cannot change; a new instance of the item must be created
|
||||
/// in order to move the item to another solution.
|
||||
/// </remarks>
|
||||
ISolution ParentSolution { get; } |
||||
} |
||||
|
||||
public interface ISolutionFileItem : ISolutionItem |
||||
{ |
||||
FileName FileName { get; } |
||||
} |
||||
} |
||||
@ -1,40 +0,0 @@
@@ -1,40 +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>
|
||||
/// Interface called to load (convert) project and solution files
|
||||
/// </summary>
|
||||
public interface IProjectLoader |
||||
{ |
||||
/// <summary>
|
||||
/// Load/Convert the project solution
|
||||
/// </summary>
|
||||
void Load(string fileName); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Loader for MSBuild project files
|
||||
/// </summary>
|
||||
public class LoadProject : IProjectLoader |
||||
{ |
||||
public void Load(string fileName) |
||||
{ |
||||
ProjectService.LoadProject(fileName); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Loader for sln files as well as Sharpdevelop cmbx and prjx files
|
||||
/// </summary>
|
||||
public class LoadSolution : IProjectLoader |
||||
{ |
||||
public void Load(string fileName) |
||||
{ |
||||
ProjectService.LoadSolution(fileName); |
||||
} |
||||
} |
||||
} |
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue