Browse Source

Fix service references.

Fixed #383 - Handle empty string for service retrieval url.
Fix SvcUtil commmand line being mangled by ProcessRunner's
RunInOutputPadAsync by generating the command line arguments as an
array instead of a string.
pull/505/merge
Matt Ward 11 years ago
parent
commit
3409a32fda
  1. 36
      src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/SvcUtilCommandLine.cs
  2. 2
      src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/SvcUtilRunner.cs
  3. 2
      src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReferenceHelper.cs

36
src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/SvcUtilCommandLine.cs

@ -24,7 +24,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference
{ {
public class SvcUtilCommandLine public class SvcUtilCommandLine
{ {
StringBuilder argumentBuilder = new StringBuilder(); List<string> arguments = new List<string>();
public SvcUtilCommandLine(ServiceReferenceGeneratorOptions options) public SvcUtilCommandLine(ServiceReferenceGeneratorOptions options)
{ {
@ -32,7 +32,11 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference
} }
public string Command { get; set; } public string Command { get; set; }
public string Arguments { get; private set; }
public string[] GetArguments()
{
return arguments.ToArray();
}
void GenerateCommandLine(ServiceReferenceGeneratorOptions options) void GenerateCommandLine(ServiceReferenceGeneratorOptions options)
{ {
@ -48,8 +52,6 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference
AppendIfNotEmpty("/ct:", options.GetDictionaryCollectionTypeDescription()); AppendIfNotEmpty("/ct:", options.GetDictionaryCollectionTypeDescription());
AppendAssemblyReferences(options.Assemblies); AppendAssemblyReferences(options.Assemblies);
AppendIfNotEmpty(options.Url); AppendIfNotEmpty(options.Url);
this.Arguments = argumentBuilder.ToString();
} }
void AppendIfTrue(string argument, bool flag) void AppendIfTrue(string argument, bool flag)
@ -62,7 +64,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference
void AppendIfNotEmpty(string argumentName, string argumentValue) void AppendIfNotEmpty(string argumentName, string argumentValue)
{ {
if (!String.IsNullOrEmpty(argumentValue)) { if (!String.IsNullOrEmpty(argumentValue)) {
Append(argumentName + GetQuotedArgument(argumentValue)); Append(argumentName + argumentValue);
} }
} }
@ -75,29 +77,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference
void Append(string argument) void Append(string argument)
{ {
argumentBuilder.Append(argument); arguments.Add(argument);
argumentBuilder.Append(' ');
}
public override string ToString()
{
return String.Format(
"{0} {1}",
GetQuotedCommand(),
Arguments);
}
string GetQuotedCommand()
{
return GetQuotedArgument(Command);
}
string GetQuotedArgument(string argument)
{
if (ContainsSpaceCharacter(argument)) {
return String.Format("\"{0}\"", argument);
}
return argument;
} }
bool ContainsSpaceCharacter(string text) bool ContainsSpaceCharacter(string text)

2
src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/SvcUtilRunner.cs

@ -40,7 +40,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference
var commandLine = new SvcUtilCommandLine(Options); var commandLine = new SvcUtilCommandLine(Options);
commandLine.Command = GetSvcUtilPath(); commandLine.Command = GetSvcUtilPath();
using (ProcessRunner processRunner = new ProcessRunner()) { using (ProcessRunner processRunner = new ProcessRunner()) {
this.ExitCode = await processRunner.RunInOutputPadAsync(SvcUtilMessageView.Category, commandLine.Command, ProcessRunner.CommandLineToArgumentArray(commandLine.Arguments)); this.ExitCode = await processRunner.RunInOutputPadAsync(SvcUtilMessageView.Category, commandLine.Command, commandLine.GetArguments());
} }
if (ProcessExited != null) { if (ProcessExited != null) {
ProcessExited(this, new EventArgs()); ProcessExited(this, new EventArgs());

2
src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReferenceHelper.cs

@ -29,7 +29,7 @@ namespace ICSharpCode.SharpDevelop.Gui
{ {
if (description.Name != null) { if (description.Name != null) {
return description.Name; return description.Name;
} else if (description.RetrievalUrl != null) { } else if (!String.IsNullOrEmpty(description.RetrievalUrl)) {
Uri uri = new Uri(description.RetrievalUrl); Uri uri = new Uri(description.RetrievalUrl);
if (uri.Segments.Length > 0) { if (uri.Segments.Length > 0) {
return uri.Segments[uri.Segments.Length - 1]; return uri.Segments[uri.Segments.Length - 1];

Loading…
Cancel
Save