Skip to content

Commit

Permalink
[Service Bus] ConnectionString parsing cleanup (#10664)
Browse files Browse the repository at this point in the history
[Service Bus] ConnectionString parsing cleanup
  • Loading branch information
ShivangiReja authored Mar 19, 2020
1 parent 28cae39 commit 9184b94
Show file tree
Hide file tree
Showing 10 changed files with 506 additions and 541 deletions.
21 changes: 21 additions & 0 deletions sdk/servicebus/Azure.Messaging.ServiceBus/src/Core/Argument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,26 @@ public static void AssertNotClosed(bool wasClosed, string targetName)
targetName);
}
}

/// <summary>
/// Ensures that an argument's value is a well-formed Event Hubs fully qualified namespace value,
/// throwing a <see cref="ArgumentException" /> if that invariant is not met.
/// </summary>
///
/// <param name="argumentValue">The argument value.</param>
/// <param name="argumentName">Name of the argument.</param>
///
///
/// <exception cref="ArgumentException"><paramref name="argumentValue"/> is not a well-formed Service Bus fully qualified namespace.</exception>
///
public static void AssertWellFormedServiceBusNamespace(string argumentValue, string argumentName)
{
argumentValue ??= string.Empty;

if (Uri.CheckHostName(argumentValue) == UriHostNameType.Unknown)
{
throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources1.InvalidFullyQualifiedNamespace, argumentValue), argumentName);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ public static ConnectionStringProperties Parse(string connectionString)
{
parsedValues.EndpointToken = new UriBuilder(value)
{
Scheme = ServiceBusEndpointScheme
Scheme = ServiceBusEndpointScheme,
Port = -1
};
}
else if (string.Compare(EntityName, token, StringComparison.OrdinalIgnoreCase) == 0)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions sdk/servicebus/Azure.Messaging.ServiceBus/src/Resources1.resx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
<data name="MissingConnectionInformation" xml:space="preserve">
<value>The connection string used for an Service Bus entity client must specify the Service Bus namespace host, and a Shared Access Signature (both the name and value) to be valid. The path to an Service Bus entity must be included in the connection string or specified separately.</value>
</data>
<data name="OnlyOneEventHubNameMayBeSpecified" xml:space="preserve">
<data name="OnlyOneEntityNameMayBeSpecified" xml:space="preserve">
<value>The path to an Service Bus entity may be specified as part of the connection string or as a separate value, but not both.</value>
</data>
<data name="UnknownConnectionType" xml:space="preserve">
Expand Down Expand Up @@ -225,7 +225,7 @@
<data name="CannotStartEventProcessorWithoutHandler" xml:space="preserve">
<value>Cannot begin processing without {0} handler set.</value>
</data>
<data name="RunningMessageProcessor" xml:space="preserve">
<data name="RunningMessageProcessorCannotPerformOperation" xml:space="preserve">
<value>The message processor is already running and needs to be stopped in order to perform this operation.</value>
</data>
<data name="ClientNeededForThisInformation" xml:space="preserve">
Expand Down Expand Up @@ -270,4 +270,7 @@
<data name="MaxPermittedLength" xml:space="preserve">
<value>Maximum permitted length is {0}</value>
</data>
</root>
<data name="InvalidFullyQualifiedNamespace" xml:space="preserve">
<value>The value '{0}' is not a well-formed Service Bus fully qualified namespace.</value>
</data>
</root>
Loading

0 comments on commit 9184b94

Please sign in to comment.