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 @@ -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();
}
}

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

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

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

@ -13,6 +13,7 @@ using System.Diagnostics; @@ -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 @@ -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);
}
}
/// <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();
}

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

@ -228,12 +228,32 @@ namespace ICSharpCode.SharpDevelop.Project @@ -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);
}
}
/// <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);
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 @@ -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));
}

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

@ -0,0 +1,35 @@ @@ -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 @@ -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)

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

@ -825,7 +825,7 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -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;

Loading…
Cancel
Save