Author: ankit
Date: 2006-12-07 15:45:29 -0500 (Thu, 07 Dec 2006)
New Revision: 69202
Modified:
trunk/monodevelop/Extras/prj2make-sharp-lib/ChangeLog
trunk/monodevelop/Extras/prj2make-sharp-lib/MSBuildFileFormat.cs
trunk/monodevelop/Extras/prj2make-sharp-lib/SlnFileFormat.cs
Log:
* SlnFileFormat.cs: Move extra .sln specific info from
ExtendedProperties to SlnData and store that in the ExtendedProperties.
* MSBuildFileFormat.cs: Likewise, move to MSBuildData.
Modified: trunk/monodevelop/Extras/prj2make-sharp-lib/ChangeLog
===================================================================
--- trunk/monodevelop/Extras/prj2make-sharp-lib/ChangeLog 2006-12-07
20:26:09 UTC (rev 69201)
+++ trunk/monodevelop/Extras/prj2make-sharp-lib/ChangeLog 2006-12-07
20:45:29 UTC (rev 69202)
@@ -1,3 +1,9 @@
+2006-12-08 Ankit Jain <[EMAIL PROTECTED]>
+
+ * SlnFileFormat.cs: Move extra .sln specific info from
+ ExtendedProperties to SlnData and store that in the ExtendedProperties.
+ * MSBuildFileFormat.cs: Likewise, move to MSBuildData.
+
2006-12-03 Ankit Jain <[EMAIL PROTECTED]>
* SlnFileFormat.cs (WriteProjects): Add 'baseDirectory' param.
Modified: trunk/monodevelop/Extras/prj2make-sharp-lib/MSBuildFileFormat.cs
===================================================================
--- trunk/monodevelop/Extras/prj2make-sharp-lib/MSBuildFileFormat.cs
2006-12-07 20:26:09 UTC (rev 69201)
+++ trunk/monodevelop/Extras/prj2make-sharp-lib/MSBuildFileFormat.cs
2006-12-07 20:45:29 UTC (rev 69202)
@@ -120,37 +120,42 @@
{
string platform = "AnyCPU";
bool newdoc = false;
+ XmlDocument doc = null;
- XmlDocument doc = project.ExtendedProperties
["xml_doc"] as XmlDocument;
- if (doc == null) {
+ MSBuildData data = (MSBuildData)
project.ExtendedProperties [typeof (MSBuildFileFormat)];
+ if (data == null) {
//Create a new XmlDocument
doc = new XmlDocument ();
- project.ExtendedProperties ["xml_doc"] = doc;
+ data = new MSBuildData ();
+ data.Document = doc;
+ project.ExtendedProperties [typeof
(MSBuildFileFormat)] = data;
newdoc = true;
XmlElement e = doc.CreateElement ("Project",
ns);
doc.AppendChild (e);
e.SetAttribute ("DefaultTargets", "Build");
+ } else {
+ doc = data.Document;
}
//Write out the Configurations
//FIXME: Not touching global config right now,
//instead just writing out everything in the individual
configs
- XmlElement globalConfigElement =
project.ExtendedProperties ["global_config"] as XmlElement;
+ XmlElement globalConfigElement =
data.GlobalConfigElement;
if (globalConfigElement == null) {
globalConfigElement = doc.CreateElement
("PropertyGroup", ns);
doc.DocumentElement.AppendChild
(globalConfigElement);
- project.ExtendedProperties ["global_config"] =
globalConfigElement;
+ data.GlobalConfigElement = globalConfigElement;
string guid = Guid.NewGuid ().ToString
().ToUpper ();
- project.ExtendedProperties ["guid"] = guid.Trim
(new char [] {'{', '}'});
+ data.Guid = guid.Trim (new char [] {'{', '}'});
//FIXME: EnsureChildValue for AssemblyName <->
OutputAssembly
// Get this from where? different configs
could have different ones..
}
EnsureChildValue (globalConfigElement, "ProjectGuid",
ns,
- String.Concat ("{", (string)
project.ExtendedProperties ["guid"], "}"));
+ String.Concat ("{", data.Guid, "}"));
//Set active config
//FIXME: >1 <Configuration elements?
@@ -194,15 +199,18 @@
}
foreach (DotNetProjectConfiguration config in
project.Configurations) {
- XmlElement configNode =
project.ExtendedProperties [config] as XmlElement;
- if (configNode == null) {
+ XmlElement configNode = null;
+
+ if (data.ConfigElements.ContainsKey (config)) {
+ configNode = data.ConfigElements
[config];
+ } else {
//Create node for new configuration
configNode = doc.CreateElement
("PropertyGroup", ns);
doc.DocumentElement.AppendChild
(configNode);
configNode.SetAttribute ("Condition",
String.Format ("
'$(Configuration)|$(Platform)' == '{0}|{1}' ", config.Name, "AnyCPU"));
- project.ExtendedProperties [config] =
configNode;
+ data.ConfigElements [config] =
configNode;
}
EnsureChildValue (configNode, "OutputType", ns,
config.CompileTarget);
@@ -272,15 +280,18 @@
{
WriteFile (file, project, monitor);
- XmlDocument doc = project.ExtendedProperties
["xml_doc"] as XmlDocument;
+ MSBuildData d = (MSBuildData)
project.ExtendedProperties [typeof (MSBuildFileFormat)];
+ if (d == null)
+ throw new Exception (String.Format ("INTERNAL
ERROR: 'data' object not found for {0}", project.Name));
+
foreach (ProjectFile pfile in project.ProjectFiles)
- project.ExtendedProperties [pfile] =
FileToXmlNode (doc, project, pfile);
+ d.ProjectFileElements [pfile] =
FileToXmlElement (d, project, pfile);
foreach (ProjectReference pref in
project.ProjectReferences)
- project.ExtendedProperties [pref] =
ReferenceToXmlNode (doc, project, pref);
+ d.ProjectReferenceElements [pref] =
ReferenceToXmlElement (d, project, pref);
SetupHandlers (project);
- doc.Save (project.FileName);
+ d.Document.Save (project.FileName);
}
//Reader
@@ -331,7 +342,9 @@
project.FileFormat = new MSBuildFileFormat (lang);
project.ClrVersion = ClrVersion.Net_2_0;
- project.ExtendedProperties ["xml_doc"] = doc;
+ MSBuildData data = new MSBuildData ();
+ data.Document = doc;
+ project.ExtendedProperties [typeof (MSBuildFileFormat)]
= data;
//Read the global config
XPathNodeIterator iter = nav.Select
("/tns:Project/tns:PropertyGroup[not(@Condition)]", NamespaceManager);
@@ -349,16 +362,14 @@
ReadConfig (iter.Current, globalConfig,
project.LanguageName, basePath, ref active_config);
//FIXME: Handle case when >1 global
PropertyGroups exist,
- //Note: No IConfiguration object is saved for
'global config'
- //so the nodes are saved with string
'global_config' as the key
- project.ExtendedProperties ["global_config"] =
iter.Current.UnderlyingObject;
+ data.GlobalConfigElement = (XmlElement)
iter.Current.UnderlyingObject;
}
if (guid != null)
- project.ExtendedProperties ["guid"] = guid.Trim
(new char [] {'{', '}'});
+ data.Guid = guid.Trim (new char [] {'{', '}'});
//ReadItemGroups : References, Source files etc
- ReadItemGroups (doc, project, globalConfig, basePath);
+ ReadItemGroups (data, project, globalConfig, basePath);
//Load configurations
iter = nav.Select ("/tns:Project/tns:[EMAIL
PROTECTED]", NamespaceManager);
@@ -384,7 +395,7 @@
ReadConfig (iter.Current, config,
project.LanguageName, basePath, ref tmp);
- project.ExtendedProperties [config] =
iter.Current.UnderlyingObject;
+ data.ConfigElements [config] = (XmlElement)
iter.Current.UnderlyingObject;
}
if (project.Configurations [active_config] != null)
@@ -430,41 +441,45 @@
//Event handlers
static void HandleConfigurationRemoved (object sender,
ConfigurationEventArgs e)
{
- DotNetProject project = sender as DotNetProject;
- if (project == null)
+ DotNetProject project = (DotNetProject) sender;
+ MSBuildData d = (MSBuildData)
project.ExtendedProperties [typeof (MSBuildFileFormat)];
+ if (d == null || !d.ConfigElements.ContainsKey
((DotNetProjectConfiguration) e.Configuration))
return;
- XmlNode node = project.ExtendedProperties
[e.Configuration] as XmlNode;
- if (node == null) {
- Console.WriteLine ("node not found");
- return;
- }
-
- node.ParentNode.RemoveChild (node);
+ XmlElement elem = d.ConfigElements
[(DotNetProjectConfiguration)e.Configuration];
+ elem.ParentNode.RemoveChild (elem);
+ d.ConfigElements.Remove
((DotNetProjectConfiguration)e.Configuration);
}
//References
static void HandleReferenceRemoved (object sender,
ProjectReferenceEventArgs e)
{
- XmlNode node = e.Project.ExtendedProperties
[e.ProjectReference] as XmlNode;
+ MSBuildData d = (MSBuildData)
e.Project.ExtendedProperties [typeof (MSBuildFileFormat)];
+ if (d == null ||
!d.ProjectReferenceElements.ContainsKey (e.ProjectReference))
+ return;
- node.ParentNode.RemoveChild (node);
+ XmlElement elem = d.ProjectReferenceElements
[e.ProjectReference];
+ elem.ParentNode.RemoveChild (elem);
+ d.ProjectReferenceElements.Remove (e.ProjectReference);
}
static void HandleReferenceAdded (object sender,
ProjectReferenceEventArgs e)
{
try {
- XmlDocument doc = e.Project.ExtendedProperties
["xml_doc"] as XmlDocument;
- e.Project.ExtendedProperties
[e.ProjectReference] =
- ReferenceToXmlNode (doc, e.Project,
e.ProjectReference);
+ MSBuildData d = (MSBuildData)
e.Project.ExtendedProperties [typeof (MSBuildFileFormat)];
+ if (d == null)
+ return;
+
+ d.ProjectReferenceElements [e.ProjectReference]
=
+ ReferenceToXmlElement (d, e.Project,
e.ProjectReference);
} catch (Exception ex) {
Runtime.LoggingService.ErrorFormat ("{0}",
ex.Message);
- Console.WriteLine ("{0}", ex.Message);
+ Console.WriteLine ("{0}", ex.ToString ());
}
}
- static XmlNode ReferenceToXmlNode (XmlDocument doc, Project
project, ProjectReference projectRef)
+ static XmlElement ReferenceToXmlElement (MSBuildData d, Project
project, ProjectReference projectRef)
{
ReferenceType refType = projectRef.ReferenceType;
@@ -474,6 +489,7 @@
else
elemName = "Reference";
+ XmlDocument doc = d.Document;
XmlElement elem = doc.CreateElement (elemName, ns);
//Add the element to the document
@@ -508,9 +524,11 @@
reference =
Runtime.FileUtilityService.AbsoluteToRelativePath (
project.BaseDirectory, p.FileName);
- if (p.ExtendedProperties.Contains ("guid"))
- AppendChild (elem, "Project", ns,
String.Concat ("{", (string) p.ExtendedProperties ["guid"], "}"));
+ //FIXME: if (p.ExtendedProperties.Contains
("guid"))
+ if (d.Guid != null & d.Guid.Length != 0)
+ EnsureChildValue (elem, "Project", ns,
String.Concat ("{", (string) p.ExtendedProperties ["guid"], "}"));
+
AppendChild (elem, "Name", ns, p.Name);
break;
@@ -528,19 +546,25 @@
static void HandleFileRemoved (object sender,
ProjectFileEventArgs e)
{
- XmlElement elem = e.Project.ExtendedProperties
[e.ProjectFile] as XmlElement;
+ MSBuildData d = (MSBuildData)
e.Project.ExtendedProperties [typeof (MSBuildFileFormat)];
+ if (d == null || !d.ProjectFileElements.ContainsKey
(e.ProjectFile))
+ return;
+ XmlElement elem = d.ProjectFileElements [e.ProjectFile];
elem.ParentNode.RemoveChild (elem);
+ d.ProjectFileElements.Remove (e.ProjectFile);
}
static void HandleFileAdded (object sender,
ProjectFileEventArgs e)
{
- XmlDocument doc = e.Project.ExtendedProperties
["xml_doc"] as XmlDocument;
- e.Project.ExtendedProperties [e.ProjectFile] =
- FileToXmlNode (doc, e.Project, e.ProjectFile);
+ MSBuildData d = (MSBuildData)
e.Project.ExtendedProperties [typeof (MSBuildFileFormat)];
+ if (d == null)
+ return;
+
+ d.ProjectFileElements [e.ProjectFile] =
FileToXmlElement (d, e.Project, e.ProjectFile);
}
- static XmlNode FileToXmlNode (XmlDocument doc, Project project,
ProjectFile projectFile)
+ static XmlElement FileToXmlElement (MSBuildData d, Project
project, ProjectFile projectFile)
{
string name = BuildActionToString
(projectFile.BuildAction);
if (name == null) {
@@ -551,6 +575,7 @@
//FIXME: Subtype
+ XmlDocument doc = d.Document;
XmlElement elem = doc.CreateElement (name, ns);
elem.SetAttribute ("Include", projectFile.RelativePath);
@@ -570,17 +595,24 @@
static void HandleFileRenamed (object sender,
ProjectFileRenamedEventArgs e)
{
- XmlElement node = e.Project.ExtendedProperties
[e.ProjectFile] as XmlElement;
- node.SetAttribute ("Include",
e.ProjectFile.RelativePath);
+ MSBuildData d = (MSBuildData)
e.Project.ExtendedProperties [typeof (MSBuildFileFormat)];
+ if (d == null || !d.ProjectFileElements.ContainsKey
(e.ProjectFile))
+ return;
+
+ XmlElement elem = d.ProjectFileElements [e.ProjectFile];
+ elem.SetAttribute ("Include",
e.ProjectFile.RelativePath);
}
static void HandleFilePropertyChanged (object sender,
ProjectFileEventArgs e)
{
//Subtype, BuildAction, DependsOn, Data
- XmlNode node = e.Project.ExtendedProperties
[e.ProjectFile] as XmlNode;
- XmlDocument doc = e.Project.ExtendedProperties
["xml_doc"] as XmlDocument;
+ MSBuildData d = (MSBuildData)
e.Project.ExtendedProperties [typeof (MSBuildFileFormat)];
+ if (d == null || !d.ProjectFileElements.ContainsKey
(e.ProjectFile))
+ return;
+ XmlElement elem = d.ProjectFileElements [e.ProjectFile];
+
//BuildAction
string buildAction = BuildActionToString
(e.ProjectFile.BuildAction);
if (buildAction == null) {
@@ -589,27 +621,27 @@
return;
}
- if (node.LocalName != buildAction) {
- XmlElement elem = doc.CreateElement
(buildAction, ns);
- XmlNode parent = node.ParentNode;
+ if (elem.LocalName != buildAction) {
+ XmlElement newElem = d.Document.CreateElement
(buildAction, ns);
+ XmlNode parent = elem.ParentNode;
List<XmlNode> list = new List<XmlNode> ();
- foreach (XmlNode n in node.ChildNodes)
+ foreach (XmlNode n in elem.ChildNodes)
list.Add (n);
foreach (XmlNode n in list)
- elem.AppendChild (node.RemoveChild (n));
+ newElem.AppendChild (elem.RemoveChild
(n));
list.Clear ();
- foreach (XmlAttribute a in node.Attributes)
+ foreach (XmlAttribute a in elem.Attributes)
list.Add (a);
foreach (XmlAttribute a in list)
- elem.Attributes.Append
(node.Attributes.Remove (a));
+ newElem.Attributes.Append
(elem.Attributes.Remove (a));
- parent.RemoveChild (node);
- parent.AppendChild (elem);
+ parent.RemoveChild (elem);
+ parent.AppendChild (newElem);
- e.Project.ExtendedProperties [e.ProjectFile] =
elem;
+ d.ProjectFileElements [e.ProjectFile] = newElem;
}
//FIXME: Subtype, DependsOn, Data
@@ -635,11 +667,11 @@
//Reading
- void ReadItemGroups (XmlDocument doc, DotNetProject project,
+ void ReadItemGroups (MSBuildData data, DotNetProject project,
DotNetProjectConfiguration globalConfig, string
basePath)
{
//FIXME: This can also be Config/Platform specific,
handle it?
- XmlNodeList itemList = doc.SelectNodes
("/tns:Project/tns:ItemGroup", NamespaceManager);
+ XmlNodeList itemList = data.Document.SelectNodes
("/tns:Project/tns:ItemGroup", NamespaceManager);
StringBuilder importsBuilder = null;
if (project.LanguageName == "VBNet")
@@ -649,6 +681,9 @@
ProjectReference pr;
foreach (XmlNode itemGroup in itemList) {
foreach (XmlNode node in itemGroup.ChildNodes) {
+ if (node.NodeType !=
XmlNodeType.Element)
+ continue;
+
if (node.Attributes ["Include"] == null)
//FIXME: warning/error?
continue;
@@ -676,7 +711,8 @@
//Not in the Gac, has
HintPath
pr =
project.AddReference (MapAndResolvePath (basePath, hintPath));
}
- project.ExtendedProperties [pr]
= node;
+ data.ProjectReferenceElements
[pr] = (XmlElement) node;
+
break;
case "ProjectReference":
//Not using @Include currently,
instead using the Name
@@ -696,20 +732,20 @@
pr = new ProjectReference
(ReferenceType.Project, projName);
project.ProjectReferences.Add
(pr);
- project.ExtendedProperties [pr]
= node;
+ data.ProjectReferenceElements
[pr] = (XmlElement) node;
break;
case "Compile":
pf = project.AddFile
(MapAndResolvePath (basePath, include), BuildAction.Compile);
- project.ExtendedProperties [pf]
= node;
+ data.ProjectFileElements [pf] =
(XmlElement) node;
break;
case "None":
pf = project.AddFile
(MapAndResolvePath (basePath, include), BuildAction.Nothing);
- project.ExtendedProperties [pf]
= node;
+ data.ProjectFileElements [pf] =
(XmlElement) node;
break;
case "EmbeddedResource":
pf = project.AddFile
(MapAndResolvePath (basePath, include), BuildAction.EmbedAsResource);
- project.ExtendedProperties [pf]
= node;
+ data.ProjectFileElements [pf] =
(XmlElement) node;
break;
case "Import":
//FIXME: Keep nodes for each
import? List of imports?
@@ -857,7 +893,7 @@
//Utility methods
- XmlNode MoveToChild (XmlNode node, string localName)
+ static XmlNode MoveToChild (XmlNode node, string localName)
{
if (!node.HasChildNodes)
return null;
@@ -869,7 +905,7 @@
return null;
}
- void EnsureChildValue (XmlNode node, string localName, string
ns, object val)
+ internal static void EnsureChildValue (XmlNode node, string
localName, string ns, object val)
{
XmlNode n = MoveToChild (node, localName);
if (n == null) {
@@ -1009,4 +1045,66 @@
return null;
}
}
+
+ class MSBuildData
+ {
+ XmlDocument doc;
+ XmlElement globalConfigElement;
+ string guid;
+ List<string> extra;
+
+ Dictionary<DotNetProjectConfiguration, XmlElement>
configElements;
+
+ Dictionary<ProjectFile, XmlElement> projectFileElements;
+ Dictionary<ProjectReference, XmlElement>
projectReferenceElements;
+
+ public MSBuildData ()
+ {
+ }
+
+ public XmlDocument Document {
+ get { return doc; }
+ set { doc = value; }
+ }
+
+ public XmlElement GlobalConfigElement {
+ get { return globalConfigElement; }
+ set { globalConfigElement = value; }
+ }
+
+ public string Guid {
+ get { return guid; }
+ set { guid = value; }
+ }
+
+ public Dictionary<DotNetProjectConfiguration, XmlElement>
ConfigElements {
+ get {
+ if (configElements == null)
+ configElements = new
Dictionary<DotNetProjectConfiguration, XmlElement> ();
+ return configElements;
+ }
+ }
+
+ public Dictionary<ProjectFile, XmlElement> ProjectFileElements {
+ get {
+ if (projectFileElements == null)
+ projectFileElements = new
Dictionary<ProjectFile, XmlElement> ();
+ return projectFileElements;
+ }
+ }
+
+ public Dictionary<ProjectReference, XmlElement>
ProjectReferenceElements {
+ get {
+ if (projectReferenceElements == null)
+ projectReferenceElements = new
Dictionary<ProjectReference, XmlElement> ();
+ return projectReferenceElements;
+ }
+ }
+
+ public List<string> Extra {
+ get { return extra; }
+ set { extra = value;}
+ }
+
+ }
}
Modified: trunk/monodevelop/Extras/prj2make-sharp-lib/SlnFileFormat.cs
===================================================================
--- trunk/monodevelop/Extras/prj2make-sharp-lib/SlnFileFormat.cs
2006-12-07 20:26:09 UTC (rev 69201)
+++ trunk/monodevelop/Extras/prj2make-sharp-lib/SlnFileFormat.cs
2006-12-07 20:45:29 UTC (rev 69202)
@@ -72,6 +72,8 @@
if (c.ParentCombine != null)
//Not the top most solution
return;
+ if (!c.ExtendedProperties.Contains (typeof
(SlnFileFormat)))
+ throw new Exception ("Writing only supported
for vs2005 projects (yet)");
using (StreamWriter sw = new StreamWriter (file, false,
Encoding.UTF8)) {
//Write Header
@@ -91,6 +93,7 @@
string s = (string)
config.ExtendedProperties ["SolutionConfigurationPlatforms"];
if (String.IsNullOrEmpty (s))
//FIXME: Platforms
+ //FIXME: Add this new string to
config.ExtendedProperties
sw.WriteLine ("\t\t{0}|{1} =
{0}|{1}", config.Name, "Any CPU");
else
sw.WriteLine ("\t\t{0}", s);
@@ -107,9 +110,10 @@
//FIXME: .ActiveCfg
//Write 'others'
- List<string> others = c.ExtendedProperties
["global_extras"] as List<string>;
- if (others != null) {
- foreach (string s in others)
+
+ SlnData data = (SlnData) c.ExtendedProperties
[typeof (SlnFileFormat)];
+ if (data.GlobalExtra != null) {
+ foreach (string s in data.GlobalExtra)
sw.WriteLine (s);
}
@@ -122,14 +126,42 @@
foreach (CombineEntry ce in combine.Entries) {
Combine c = ce as Combine;
- writer.WriteLine (@"Project(""{{{0}}}"") =
""{1}"", ""{2}"", ""{{{3}}}""",
- (c != null) ? folderTypeGuid.ToString
().ToUpper () : projectTypeGuid.ToString ().ToUpper (),
- ce.Name,
- (c != null) ? ce.Name :
Runtime.FileUtilityService.AbsoluteToRelativePath (baseDirectory, ce.FileName),
- //FIXME: "guid" is avail only incase of
msbuild projects..
- (string) ce.ExtendedProperties
["guid"]);
+ List<string> l = null;
+ if (c == null) {
+ //Project
+ MSBuildData msbData = (MSBuildData)
ce.ExtendedProperties [typeof (MSBuildFileFormat)];
+ if (msbData == null)
+ //This should not happen as any
.mdp would've been converted to
+ //.*proj and so would have this
object
+ //FIXME : But can happen for
unsupported project types.. eg. md-unit
+ throw new Exception
(String.Format (
+ "INTERNAL ERROR:
Project named '{0}', filename = {1}, does not have a 'data' object.",
+ ce.Name, ce.FileName));
- List<string> l = ce.ExtendedProperties
["extra"] as List<string>;
+ l = msbData.Extra;
+
+ writer.WriteLine
(@"Project(""{{{0}}}"") = ""{1}"", ""{2}"", ""{{{3}}}""",
+ projectTypeGuid.ToString
().ToUpper (),
+ ce.Name,
+
Runtime.FileUtilityService.AbsoluteToRelativePath (baseDirectory, ce.FileName),
+ msbData.Guid);
+ } else {
+ //Solution
+ SlnData slnData = (SlnData)
c.ExtendedProperties [typeof (SlnFileFormat)];
+ if (slnData == null)
+ throw new Exception
(String.Format (
+ "INTERNAL ERROR:
Solution named '{0}', filename = {1}, does not have a 'data' object.",
+ ce.Name, ce.FileName));
+
+ l = slnData.Extra;
+
+ writer.WriteLine
(@"Project(""{{{0}}}"") = ""{1}"", ""{2}"", ""{{{3}}}""",
+ folderTypeGuid.ToString
().ToUpper (),
+ ce.Name,
+ ce.Name,
+ slnData.Guid);
+ }
+
if (l != null) {
foreach (string s in l)
writer.WriteLine (s);
@@ -151,11 +183,28 @@
WriteNestedProjects (c, writer);
}
- string guid = (string) combine.ExtendedProperties
["guid"];
+ SlnData data = (SlnData) combine.ExtendedProperties
[typeof (SlnFileFormat)];
+ if (data == null)
+ throw new Exception (String.Format (
+ "INTERNAL ERROR: Solution named '{0}',
filename = {1}, does not have a 'data' object.",
+ combine.Name, combine.FileName));
+
+ string containerGuid = data.Guid;
Combine root = combine.RootCombine;
foreach (CombineEntry ce in combine.Entries) {
- if (ce.ParentCombine != root)
- writer.WriteLine (@"{0}{{{1}}} =
{{{2}}}", "\t\t", (string) ce.ExtendedProperties ["guid"], guid);
+ if (ce.ParentCombine == root)
+ continue;
+
+ string containeeGuid = null;
+ if (ce is Combine) {
+ SlnData slnData = (SlnData)
ce.ExtendedProperties [typeof (SlnFileFormat)];
+ containeeGuid = slnData.Guid;
+ } else {
+ MSBuildData msbData = (MSBuildData)
ce.ExtendedProperties [typeof (MSBuildFileFormat)];
+ containeeGuid = msbData.Guid;
+ }
+
+ writer.WriteLine (@"{0}{{{1}}} = {{{2}}}",
"\t\t", containeeGuid, containerGuid);
}
}
@@ -215,13 +264,17 @@
Project p = (Project)
allProjects [pref.Reference];
- XmlElement elem =
(XmlElement) proj.ExtendedProperties [pref];
+ //FIXME: Move this to
MSBuildFileFormat ?
+ MSBuildData data =
(MSBuildData) proj.ExtendedProperties [typeof (MSBuildFileFormat)];
+ XmlElement elem =
data.ProjectReferenceElements [pref];
elem.SetAttribute
("Include",
Runtime.FileUtilityService.AbsoluteToRelativePath (
proj.BaseDirectory, p.FileName));
-
MSBuildFileFormat.AppendChild (elem, "Project", MSBuildFileFormat.ns,
- String.Concat
("{", (string) p.ExtendedProperties ["guid"], "}"));
+ //Set guid of the
ProjectReference
+ MSBuildData prefData =
(MSBuildData) p.ExtendedProperties [typeof (MSBuildFileFormat)];
+
MSBuildFileFormat.EnsureChildValue (elem, "Project", MSBuildFileFormat.ns,
+ String.Concat
("{", prefData.Guid, "}"));
}
}
}
@@ -231,7 +284,7 @@
e.CombineEntry.RootCombine.FileName =
e.CombineEntry.RootCombine.FileName;
} catch (Exception ex) {
Runtime.LoggingService.DebugFormat ("{0}",
ex.Message);
- Console.WriteLine ("{0}", ex.Message);
+ Console.WriteLine ("HandleCombineEntryAdded :
{0}", ex.ToString ());
}
}
@@ -242,9 +295,6 @@
if (newCombine == null) {
if (String.Compare (Path.GetExtension
(ce.FileName), ".mdp", true) == 0) {
DotNetProject project = (DotNetProject)
ce;
-
- project.ExtendedProperties ["guid"] =
Guid.NewGuid ().ToString ().ToUpper ();
-
MSBuildFileFormat fileFormat = new
MSBuildFileFormat (project.LanguageName);
project.FileFormat = fileFormat;
@@ -257,9 +307,14 @@
//FIXME: Remove the empty mds created for this
solution folder
//File.Delete (newCombine.FileName);
- if (newCombine.ExtendedProperties ["guid"] ==
null)
- newCombine.ExtendedProperties ["guid"]
= Guid.NewGuid ().ToString ().ToUpper ();
+ SlnData slnData = (SlnData)
newCombine.ExtendedProperties [typeof (SlnFileFormat)];
+ if (slnData == null) {
+ slnData = new SlnData ();
+ newCombine.ExtendedProperties [typeof
(SlnFileFormat)] = slnData;
+ }
+ slnData.Guid = Guid.NewGuid ().ToString
().ToUpper ();
+
if (String.Compare (Path.GetExtension
(newCombine.FileName), ".mds", true) == 0) {
foreach (CombineEntry e in
newCombine.Entries)
ConvertToMSBuild (e, false);
@@ -269,6 +324,7 @@
SetHandlers (newCombine, false);
converted = true;
}
+
//This is set to ensure that the solution
folder's BaseDirectory
//(which is derived from .FileName) matches
that of the root
//combine
@@ -302,6 +358,7 @@
ListDictionary globals = null;
Combine combine = null;
+ SlnData data = null;
List<Section> projectSections = null;
List<string> lines = null;
@@ -311,6 +368,8 @@
combine.Name = Path.GetFileNameWithoutExtension
(fileName);
combine.FileName = fileName;
combine.FileFormat = new SlnFileFormat ();
+ data = new SlnData ();
+ combine.ExtendedProperties [typeof
(SlnFileFormat)] = data;
string s = null;
projectSections = new List<Section> ();
@@ -374,9 +433,12 @@
folder.FileName = projectPath;
folder.FileFormat = new SlnFileFormat
();
- folder.ExtendedProperties ["guid"] =
projectGuid.Trim (new char [] {'{', '}'});
- folder.ExtendedProperties ["extra"] =
lines.GetRange (sec.Start + 1, sec.Count - 2);
+ SlnData slnData = new SlnData ();
+ folder.ExtendedProperties [typeof
(SlnFileFormat)] = slnData;
+ slnData.Guid = projectGuid.Trim (new
char [] {'{', '}'});
+ slnData.Extra = lines.GetRange
(sec.Start + 1, sec.Count - 2);
+
entries [projectGuid] = folder;
continue;
@@ -396,8 +458,8 @@
DotNetProject project =
Services.ProjectService.ReadFile (projectPath, monitor) as DotNetProject;
project.Name = projectName;
entries [projectGuid] = project;
- project.ExtendedProperties
["extra"] =
- lines.GetRange
(sec.Start + 1, sec.Count - 2);
+ MSBuildData msbData =
(MSBuildData) project.ExtendedProperties [typeof (MSBuildFileFormat)];
+ msbData.Extra = lines.GetRange
(sec.Start + 1, sec.Count - 2);
} catch {
//
}
@@ -431,7 +493,7 @@
foreach (Section sec in globals.Values)
globalLines.InsertRange (globalLines.Count,
lines.GetRange (sec.Start, sec.Count));
- combine.ExtendedProperties ["global_extras"] =
globalLines;
+ data.GlobalExtra = globalLines;
return combine;
}
@@ -498,10 +560,6 @@
config.ExtendedProperties.Add
("Platform", key_parts [1]);
}
- //Add all the projects to the configurations
- foreach (CombineEntry entry in combine.Entries)
- config.AddEntry (entry);
-
config.ExtendedProperties.Add
("SolutionConfigurationPlatforms", s);
}
}
@@ -661,5 +719,35 @@
}
}
+ class SlnData
+ {
+ string guid;
+ Dictionary<CombineConfiguration, string> configStrings;
+ List<string> globalExtra; // unused GlobalSections
+ List<string> extra; //used by solution folders..
+
+ public string Guid {
+ get { return guid; }
+ set { guid = value; }
+ }
+
+ public Dictionary<CombineConfiguration, string>
ConfigStrings {
+ get {
+ if (configStrings == null)
+ configStrings = new
Dictionary<CombineConfiguration, string> ();
+ return configStrings;
+ }
+ }
+
+ public List<string> GlobalExtra {
+ get { return globalExtra; }
+ set { globalExtra = value; }
+ }
+
+ public List<string> Extra {
+ get { return extra; }
+ set { extra = value; }
+ }
+ }
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches