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. 4
      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 @@ -24,7 +24,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference
{
public class SvcUtilCommandLine
{
StringBuilder argumentBuilder = new StringBuilder();
List<string> arguments = new List<string>();
public SvcUtilCommandLine(ServiceReferenceGeneratorOptions options)
{
@ -32,7 +32,11 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference @@ -32,7 +32,11 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference
}
public string Command { get; set; }
public string Arguments { get; private set; }
public string[] GetArguments()
{
return arguments.ToArray();
}
void GenerateCommandLine(ServiceReferenceGeneratorOptions options)
{
@ -48,8 +52,6 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference @@ -48,8 +52,6 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference
AppendIfNotEmpty("/ct:", options.GetDictionaryCollectionTypeDescription());
AppendAssemblyReferences(options.Assemblies);
AppendIfNotEmpty(options.Url);
this.Arguments = argumentBuilder.ToString();
}
void AppendIfTrue(string argument, bool flag)
@ -62,7 +64,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference @@ -62,7 +64,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference
void AppendIfNotEmpty(string argumentName, string argumentValue)
{
if (!String.IsNullOrEmpty(argumentValue)) {
Append(argumentName + GetQuotedArgument(argumentValue));
Append(argumentName + argumentValue);
}
}
@ -75,29 +77,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference @@ -75,29 +77,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference
void Append(string argument)
{
argumentBuilder.Append(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;
arguments.Add(argument);
}
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 @@ -40,7 +40,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference
var commandLine = new SvcUtilCommandLine(Options);
commandLine.Command = GetSvcUtilPath();
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) {
ProcessExited(this, new EventArgs());

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

@ -24,12 +24,12 @@ using System.Web.Services.Discovery; @@ -24,12 +24,12 @@ using System.Web.Services.Discovery;
namespace ICSharpCode.SharpDevelop.Gui
{
internal static class ServiceReferenceHelper
{
{
public static string GetServiceName(ServiceDescription description)
{
if (description.Name != null) {
return description.Name;
} else if (description.RetrievalUrl != null) {
} else if (!String.IsNullOrEmpty(description.RetrievalUrl)) {
Uri uri = new Uri(description.RetrievalUrl);
if (uri.Segments.Length > 0) {
return uri.Segments[uri.Segments.Length - 1];

Loading…
Cancel
Save