diff --git a/src/AddIns/BackendBindings/WixBinding/Project/Src/Project/WixProject.cs b/src/AddIns/BackendBindings/WixBinding/Project/Src/Project/WixProject.cs
index 06559808ef..ca21aeefea 100644
--- a/src/AddIns/BackendBindings/WixBinding/Project/Src/Project/WixProject.cs
+++ b/src/AddIns/BackendBindings/WixBinding/Project/Src/Project/WixProject.cs
@@ -57,14 +57,16 @@ namespace ICSharpCode.WixBinding
public override void Start(bool withDebugging)
{
- withDebugging = false;
+ base.Start(false); // debugging not supported
+ }
+
+ public override System.Diagnostics.ProcessStartInfo CreateStartInfo()
+ {
switch (StartAction) {
case StartAction.Project:
- Start(InstallerFullPath, withDebugging);
- break;
+ return CreateStartInfo(InstallerFullPath);
default:
- base.Start(withDebugging);
- break;
+ return base.CreateStartInfo();
}
}
diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
index caa209fb82..013f671baa 100644
--- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
+++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
@@ -127,6 +127,7 @@
+
diff --git a/src/Main/Base/Project/Src/Project/AbstractProject.cs b/src/Main/Base/Project/Src/Project/AbstractProject.cs
index 9913fe910c..46ec75b092 100644
--- a/src/Main/Base/Project/Src/Project/AbstractProject.cs
+++ b/src/Main/Base/Project/Src/Project/AbstractProject.cs
@@ -13,6 +13,7 @@ using System.Diagnostics;
using System.IO;
using ICSharpCode.Core;
+using ICSharpCode.SharpDevelop.Debugging;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.SharpDevelop.Project
@@ -360,6 +361,28 @@ namespace ICSharpCode.SharpDevelop.Project
}
public virtual void Start(bool withDebugging)
+ {
+ ProcessStartInfo psi;
+ try {
+ psi = CreateStartInfo();
+ } catch (ProjectStartException ex) {
+ MessageService.ShowError(ex.Message);
+ return;
+ }
+ if (withDebugging && !FileUtility.IsUrl(psi.FileName)) {
+ DebuggerService.CurrentDebugger.Start(psi);
+ } else {
+ DebuggerService.CurrentDebugger.StartWithoutDebugging(psi);
+ }
+ }
+
+ ///
+ /// Creates the start info used to start the project.
+ ///
+ /// Occurs when the project cannot be started.
+ /// ProcessStartInfo used to start the project.
+ /// Note: this can be a ProcessStartInfo with a URL as filename!
+ public virtual ProcessStartInfo CreateStartInfo()
{
throw new NotSupportedException();
}
diff --git a/src/Main/Base/Project/Src/Project/CompilableProject.cs b/src/Main/Base/Project/Src/Project/CompilableProject.cs
index f79ce3251e..74484ba962 100644
--- a/src/Main/Base/Project/Src/Project/CompilableProject.cs
+++ b/src/Main/Base/Project/Src/Project/CompilableProject.cs
@@ -228,12 +228,32 @@ namespace ICSharpCode.SharpDevelop.Project
return text;
}
+ [Obsolete("Override CreateStartInfo instead of using Start()")]
protected void Start(string program, bool withDebugging)
+ {
+ ProcessStartInfo psi;
+ try {
+ psi = CreateStartInfo();
+ } catch (ProjectStartException ex) {
+ MessageService.ShowError(ex.Message);
+ return;
+ }
+ if (withDebugging) {
+ DebuggerService.CurrentDebugger.Start(psi);
+ } else {
+ DebuggerService.CurrentDebugger.StartWithoutDebugging(psi);
+ }
+ }
+
+ ///
+ /// Creates a for the specified program, using
+ /// arguments and working directory from the project options.
+ ///
+ protected ProcessStartInfo CreateStartInfo(string program)
{
program = RemoveQuotes(program);
if (!FileUtility.IsValidPath(program)) {
- MessageService.ShowError(program + " is not a valid path; the process cannot be started.");
- return;
+ throw new ProjectStartException(program + " is not a valid path; the process cannot be started.");
}
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = Path.Combine(Directory, program);
@@ -245,41 +265,33 @@ namespace ICSharpCode.SharpDevelop.Project
workingDir = RemoveQuotes(workingDir);
if (!FileUtility.IsValidPath(workingDir)) {
- MessageService.ShowError("Working directory " + workingDir + " is invalid; the process cannot be started. You can specify the working directory in the project options.");
- return;
+ throw new ProjectStartException("Working directory '" + workingDir + "' is invalid; the process cannot be started. You can specify the working directory in the project options.");
}
psi.WorkingDirectory = Path.Combine(Directory, workingDir);
}
psi.Arguments = StringParser.Parse(this.StartArguments);
if (!File.Exists(psi.FileName)) {
- MessageService.ShowError(psi.FileName + " does not exist and cannot be started.");
- return;
+ throw new ProjectStartException(psi.FileName + " does not exist and cannot be started.");
}
if (!System.IO.Directory.Exists(psi.WorkingDirectory)) {
- MessageService.ShowError("Working directory " + psi.WorkingDirectory + " does not exist; the process cannot be started. You can specify the working directory in the project options.");
- return;
- }
-
- if (withDebugging) {
- DebuggerService.CurrentDebugger.Start(psi);
- } else {
- DebuggerService.CurrentDebugger.StartWithoutDebugging(psi);
+ throw new ProjectStartException("Working directory " + psi.WorkingDirectory + " does not exist; the process cannot be started. You can specify the working directory in the project options.");
}
+ return psi;
}
- public override void Start(bool withDebugging)
+ public override ProcessStartInfo CreateStartInfo()
{
switch (this.StartAction) {
case StartAction.Project:
- Start(this.OutputAssemblyFullPath, withDebugging);
- break;
+ return CreateStartInfo(this.OutputAssemblyFullPath);
case StartAction.Program:
- Start(this.StartProgram, withDebugging);
- break;
+ return CreateStartInfo(this.StartProgram);
case StartAction.StartURL:
- FileService.OpenFile("browser://" + this.StartUrl);
- break;
+ string url = this.StartUrl;
+ if (!FileUtility.IsUrl(url))
+ url = "http://" + url;
+ return new ProcessStartInfo(url);
default:
throw new System.ComponentModel.InvalidEnumArgumentException("StartAction", (int)this.StartAction, typeof(StartAction));
}
diff --git a/src/Main/Base/Project/Src/Project/ProjectStartException.cs b/src/Main/Base/Project/Src/Project/ProjectStartException.cs
new file mode 100644
index 0000000000..7e60b9c4f0
--- /dev/null
+++ b/src/Main/Base/Project/Src/Project/ProjectStartException.cs
@@ -0,0 +1,35 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Runtime.Serialization;
+
+namespace ICSharpCode.SharpDevelop.Project
+{
+ ///
+ /// This exception occurs when a project cannot be started.
+ ///
+ [Serializable]
+ public class ProjectStartException : Exception
+ {
+ public ProjectStartException() : base()
+ {
+ }
+
+ public ProjectStartException(string message) : base(message)
+ {
+ }
+
+ public ProjectStartException(string message, Exception innerException) : base(message, innerException)
+ {
+ }
+
+ protected ProjectStartException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ }
+ }
+}
diff --git a/src/Main/Core/Project/Src/Services/FileUtility/FileUtility.cs b/src/Main/Core/Project/Src/Services/FileUtility/FileUtility.cs
index 6d08671722..d837562929 100644
--- a/src/Main/Core/Project/Src/Services/FileUtility/FileUtility.cs
+++ b/src/Main/Core/Project/Src/Services/FileUtility/FileUtility.cs
@@ -148,7 +148,7 @@ namespace ICSharpCode.Core
public static bool IsUrl(string path)
{
- return path.IndexOf(':') >= 2;
+ return path.IndexOf("://", StringComparison.Ordinal) > 0;
}
public static string GetCommonBaseDirectory(string dir1, string dir2)
diff --git a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/MemberLookupHelper.cs b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/MemberLookupHelper.cs
index c6cc920df7..7df5a3b6e3 100644
--- a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/MemberLookupHelper.cs
+++ b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/MemberLookupHelper.cs
@@ -825,7 +825,7 @@ namespace ICSharpCode.SharpDevelop.Dom
{
if (type == null)
throw new ArgumentNullException("type");
- StringComparer nameComparer = type.ProjectContent.Language.NameComparer;
+ StringComparer nameComparer = member.DeclaringType.ProjectContent.Language.NameComparer;
member = GetGenericMember(member);
if (member is IMethod) {
IMethod parentMethod = (IMethod)member;