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
diff options
context:
space:
mode:
authorLluis Sanchez Gual <lluis@xamarin.com>2015-04-15 19:09:10 +0300
committerLluis Sanchez Gual <lluis@xamarin.com>2015-04-15 22:01:36 +0300
commit38dc2dac674c7e7b26e940b9c13a5e5caec73d38 (patch)
tree5065c0c574196768268ef0f071ea30542fd1dccf /main/src/addins/MonoDevelop.Autotools
parented0a5dcd1278be0b3e70dce146cf67b2409c4141 (diff)
Fix serialization of custom data
Properly implement serialization of custom data for the autotools add-in and the linux deployment add-ins.
Diffstat (limited to 'main/src/addins/MonoDevelop.Autotools')
-rw-r--r--main/src/addins/MonoDevelop.Autotools/FileNodeBuilderExtension.cs8
-rw-r--r--main/src/addins/MonoDevelop.Autotools/MakefileData.cs22
-rw-r--r--main/src/addins/MonoDevelop.Autotools/MakefileOptionPanel.cs2
-rw-r--r--main/src/addins/MonoDevelop.Autotools/MakefileOptionPanelWidget.cs4
-rw-r--r--main/src/addins/MonoDevelop.Autotools/MakefileProjectServiceExtension.cs23
-rw-r--r--main/src/addins/MonoDevelop.Autotools/MonoDevelop.Autotools.addin.xml5
-rw-r--r--main/src/addins/MonoDevelop.Autotools/PropertyProvider.cs4
7 files changed, 43 insertions, 25 deletions
diff --git a/main/src/addins/MonoDevelop.Autotools/FileNodeBuilderExtension.cs b/main/src/addins/MonoDevelop.Autotools/FileNodeBuilderExtension.cs
index 1c90564ec3..882ea0a81e 100644
--- a/main/src/addins/MonoDevelop.Autotools/FileNodeBuilderExtension.cs
+++ b/main/src/addins/MonoDevelop.Autotools/FileNodeBuilderExtension.cs
@@ -22,8 +22,6 @@ namespace MonoDevelop.Autotools
class FileNodeCommandHandler: NodeCommandHandler
{
- const string infoProperty = "MonoDevelop.Autotools.MakefileInfo";
-
[CommandHandler (Commands.SynchWithMakefile)]
[AllowMultiSelection]
public void OnExclude ()
@@ -34,7 +32,7 @@ namespace MonoDevelop.Autotools
foreach (ITreeNavigator node in CurrentNodes) {
ProjectFile file = (ProjectFile) node.DataItem;
if (file.Project != null) {
- MakefileData data = file.Project.ExtendedProperties [infoProperty] as MakefileData;
+ MakefileData data = file.Project.GetMakefileData ();
if (data != null && data.IsFileIntegrationEnabled (file.BuildAction)) {
if (data.IsFileExcluded (file.FilePath)) {
allChecked = false;
@@ -50,7 +48,7 @@ namespace MonoDevelop.Autotools
ProjectFile file = (ProjectFile) node.DataItem;
if (file.Project != null) {
projects.Add (file.Project);
- MakefileData data = file.Project.ExtendedProperties [infoProperty] as MakefileData;
+ MakefileData data = file.Project.GetMakefileData ();
if (data != null && data.IntegrationEnabled) {
data.SetFileExcluded (file.FilePath, allChecked);
}
@@ -71,7 +69,7 @@ namespace MonoDevelop.Autotools
foreach (ITreeNavigator node in CurrentNodes) {
ProjectFile file = (ProjectFile) node.DataItem;
if (file.Project != null) {
- MakefileData data = file.Project.ExtendedProperties [infoProperty] as MakefileData;
+ MakefileData data = file.Project.GetMakefileData ();
if (data != null && data.IsFileIntegrationEnabled (file.BuildAction)) {
anyEnabled = true;
if (!data.IsFileExcluded (file.FilePath)) {
diff --git a/main/src/addins/MonoDevelop.Autotools/MakefileData.cs b/main/src/addins/MonoDevelop.Autotools/MakefileData.cs
index 01a6b1cb51..6f7803c4a7 100644
--- a/main/src/addins/MonoDevelop.Autotools/MakefileData.cs
+++ b/main/src/addins/MonoDevelop.Autotools/MakefileData.cs
@@ -39,10 +39,11 @@ using MonoDevelop.Projects;
using MonoDevelop.Core.Assemblies;
using MonoDevelop.Ide;
using System.Xml;
+using MonoDevelop.Projects.Formats.MSBuild;
namespace MonoDevelop.Autotools
{
- [DataItem ("MakefileInfo")]
+ [DataItem ("MonoDevelop.Autotools.MakefileInfo")]
public class MakefileData : ICloneable
{
bool integrationEnabled;
@@ -81,6 +82,7 @@ namespace MonoDevelop.Autotools
public XmlElement Write ()
{
XmlDataSerializer ser = new XmlDataSerializer (new DataContext ());
+ ser.Namespace = MSBuildProject.Schema;
var sw = new StringWriter ();
ser.Serialize (new XmlTextWriter (sw), this);
XmlDocument doc = new XmlDocument ();
@@ -1207,7 +1209,7 @@ namespace MonoDevelop.Autotools
}
foreach (DotNetProject sproj in projects.Values) {
- MakefileData mdata = sproj.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData;
+ MakefileData mdata = sproj.GetMakefileData ();
if (mdata == null)
continue;
@@ -1858,4 +1860,20 @@ namespace MonoDevelop.Autotools
this.Name = name;
}
}
+
+ internal static class MakefileDataExtension
+ {
+ public static MakefileData GetMakefileData (this Project project)
+ {
+ var ex = project.GetService<MakefileProjectExtension> ();
+ return ex != null ? ex.MakefileData : null;
+ }
+
+ public static void SetMakefileData (this Project project, MakefileData data)
+ {
+ var ex = project.GetService<MakefileProjectExtension> ();
+ if (ex != null)
+ ex.MakefileData = data;
+ }
+ }
}
diff --git a/main/src/addins/MonoDevelop.Autotools/MakefileOptionPanel.cs b/main/src/addins/MonoDevelop.Autotools/MakefileOptionPanel.cs
index aad187c6ef..4ac8a3e0b1 100644
--- a/main/src/addins/MonoDevelop.Autotools/MakefileOptionPanel.cs
+++ b/main/src/addins/MonoDevelop.Autotools/MakefileOptionPanel.cs
@@ -16,7 +16,7 @@ namespace MonoDevelop.Autotools
public override Widget CreatePanelWidget()
{
Project project = ConfiguredProject;
- MakefileData data = project.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData;
+ MakefileData data = project.GetMakefileData ();
MakefileData tmpData = null;
if (data != null) {
diff --git a/main/src/addins/MonoDevelop.Autotools/MakefileOptionPanelWidget.cs b/main/src/addins/MonoDevelop.Autotools/MakefileOptionPanelWidget.cs
index f245686308..2b8e9474df 100644
--- a/main/src/addins/MonoDevelop.Autotools/MakefileOptionPanelWidget.cs
+++ b/main/src/addins/MonoDevelop.Autotools/MakefileOptionPanelWidget.cs
@@ -205,7 +205,7 @@ namespace MonoDevelop.Autotools
// Data validation
- MakefileData oldData = project.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData;
+ MakefileData oldData = project.GetMakefileData ();
MakefileData tmpData = data;
if (tmpData.IntegrationEnabled) {
@@ -266,7 +266,7 @@ namespace MonoDevelop.Autotools
}
//FIXME: Do this only if there are changes b/w tmpData and Data
- project.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] = tmpData;
+ project.SetMakefileData (tmpData);
using (ProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetStatusProgressMonitor (
GettextCatalog.GetString ("Updating project"), "gtk-run", true)) {
diff --git a/main/src/addins/MonoDevelop.Autotools/MakefileProjectServiceExtension.cs b/main/src/addins/MonoDevelop.Autotools/MakefileProjectServiceExtension.cs
index 8989dcfb5d..560bd8a429 100644
--- a/main/src/addins/MonoDevelop.Autotools/MakefileProjectServiceExtension.cs
+++ b/main/src/addins/MonoDevelop.Autotools/MakefileProjectServiceExtension.cs
@@ -71,6 +71,15 @@ namespace MonoDevelop.Autotools
{
MakefileData data;
+ public MakefileProjectExtension ()
+ {
+ }
+
+ public MakefileData MakefileData {
+ get { return data; }
+ set { data = value; }
+ }
+
protected override void OnReadProject (ProgressMonitor monitor, MonoDevelop.Projects.Formats.MSBuild.MSBuildProject msproject)
{
base.OnReadProject (monitor, msproject);
@@ -100,11 +109,14 @@ namespace MonoDevelop.Autotools
{
base.OnWriteProject (monitor, msproject);
- if (data == null || !data.SupportsIntegration)
+ if (data == null)
return;
- msproject.SetProjectExtension ("MonoDevelop.Autotools.MakefileInfo", data.Write ());
+ msproject.SetMonoDevelopProjectExtension ("MonoDevelop.Autotools.MakefileInfo", data.Write ());
+ if (!data.SupportsIntegration)
+ return;
+
try {
data.UpdateMakefile (monitor);
} catch (Exception e) {
@@ -119,7 +131,6 @@ namespace MonoDevelop.Autotools
{
List<FilePath> col = base.OnGetItemFiles (includeReferencedFiles).ToList ();
- MakefileData data = Project.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData;
if (data == null || !data.SupportsIntegration || string.IsNullOrEmpty (data.AbsoluteMakefileName))
return col;
@@ -138,7 +149,6 @@ namespace MonoDevelop.Autotools
//FIXME: Check whether autogen.sh is required or not
protected async override Task<BuildResult> OnBuild (ProgressMonitor monitor, ConfigurationSelector configuration)
{
- MakefileData data = Project.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData;
if (data == null || !data.SupportsIntegration || String.IsNullOrEmpty (data.BuildTargetName))
return await base.OnBuild (monitor, configuration);
@@ -322,7 +332,6 @@ namespace MonoDevelop.Autotools
protected async override Task<BuildResult> OnClean (ProgressMonitor monitor, ConfigurationSelector configuration)
{
- MakefileData data = Project.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData;
if (data == null || !data.SupportsIntegration || String.IsNullOrEmpty (data.CleanTargetName)) {
return await base.OnClean (monitor, configuration);
}
@@ -363,7 +372,6 @@ namespace MonoDevelop.Autotools
protected override bool OnGetCanExecute (ExecutionContext context, ConfigurationSelector configuration)
{
- MakefileData data = Project.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData;
if (data != null && data.SupportsIntegration && !String.IsNullOrEmpty (data.ExecuteTargetName))
return true;
return base.OnGetCanExecute (context, configuration);
@@ -372,9 +380,8 @@ namespace MonoDevelop.Autotools
protected async override Task OnExecute (ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
{
- MakefileData data = Project.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData;
if (data == null || !data.SupportsIntegration || String.IsNullOrEmpty (data.ExecuteTargetName)) {
- base.OnExecute (monitor, context, configuration);
+ await base.OnExecute (monitor, context, configuration);
return;
}
diff --git a/main/src/addins/MonoDevelop.Autotools/MonoDevelop.Autotools.addin.xml b/main/src/addins/MonoDevelop.Autotools/MonoDevelop.Autotools.addin.xml
index 41688c50e1..aa3a14dbaa 100644
--- a/main/src/addins/MonoDevelop.Autotools/MonoDevelop.Autotools.addin.xml
+++ b/main/src/addins/MonoDevelop.Autotools/MonoDevelop.Autotools.addin.xml
@@ -105,11 +105,6 @@
</Condition>
</Extension>
- <Extension path = "/MonoDevelop/ProjectModel/ExtendedProperties">
- <ItemProperty class = "MonoDevelop.Projects.Project"
- name = "MonoDevelop.Autotools.MakefileInfo" type = "MonoDevelop.Autotools.MakefileData" />
- </Extension>
-
<Extension path = "/MonoDevelop/DesignerSupport/PropertyProviders">
<Condition id="Platform" value="!windows">
<Class class = "MonoDevelop.Autotools.PropertyProvider"/>
diff --git a/main/src/addins/MonoDevelop.Autotools/PropertyProvider.cs b/main/src/addins/MonoDevelop.Autotools/PropertyProvider.cs
index ef96d97d0f..368ce87e2f 100644
--- a/main/src/addins/MonoDevelop.Autotools/PropertyProvider.cs
+++ b/main/src/addins/MonoDevelop.Autotools/PropertyProvider.cs
@@ -12,7 +12,7 @@ namespace MonoDevelop.Autotools
{
ProjectFile file = obj as ProjectFile;
if (file != null && file.Project != null) {
- MakefileData data = file.Project.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData;
+ MakefileData data = file.Project.GetMakefileData ();
if (data != null && data.IsFileIntegrationEnabled (file.BuildAction))
return true;
}
@@ -33,7 +33,7 @@ namespace MonoDevelop.Autotools
public ProjectFileWrapper (ProjectFile file)
{
this.file = file;
- data = file.Project.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData;
+ data = file.Project.GetMakefileData ();
}
[LocalizedCategory ("Makefile Integration")]