Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/main/src
diff options
context:
space:
mode:
authorAlan McGovern <alan.mcgovern@gmail.com>2011-08-24 20:00:03 +0400
committerAlan McGovern <alan.mcgovern@gmail.com>2011-08-24 23:50:11 +0400
commite608e5e7fcc7431186be59ae1714de4cf4c25fe3 (patch)
tree9803fb9adebb77bb7e49902fd476f2cae7f21dba /main/src
parent4c1c02569c0ddba2770d605ca74abee98a55c063 (diff)
[MacDev] Sort items properly in the xcode solution
The original attempt to sort the items when adding them to the generated xcode solution sorted them by calling ToString and comparing that. This is useless as ToString is typically prefixed with a random ID and so you will always end up with random sorting. Fix this by putting some smarts into the sorting so it can handle (at the least) files and groups.
Diffstat (limited to 'main/src')
-rw-r--r--main/src/addins/MonoDevelop.MacDev/Makefile.am1
-rw-r--r--main/src/addins/MonoDevelop.MacDev/MonoDevelop.MacDev.csproj1
-rw-r--r--main/src/addins/MonoDevelop.MacDev/XcodeIntegration/PBXFileReference.cs14
-rw-r--r--main/src/addins/MonoDevelop.MacDev/XcodeIntegration/PBXGroup.cs2
-rw-r--r--main/src/addins/MonoDevelop.MacDev/XcodeIntegration/XCodeObjectComparer.cs59
5 files changed, 69 insertions, 8 deletions
diff --git a/main/src/addins/MonoDevelop.MacDev/Makefile.am b/main/src/addins/MonoDevelop.MacDev/Makefile.am
index 188284a9aa..6946733f71 100644
--- a/main/src/addins/MonoDevelop.MacDev/Makefile.am
+++ b/main/src/addins/MonoDevelop.MacDev/Makefile.am
@@ -84,6 +84,7 @@ FILES = \
XcodeIntegration/XCBuildConfiguration.cs \
XcodeIntegration/XCConfigurationList.cs \
XcodeIntegration/XcodeObject.cs \
+ XcodeIntegration/XCodeObjectComparer.cs \
XcodeIntegration/XcodeProject.cs \
XcodeIntegration/XcodeType.cs \
XcodeInterfaceBuilderDisplayBinding.cs \
diff --git a/main/src/addins/MonoDevelop.MacDev/MonoDevelop.MacDev.csproj b/main/src/addins/MonoDevelop.MacDev/MonoDevelop.MacDev.csproj
index 791d34ebcd..754e284abc 100644
--- a/main/src/addins/MonoDevelop.MacDev/MonoDevelop.MacDev.csproj
+++ b/main/src/addins/MonoDevelop.MacDev/MonoDevelop.MacDev.csproj
@@ -136,6 +136,7 @@
<Compile Include="MonoDevelop.MacDev.PlistEditor\ExpanderList.cs" />
<Compile Include="MonoDevelop.MacDev.PlistEditor\ImageChooser.cs" />
<Compile Include="XcodeSyncing\XcodeSyncedResource.cs" />
+ <Compile Include="XcodeIntegration\XCodeObjectComparer.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="MonoDevelop.MacDev.addin.xml">
diff --git a/main/src/addins/MonoDevelop.MacDev/XcodeIntegration/PBXFileReference.cs b/main/src/addins/MonoDevelop.MacDev/XcodeIntegration/PBXFileReference.cs
index e3681d8183..fb49d60c91 100644
--- a/main/src/addins/MonoDevelop.MacDev/XcodeIntegration/PBXFileReference.cs
+++ b/main/src/addins/MonoDevelop.MacDev/XcodeIntegration/PBXFileReference.cs
@@ -31,15 +31,15 @@ namespace MonoDevelop.MacDev.XcodeIntegration
{
class PBXFileReference : XcodeObject
{
- string name;
- string path;
- string sourceTree;
+ public string Name { get; private set; }
+ public string Path { get; private set; }
+ public string SourceTree {get; private set; }
public PBXFileReference (string name, string path, string sourceTree)
{
- this.name = name;
- this.path = path;
- this.sourceTree = sourceTree;
+ Name = name;
+ Path = path;
+ SourceTree = sourceTree;
}
public override XcodeType Type {
@@ -50,7 +50,7 @@ namespace MonoDevelop.MacDev.XcodeIntegration
public override string ToString ()
{
- return string.Format ("{0} = {{isa = {1}; name = {2}; path = {3}; sourceTree = {4}; }};", Token, Type, QuoteOnDemand (name), QuoteOnDemand (path), sourceTree);
+ return string.Format ("{0} = {{isa = {1}; name = {2}; path = {3}; sourceTree = {4}; }};", Token, Type, QuoteOnDemand (Name), QuoteOnDemand (Path), SourceTree);
}
}
}
diff --git a/main/src/addins/MonoDevelop.MacDev/XcodeIntegration/PBXGroup.cs b/main/src/addins/MonoDevelop.MacDev/XcodeIntegration/PBXGroup.cs
index 2befa89c64..5cdca8044e 100644
--- a/main/src/addins/MonoDevelop.MacDev/XcodeIntegration/PBXGroup.cs
+++ b/main/src/addins/MonoDevelop.MacDev/XcodeIntegration/PBXGroup.cs
@@ -63,7 +63,7 @@ namespace MonoDevelop.MacDev.XcodeIntegration
var sb = new StringBuilder ();
sb.AppendFormat ("{0} = {{\n\t\t\tisa = {1};\n\t\t\tchildren = (\n", Token, Type);
- children.Sort ((x, y) => x.ToString ().CompareTo (y.ToString ()));
+ children.Sort (new XcodeObjectComparer ());
foreach (var child in children)
sb.AppendFormat ("\t\t\t\t{0},\n", child.Token);
var quotedName = QuoteOnDemand (name);
diff --git a/main/src/addins/MonoDevelop.MacDev/XcodeIntegration/XCodeObjectComparer.cs b/main/src/addins/MonoDevelop.MacDev/XcodeIntegration/XCodeObjectComparer.cs
new file mode 100644
index 0000000000..569b7b9a86
--- /dev/null
+++ b/main/src/addins/MonoDevelop.MacDev/XcodeIntegration/XCodeObjectComparer.cs
@@ -0,0 +1,59 @@
+//
+// XCodeObjectComparer.cs
+//
+// Author:
+// Alan McGovern <alan@xamarin.com>
+//
+// Copyright (c) 2011 Xamarin 2011
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using System.Collections.Generic;
+
+namespace MonoDevelop.MacDev.XcodeIntegration {
+
+ public class XcodeObjectComparer : IComparer<XcodeObject> {
+
+ public int Compare (XcodeObject x, XcodeObject y)
+ {
+ if (x == null)
+ return y == null ? 0 : -1;
+ if (y == null)
+ return 1;
+ if (x.GetType () != y.GetType ())
+ return x.GetType ().Name.CompareTo (y.GetType ().Name);
+
+ if (x is PBXFileReference) {
+ var left = (PBXFileReference) x;
+ var right = (PBXFileReference) y;
+ return left.Path.CompareTo (right.Path);
+ }
+
+ if (x is PBXGroup) {
+ var left = (PBXGroup) x;
+ var right = (PBXGroup) y;
+ return left.Name.CompareTo (right.Name);
+ }
+
+ return 0;
+ }
+ }
+}
+