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 <slluis.devel@gmail.com>2015-03-13 22:18:29 +0300
committerLluis Sanchez <slluis.devel@gmail.com>2015-03-13 22:18:29 +0300
commitf8e52bf493869b6a320a95400553dc9ea8b7ef22 (patch)
tree603f9019a83d5221b52e4970c5e314c5f0975c70
parent8deb45731afdc20fc720bf293c5aebf796d99363 (diff)
parent84d4487760b917ac190bf713c5b14bd0a9421d0b (diff)
Merge pull request #797 from DavidKarlas/bug27973monodevelop-5.8.1.8
Bug 27973 - On adding Xaml file in Forms Shared project, XS gives error message.
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CustomTools/CustomToolService.cs86
1 files changed, 55 insertions, 31 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CustomTools/CustomToolService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CustomTools/CustomToolService.cs
index dedba299ab..6c3e3a6d1e 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CustomTools/CustomToolService.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CustomTools/CustomToolService.cs
@@ -120,19 +120,58 @@ namespace MonoDevelop.Ide.CustomTools
}
}
+ static bool ShouldRunGenerator (ProjectFile file, bool force, out ISingleFileCustomTool tool, out ProjectFile genFile)
+ {
+ tool = null;
+ genFile = null;
+
+ //ignore cloned file from shared project in context of referencing project
+ if ((file.Flags & ProjectItemFlags.DontPersist) != 0) {
+ return false;
+ }
+
+ tool = GetGenerator (file.Generator);
+ if (tool == null) {
+ return false;
+ }
+
+ //ignore MSBuild tool for projects that aren't MSBuild or can't build
+ //we could emit a warning but this would get very annoying for Xamarin Forms + SAP
+ //in future we could consider running the MSBuild generator in context of every referencing project
+ if (tool is MSBuildCustomTool) {
+ if (!file.Project.SupportsBuild ()) {
+ return false;
+ }
+ bool byDefault, require;
+ MonoDevelop.Projects.Formats.MSBuild.MSBuildProjectService.CheckHandlerUsesMSBuildEngine (file.Project, out byDefault, out require);
+ var usesMSBuild = require || (file.Project.UseMSBuildEngine ?? byDefault);
+ if (!usesMSBuild) {
+ return false;
+ }
+ }
+
+ if (!string.IsNullOrEmpty (file.LastGenOutput)) {
+ genFile = file.Project.Files.GetFile (file.FilePath.ParentDirectory.Combine (file.LastGenOutput));
+ }
+
+ return force
+ || genFile == null
+ || !File.Exists (genFile.FilePath)
+ || File.GetLastWriteTime (file.FilePath) > File.GetLastWriteTime (genFile.FilePath);
+ }
+
static void Update (IProgressMonitor monitor, IEnumerator<ProjectFile> fileEnumerator, bool force, int succeeded, int warnings, int errors)
{
ProjectFile file = fileEnumerator.Current;
- ProjectFile genFile = null;
ISingleFileCustomTool tool;
+ ProjectFile genFile;
- //Find the first file in the collection, which has got generator tool
- while (((tool = GetGenerator (file.Generator)) == null
- || (genFile = GetGeneratedFile (file, force)) == null)
- && fileEnumerator.MoveNext ());
+ bool shouldRun;
+ while (!(shouldRun = ShouldRunGenerator (file, force, out tool, out genFile)) && fileEnumerator.MoveNext ())
+ continue;
//no files which can be generated in remaining elements of the collection, nothing to do
- if (tool == null || genFile == null) {
+ if (!shouldRun) {
WriteSummaryResults (monitor, succeeded, warnings, errors);
return;
}
@@ -196,29 +235,14 @@ namespace MonoDevelop.Ide.CustomTools
monitor.Dispose ();
}
- static ProjectFile GetGeneratedFile (ProjectFile file, bool force)
- {
- ProjectFile genFile = null;
-
- if (!string.IsNullOrEmpty (file.LastGenOutput))
- genFile = file.Project.Files.GetFile (file.FilePath.ParentDirectory.Combine (file.LastGenOutput));
-
- if (!force && genFile != null && File.Exists (genFile.FilePath) &&
- File.GetLastWriteTime (file.FilePath) < File.GetLastWriteTime (genFile.FilePath)) {
- return null;
- }
-
- return genFile;
- }
-
public static void Update (ProjectFile file, bool force)
{
- var tool = GetGenerator (file.Generator);
- if (tool == null)
+ ISingleFileCustomTool tool;
+ ProjectFile genFile;
+ if (!ShouldRunGenerator (file, force, out tool, out genFile)) {
return;
+ }
- ProjectFile genFile = GetGeneratedFile(file, force);
-
TaskService.Errors.ClearByOwner (file);
//if this file is already being run, cancel it
@@ -290,7 +314,7 @@ namespace MonoDevelop.Ide.CustomTools
null : result.GeneratedFilePath.ToRelative (file.FilePath.ParentDirectory);
if (!string.IsNullOrEmpty (genFileName)) {
- bool validName = genFileName.IndexOfAny (new char[] { '/', '\\' }) < 0
+ bool validName = genFileName.IndexOfAny (new [] { '/', '\\' }) < 0
&& FileService.IsValidFileName (genFileName);
if (!broken && !validName) {
@@ -374,11 +398,11 @@ namespace MonoDevelop.Ide.CustomTools
public static string GetFileNamespace (ProjectFile file, string outputFile)
{
string ns = file.CustomToolNamespace;
- if (string.IsNullOrEmpty (ns) && !string.IsNullOrEmpty (outputFile)) {
- var dnp = file.Project as DotNetProject;
- if (dnp != null)
- ns = dnp.GetDefaultNamespace (outputFile);
- }
+ if (!string.IsNullOrEmpty (ns) || string.IsNullOrEmpty (outputFile))
+ return ns;
+ var dnfc = file.Project as IDotNetFileContainer;
+ if (dnfc != null)
+ return dnfc.GetDefaultNamespace (outputFile);
return ns;
}