Author: ankit
Date: 2008-01-23 08:34:25 -0500 (Wed, 23 Jan 2008)
New Revision: 93654
Modified:
branches/monodevelop/main/1.0/src/addins/prj2make-sharp-lib/ChangeLog
branches/monodevelop/main/1.0/src/addins/prj2make-sharp-lib/SlnData.cs
branches/monodevelop/main/1.0/src/addins/prj2make-sharp-lib/SlnFileFormat.cs
Log:
Fix bug#353042.
* SlnData.cs (HeaderComment): New.
(VersionString): New.
* SlnFileFormat.cs: Retain the header comment string and version and use
that when writing .sln .
Modified: branches/monodevelop/main/1.0/src/addins/prj2make-sharp-lib/ChangeLog
===================================================================
--- branches/monodevelop/main/1.0/src/addins/prj2make-sharp-lib/ChangeLog
2008-01-23 13:10:40 UTC (rev 93653)
+++ branches/monodevelop/main/1.0/src/addins/prj2make-sharp-lib/ChangeLog
2008-01-23 13:34:25 UTC (rev 93654)
@@ -1,3 +1,11 @@
+2008-01-23 Ankit Jain <[EMAIL PROTECTED]>
+
+ Fix bug#353042.
+ * SlnData.cs (HeaderComment): New.
+ (VersionString): New.
+ * SlnFileFormat.cs: Retain the header comment string and version and use
+ that when writing .sln .
+
2008-01-22 Lluis Sanchez Gual <[EMAIL PROTECTED]>
* prj2make-sharp-lib.addin.xml: Updated add-in category and description.
Modified: branches/monodevelop/main/1.0/src/addins/prj2make-sharp-lib/SlnData.cs
===================================================================
--- branches/monodevelop/main/1.0/src/addins/prj2make-sharp-lib/SlnData.cs
2008-01-23 13:10:40 UTC (rev 93653)
+++ branches/monodevelop/main/1.0/src/addins/prj2make-sharp-lib/SlnData.cs
2008-01-23 13:34:25 UTC (rev 93654)
@@ -36,6 +36,8 @@
class SlnData
{
string guid;
+ string headerComment;
+ string versionString;
Dictionary<CombineConfiguration, string> configStrings;
List<string> globalExtra; // unused GlobalSections
Dictionary<string, List<string>> sectionExtras;
@@ -43,14 +45,17 @@
List<string> unknownProjects;
Dictionary<string, DotNetProject> projectsByGuidTable;
- public SlnData ()
+ public SlnData ()
+ : this (String.Format ("{{{0}}}", System.Guid.NewGuid
().ToString ().ToUpper ()))
{
- this.guid = String.Format ("{{{0}}}",
System.Guid.NewGuid ().ToString ().ToUpper ());
}
public SlnData (string guid)
{
this.guid = guid;
+ // default, vs2005
+ versionString = "9.00";
+ headerComment = "# Visual Studio 2005";
}
/* Guid with enclosing {} */
@@ -59,6 +64,18 @@
set { guid = value; }
}
+ // Eg. "# Visual C# Express 2008"
+ public string HeaderComment {
+ get { return headerComment; }
+ set { headerComment = value; }
+ }
+
+ // Eg. 9.00 or 10.00
+ public string VersionString {
+ get { return versionString; }
+ set { versionString = value; }
+ }
+
public Dictionary<CombineConfiguration, string> ConfigStrings {
get {
if (configStrings == null)
Modified:
branches/monodevelop/main/1.0/src/addins/prj2make-sharp-lib/SlnFileFormat.cs
===================================================================
---
branches/monodevelop/main/1.0/src/addins/prj2make-sharp-lib/SlnFileFormat.cs
2008-01-23 13:10:40 UTC (rev 93653)
+++
branches/monodevelop/main/1.0/src/addins/prj2make-sharp-lib/SlnFileFormat.cs
2008-01-23 13:34:25 UTC (rev 93654)
@@ -64,7 +64,8 @@
{
if (String.Compare (Path.GetExtension (file), ".sln",
true) != 0)
return false;
- string version = GetSlnFileVersion (file);
+ string tmp;
+ string version = GetSlnFileVersion (file, out tmp);
return version == "9.00" || version == "10.00";
}
@@ -128,28 +129,27 @@
using (StreamWriter sw = new StreamWriter (file, false,
Encoding.UTF8)) {
sw.NewLine = "\r\n";
+ SlnData slnData = GetSlnData (c);
+ if (slnData == null) {
+ // If a non-msbuild project is being
converted by just
+ // changing the fileformat, then create
the SlnData for it
+ slnData = new SlnData ();
+ c.ExtendedProperties [typeof
(SlnFileFormat)] = slnData;
+ }
+
sw.WriteLine ();
//Write Header
- sw.WriteLine ("Microsoft Visual Studio Solution
File, Format Version 9.00");
+ sw.WriteLine ("Microsoft Visual Studio Solution
File, Format Version " + slnData.VersionString);
+ sw.WriteLine (slnData.HeaderComment);
- sw.WriteLine ("# Visual Studio 2005");
-
//Write the projects
monitor.BeginTask (GettextCatalog.GetString
("Saving projects"), 1);
WriteProjects (c, c.BaseDirectory, sw, monitor);
monitor.EndTask ();
- SlnData slnData = GetSlnData (c);
- if (slnData == null) {
- // If a non-msbuild project is being
converted by just
- // changing the fileformat, then create
the SlnData for it
- slnData = new SlnData ();
- c.ExtendedProperties [typeof
(SlnFileFormat)] = slnData;
- } else {
- //Write the lines for unknownProjects
- foreach (string l in
slnData.UnknownProjects)
- sw.WriteLine (l);
- }
+ //Write the lines for unknownProjects
+ foreach (string l in slnData.UnknownProjects)
+ sw.WriteLine (l);
//Write the Globals
sw.WriteLine ("Global");
@@ -252,6 +252,11 @@
// Solution folder
slnData = new SlnData ();
c.ExtendedProperties [typeof
(SlnFileFormat)] = slnData;
+ SlnData data = GetSlnData
(combine);
+ if (data != null) {
+ slnData.VersionString =
data.VersionString;
+ slnData.HeaderComment =
data.HeaderComment;
+ }
}
l = slnData.Extra;
@@ -390,7 +395,8 @@
//
Combine LoadSolution (string fileName, IProgressMonitor monitor)
{
- string version = GetSlnFileVersion (fileName);
+ string headerComment;
+ string version = GetSlnFileVersion (fileName, out
headerComment);
if (version != "9.00" && version != "10.00")
throw new UnknownProjectVersionException
(fileName, version);
@@ -410,6 +416,8 @@
combine.FileFormat = new MSBuildFileFormat ();
data = new SlnData ();
combine.ExtendedProperties [typeof
(SlnFileFormat)] = data;
+ data.VersionString = version;
+ data.HeaderComment = headerComment;
string s = null;
projectSections = new List<Section> ();
@@ -479,6 +487,8 @@
SlnData slnData = new SlnData
(projectGuid);
folder.ExtendedProperties [typeof
(SlnFileFormat)] = slnData;
+ slnData.VersionString =
data.VersionString;
+ slnData.HeaderComment =
data.HeaderComment;
slnData.Extra = lines.GetRange
(sec.Start + 1, sec.Count - 2);
@@ -897,10 +907,11 @@
}
// Utility function to determine the sln file version
- string GetSlnFileVersion(string strInSlnFile)
+ string GetSlnFileVersion(string strInSlnFile, out string
headerComment)
{
string strVersion = null;
string strInput = null;
+ headerComment = null;
Match match;
StreamReader reader = new StreamReader(strInSlnFile);
@@ -919,6 +930,7 @@
if (match.Success)
{
strVersion = match.Groups[1].Value;
+ headerComment = reader.ReadLine ();
}
// Close the stream
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches