Browse Source

Added CreateStartInfo method to AbstractProject.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3864 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 17 years ago
parent
commit
9fc26985b2
  1. 12
      src/AddIns/BackendBindings/WixBinding/Project/Src/Project/WixProject.cs
  2. 1
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  3. 23
      src/Main/Base/Project/Src/Project/AbstractProject.cs
  4. 54
      src/Main/Base/Project/Src/Project/CompilableProject.cs
  5. 35
      src/Main/Base/Project/Src/Project/ProjectStartException.cs
  6. 2
      src/Main/Core/Project/Src/Services/FileUtility/FileUtility.cs
  7. 2
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/MemberLookupHelper.cs

12
src/AddIns/BackendBindings/WixBinding/Project/Src/Project/WixProject.cs

@ -57,14 +57,16 @@ namespace ICSharpCode.WixBinding
public override void Start(bool withDebugging) public override void Start(bool withDebugging)
{ {
withDebugging = false; base.Start(false); // debugging not supported
}
public override System.Diagnostics.ProcessStartInfo CreateStartInfo()
{
switch (StartAction) { switch (StartAction) {
case StartAction.Project: case StartAction.Project:
Start(InstallerFullPath, withDebugging); return CreateStartInfo(InstallerFullPath);
break;
default: default:
base.Start(withDebugging); return base.CreateStartInfo();
break;
} }
} }

1
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -127,6 +127,7 @@
<Compile Include="Src\Project\ContextSpecificProperties.cs" /> <Compile Include="Src\Project\ContextSpecificProperties.cs" />
<Compile Include="Src\Project\IBuildFeedbackSink.cs" /> <Compile Include="Src\Project\IBuildFeedbackSink.cs" />
<Compile Include="Src\Project\MSBuildFileProject.cs" /> <Compile Include="Src\Project\MSBuildFileProject.cs" />
<Compile Include="Src\Project\ProjectStartException.cs" />
<Compile Include="Src\Project\ProjectLoadException.cs" /> <Compile Include="Src\Project\ProjectLoadException.cs" />
<Compile Include="Src\Project\ProjectPropertyChangedEventArgs.cs" /> <Compile Include="Src\Project\ProjectPropertyChangedEventArgs.cs" />
<Compile Include="Src\Services\Debugger\BreakpointBookmark.cs" /> <Compile Include="Src\Services\Debugger\BreakpointBookmark.cs" />

23
src/Main/Base/Project/Src/Project/AbstractProject.cs

@ -13,6 +13,7 @@ using System.Diagnostics;
using System.IO; using System.IO;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Debugging;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.SharpDevelop.Project namespace ICSharpCode.SharpDevelop.Project
@ -360,6 +361,28 @@ namespace ICSharpCode.SharpDevelop.Project
} }
public virtual void Start(bool withDebugging) 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);
}
}
/// <summary>
/// Creates the start info used to start the project.
/// </summary>
/// <exception cref="ProjectStartException">Occurs when the project cannot be started.</exception>
/// <returns>ProcessStartInfo used to start the project.
/// Note: this can be a ProcessStartInfo with a URL as filename!</returns>
public virtual ProcessStartInfo CreateStartInfo()
{ {
throw new NotSupportedException(); throw new NotSupportedException();
} }

54
src/Main/Base/Project/Src/Project/CompilableProject.cs

@ -228,12 +228,32 @@ namespace ICSharpCode.SharpDevelop.Project
return text; return text;
} }
[Obsolete("Override CreateStartInfo instead of using Start()")]
protected void Start(string program, bool withDebugging) 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);
}
}
/// <summary>
/// Creates a <see cref="ProcessStartInfo"/> for the specified program, using
/// arguments and working directory from the project options.
/// </summary>
protected ProcessStartInfo CreateStartInfo(string program)
{ {
program = RemoveQuotes(program); program = RemoveQuotes(program);
if (!FileUtility.IsValidPath(program)) { if (!FileUtility.IsValidPath(program)) {
MessageService.ShowError(program + " is not a valid path; the process cannot be started."); throw new ProjectStartException(program + " is not a valid path; the process cannot be started.");
return;
} }
ProcessStartInfo psi = new ProcessStartInfo(); ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = Path.Combine(Directory, program); psi.FileName = Path.Combine(Directory, program);
@ -245,41 +265,33 @@ namespace ICSharpCode.SharpDevelop.Project
workingDir = RemoveQuotes(workingDir); workingDir = RemoveQuotes(workingDir);
if (!FileUtility.IsValidPath(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."); throw new ProjectStartException("Working directory '" + workingDir + "' is invalid; the process cannot be started. You can specify the working directory in the project options.");
return;
} }
psi.WorkingDirectory = Path.Combine(Directory, workingDir); psi.WorkingDirectory = Path.Combine(Directory, workingDir);
} }
psi.Arguments = StringParser.Parse(this.StartArguments); psi.Arguments = StringParser.Parse(this.StartArguments);
if (!File.Exists(psi.FileName)) { if (!File.Exists(psi.FileName)) {
MessageService.ShowError(psi.FileName + " does not exist and cannot be started."); throw new ProjectStartException(psi.FileName + " does not exist and cannot be started.");
return;
} }
if (!System.IO.Directory.Exists(psi.WorkingDirectory)) { 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."); 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;
}
if (withDebugging) {
DebuggerService.CurrentDebugger.Start(psi);
} else {
DebuggerService.CurrentDebugger.StartWithoutDebugging(psi);
} }
return psi;
} }
public override void Start(bool withDebugging) public override ProcessStartInfo CreateStartInfo()
{ {
switch (this.StartAction) { switch (this.StartAction) {
case StartAction.Project: case StartAction.Project:
Start(this.OutputAssemblyFullPath, withDebugging); return CreateStartInfo(this.OutputAssemblyFullPath);
break;
case StartAction.Program: case StartAction.Program:
Start(this.StartProgram, withDebugging); return CreateStartInfo(this.StartProgram);
break;
case StartAction.StartURL: case StartAction.StartURL:
FileService.OpenFile("browser://" + this.StartUrl); string url = this.StartUrl;
break; if (!FileUtility.IsUrl(url))
url = "http://" + url;
return new ProcessStartInfo(url);
default: default:
throw new System.ComponentModel.InvalidEnumArgumentException("StartAction", (int)this.StartAction, typeof(StartAction)); throw new System.ComponentModel.InvalidEnumArgumentException("StartAction", (int)this.StartAction, typeof(StartAction));
} }

35
src/Main/Base/Project/Src/Project/ProjectStartException.cs

@ -0,0 +1,35 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <author name="Daniel Grunwald"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Runtime.Serialization;
namespace ICSharpCode.SharpDevelop.Project
{
/// <summary>
/// This exception occurs when a project cannot be started.
/// </summary>
[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)
{
}
}
}

2
src/Main/Core/Project/Src/Services/FileUtility/FileUtility.cs

@ -148,7 +148,7 @@ namespace ICSharpCode.Core
public static bool IsUrl(string path) public static bool IsUrl(string path)
{ {
return path.IndexOf(':') >= 2; return path.IndexOf("://", StringComparison.Ordinal) > 0;
} }
public static string GetCommonBaseDirectory(string dir1, string dir2) public static string GetCommonBaseDirectory(string dir1, string dir2)

2
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/MemberLookupHelper.cs

@ -825,7 +825,7 @@ namespace ICSharpCode.SharpDevelop.Dom
{ {
if (type == null) if (type == null)
throw new ArgumentNullException("type"); throw new ArgumentNullException("type");
StringComparer nameComparer = type.ProjectContent.Language.NameComparer; StringComparer nameComparer = member.DeclaringType.ProjectContent.Language.NameComparer;
member = GetGenericMember(member); member = GetGenericMember(member);
if (member is IMethod) { if (member is IMethod) {
IMethod parentMethod = (IMethod)member; IMethod parentMethod = (IMethod)member;

Loading…
Cancel
Save