Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit 3409a32

Browse files
committed
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.
1 parent 2b85ce4 commit 3409a32

3 files changed

Lines changed: 11 additions & 31 deletions

File tree

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

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,19 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference
2424
{
2525
public class SvcUtilCommandLine
2626
{
27-
StringBuilder argumentBuilder = new StringBuilder();
27+
List<string> arguments = new List<string>();
2828

2929
public SvcUtilCommandLine(ServiceReferenceGeneratorOptions options)
3030
{
3131
GenerateCommandLine(options);
3232
}
3333

3434
public string Command { get; set; }
35-
public string Arguments { get; private set; }
35+
36+
public string[] GetArguments()
37+
{
38+
return arguments.ToArray();
39+
}
3640

3741
void GenerateCommandLine(ServiceReferenceGeneratorOptions options)
3842
{
@@ -48,8 +52,6 @@ void GenerateCommandLine(ServiceReferenceGeneratorOptions options)
4852
AppendIfNotEmpty("/ct:", options.GetDictionaryCollectionTypeDescription());
4953
AppendAssemblyReferences(options.Assemblies);
5054
AppendIfNotEmpty(options.Url);
51-
52-
this.Arguments = argumentBuilder.ToString();
5355
}
5456

5557
void AppendIfTrue(string argument, bool flag)
@@ -62,7 +64,7 @@ void AppendIfTrue(string argument, bool flag)
6264
void AppendIfNotEmpty(string argumentName, string argumentValue)
6365
{
6466
if (!String.IsNullOrEmpty(argumentValue)) {
65-
Append(argumentName + GetQuotedArgument(argumentValue));
67+
Append(argumentName + argumentValue);
6668
}
6769
}
6870

@@ -75,29 +77,7 @@ void AppendIfNotEmpty(string argument)
7577

7678
void Append(string argument)
7779
{
78-
argumentBuilder.Append(argument);
79-
argumentBuilder.Append(' ');
80-
}
81-
82-
public override string ToString()
83-
{
84-
return String.Format(
85-
"{0} {1}",
86-
GetQuotedCommand(),
87-
Arguments);
88-
}
89-
90-
string GetQuotedCommand()
91-
{
92-
return GetQuotedArgument(Command);
93-
}
94-
95-
string GetQuotedArgument(string argument)
96-
{
97-
if (ContainsSpaceCharacter(argument)) {
98-
return String.Format("\"{0}\"", argument);
99-
}
100-
return argument;
80+
arguments.Add(argument);
10181
}
10282

10383
bool ContainsSpaceCharacter(string text)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public async void Run()
4040
var commandLine = new SvcUtilCommandLine(Options);
4141
commandLine.Command = GetSvcUtilPath();
4242
using (ProcessRunner processRunner = new ProcessRunner()) {
43-
this.ExitCode = await processRunner.RunInOutputPadAsync(SvcUtilMessageView.Category, commandLine.Command, ProcessRunner.CommandLineToArgumentArray(commandLine.Arguments));
43+
this.ExitCode = await processRunner.RunInOutputPadAsync(SvcUtilMessageView.Category, commandLine.Command, commandLine.GetArguments());
4444
}
4545
if (ProcessExited != null) {
4646
ProcessExited(this, new EventArgs());

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
namespace ICSharpCode.SharpDevelop.Gui
2525
{
2626
internal static class ServiceReferenceHelper
27-
{
27+
{
2828
public static string GetServiceName(ServiceDescription description)
2929
{
3030
if (description.Name != null) {
3131
return description.Name;
32-
} else if (description.RetrievalUrl != null) {
32+
} else if (!String.IsNullOrEmpty(description.RetrievalUrl)) {
3333
Uri uri = new Uri(description.RetrievalUrl);
3434
if (uri.Segments.Length > 0) {
3535
return uri.Segments[uri.Segments.Length - 1];

0 commit comments

Comments
 (0)