summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.OpenId/OpenId
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOpenAuth.OpenId/OpenId')
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/Association.cs16
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/AssociationContract.cs2
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/ChannelElements/ExtensionsBindingElement.cs6
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/ChannelElements/KeyValueFormEncoding.cs2
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/ChannelElements/OpenIdChannel.cs2
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/ChannelElements/ReturnToSignatureBindingElement.cs4
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/ChannelElements/SigningBindingElement.cs6
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/ChannelElements/SigningBindingElementContract.cs4
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/DiffieHellmanUtilities.cs20
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/Extensions/AliasManager.cs20
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/Extensions/AttributeExchange/AXUtilities.cs12
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/Extensions/AttributeExchange/AttributeRequest.cs8
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/Extensions/AttributeExchange/AttributeValues.cs4
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/Extensions/ExtensionArgumentsManager.cs14
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/Extensions/ExtensionsInteropHelper.cs8
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/Extensions/ProviderAuthenticationPolicy/PapeUtilities.cs2
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/Extensions/ProviderAuthenticationPolicy/PolicyResponse.cs2
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/Extensions/SimpleRegistration/ClaimsRequest.cs2
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs2
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/HmacShaAssociation.cs28
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/IIdentifierDiscoveryService.cs4
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/IProviderEndpoint.cs3
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/Identifier.cs10
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/IdentifierDiscoveryResult.cs10
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/Messages/CheckAuthenticationRequest.cs2
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/Messages/DirectResponseBase.cs2
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/Messages/IndirectResponseBase.cs6
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/Messages/IndirectSignedResponse.cs8
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/Messages/NegativeAssertionResponse.cs6
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/Messages/RequestBase.cs6
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/Messages/SignedResponseRequest.cs4
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/NoDiscoveryIdentifier.cs2
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/OpenIdUtilities.cs8
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/OpenIdXrdsHelper.cs6
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/Protocol.cs6
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/Provider/IAuthenticationRequest.cs8
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/Provider/IHostProcessedRequest.cs2
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/Provider/IProviderBehavior.cs6
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/Provider/IRequest.cs4
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/ProviderEndpointDescription.cs8
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/Realm.cs8
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/RelyingParty/IAuthenticationRequestContract.cs20
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/RelyingParty/IAuthenticationResponse.cs10
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/RelyingParty/IRelyingPartyBehavior.cs6
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/RelyingPartyDescription.cs4
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/SecuritySettings.cs2
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/UriIdentifier.cs20
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/XriDiscoveryProxyService.cs4
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/XriIdentifier.cs12
49 files changed, 179 insertions, 182 deletions
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Association.cs b/src/DotNetOpenAuth.OpenId/OpenId/Association.cs
index d063aa1..ff30a36 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/Association.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/Association.cs
@@ -35,11 +35,11 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="totalLifeLength">How long the association will be useful.</param>
/// <param name="issued">The UTC time of when this association was originally issued by the Provider.</param>
protected Association(string handle, byte[] secret, TimeSpan totalLifeLength, DateTime issued) {
- Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(handle));
- Contract.Requires<ArgumentNullException>(secret != null);
- Contract.Requires<ArgumentOutOfRangeException>(totalLifeLength > TimeSpan.Zero);
- Contract.Requires<ArgumentException>(issued.Kind == DateTimeKind.Utc);
- Contract.Requires<ArgumentOutOfRangeException>(issued <= DateTime.UtcNow);
+ Requires.NotNullOrEmpty(handle, "handle");
+ Requires.NotNull(secret, "secret");
+ Requires.InRange(totalLifeLength > TimeSpan.Zero, "totalLifeLength");
+ Requires.True(issued.Kind == DateTimeKind.Utc, "issued");
+ Requires.InRange(issued <= DateTime.UtcNow, "issued");
Contract.Ensures(this.TotalLifeLength == totalLifeLength);
this.Handle = handle;
@@ -162,8 +162,8 @@ namespace DotNetOpenAuth.OpenId {
/// IRelyingPartyAssociationStore.GetAssociation method.
/// </returns>
public static Association Deserialize(string handle, DateTime expiresUtc, byte[] privateData) {
- Contract.Requires<ArgumentNullException>(!String.IsNullOrEmpty(handle));
- Contract.Requires<ArgumentNullException>(privateData != null);
+ Requires.NotNullOrEmpty(handle, "handle");
+ Requires.NotNull(privateData, "privateData");
Contract.Ensures(Contract.Result<Association>() != null);
expiresUtc = expiresUtc.ToUniversalTimeSafe();
@@ -278,7 +278,7 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="data">The data to sign. This data will not be changed (the signature is the return value).</param>
/// <returns>The calculated signature of the data.</returns>
protected internal byte[] Sign(byte[] data) {
- Contract.Requires<ArgumentNullException>(data != null);
+ Requires.NotNull(data, "data");
using (HashAlgorithm hasher = this.CreateHasher()) {
return hasher.ComputeHash(data);
}
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/AssociationContract.cs b/src/DotNetOpenAuth.OpenId/OpenId/AssociationContract.cs
index 57f4fd9..e36028e 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/AssociationContract.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/AssociationContract.cs
@@ -46,7 +46,7 @@ namespace DotNetOpenAuth.OpenId {
/// </returns>
[Pure]
internal override string GetAssociationType(Protocol protocol) {
- Contract.Requires<ArgumentNullException>(protocol != null);
+ Requires.NotNull(protocol, "protocol");
throw new NotImplementedException();
}
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/ChannelElements/ExtensionsBindingElement.cs b/src/DotNetOpenAuth.OpenId/OpenId/ChannelElements/ExtensionsBindingElement.cs
index ace8d69..705f737 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/ChannelElements/ExtensionsBindingElement.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/ChannelElements/ExtensionsBindingElement.cs
@@ -33,8 +33,8 @@ namespace DotNetOpenAuth.OpenId.ChannelElements {
/// <param name="securitySettings">The security settings.</param>
/// <param name="receiveUnsignedExtensions">Security setting for relying parties. Should be true for Providers.</param>
internal ExtensionsBindingElement(IOpenIdExtensionFactory extensionFactory, SecuritySettings securitySettings, bool receiveUnsignedExtensions) {
- Contract.Requires<ArgumentNullException>(extensionFactory != null);
- Contract.Requires<ArgumentNullException>(securitySettings != null);
+ Requires.NotNull(extensionFactory, "extensionFactory");
+ Requires.NotNull(securitySettings, "securitySettings");
this.ExtensionFactory = extensionFactory;
this.receiveUnsignedExtensions = receiveUnsignedExtensions;
@@ -238,7 +238,7 @@ namespace DotNetOpenAuth.OpenId.ChannelElements {
/// A dictionary of message parts, including only signed parts when appropriate.
/// </returns>
private IDictionary<string, string> GetExtensionsDictionary(IProtocolMessage message, bool ignoreUnsigned) {
- Contract.Requires<InvalidOperationException>(this.Channel != null);
+ Requires.ValidState(this.Channel != null);
IndirectSignedResponse signedResponse = message as IndirectSignedResponse;
if (signedResponse != null && ignoreUnsigned) {
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/ChannelElements/KeyValueFormEncoding.cs b/src/DotNetOpenAuth.OpenId/OpenId/ChannelElements/KeyValueFormEncoding.cs
index 46c2139..1993cb4 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/ChannelElements/KeyValueFormEncoding.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/ChannelElements/KeyValueFormEncoding.cs
@@ -101,7 +101,7 @@ namespace DotNetOpenAuth.OpenId.ChannelElements {
/// </remarks>
[SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times", Justification = "Not a problem for this type.")]
public static byte[] GetBytes(IEnumerable<KeyValuePair<string, string>> keysAndValues) {
- Contract.Requires<ArgumentNullException>(keysAndValues != null);
+ Requires.NotNull(keysAndValues, "keysAndValues");
using (MemoryStream ms = new MemoryStream()) {
using (StreamWriter sw = new StreamWriter(ms, textEncoding)) {
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/ChannelElements/OpenIdChannel.cs b/src/DotNetOpenAuth.OpenId/OpenId/ChannelElements/OpenIdChannel.cs
index cc49a95..a2a5c88 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/ChannelElements/OpenIdChannel.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/ChannelElements/OpenIdChannel.cs
@@ -48,7 +48,7 @@ namespace DotNetOpenAuth.OpenId.ChannelElements {
/// <param name="bindingElements">The binding elements to use in sending and receiving messages.</param>
protected OpenIdChannel(IMessageFactory messageTypeProvider, IChannelBindingElement[] bindingElements)
: base(messageTypeProvider, bindingElements) {
- Contract.Requires<ArgumentNullException>(messageTypeProvider != null);
+ Requires.NotNull(messageTypeProvider, "messageTypeProvider");
// Customize the binding element order, since we play some tricks for higher
// security and backward compatibility with older OpenID versions.
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/ChannelElements/ReturnToSignatureBindingElement.cs b/src/DotNetOpenAuth.OpenId/OpenId/ChannelElements/ReturnToSignatureBindingElement.cs
index bc7b2a1..25a29bb 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/ChannelElements/ReturnToSignatureBindingElement.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/ChannelElements/ReturnToSignatureBindingElement.cs
@@ -58,7 +58,7 @@ namespace DotNetOpenAuth.OpenId.ChannelElements {
/// </summary>
/// <param name="cryptoKeyStore">The crypto key store.</param>
internal ReturnToSignatureBindingElement(ICryptoKeyStore cryptoKeyStore) {
- Contract.Requires<ArgumentNullException>(cryptoKeyStore != null);
+ Requires.NotNull(cryptoKeyStore, "cryptoKeyStore");
this.cryptoKeyStore = cryptoKeyStore;
}
@@ -173,7 +173,7 @@ namespace DotNetOpenAuth.OpenId.ChannelElements {
/// or other minor changes do not invalidate the signature.
/// </remarks>
private byte[] GetReturnToSignature(Uri returnTo, CryptoKey cryptoKey = null) {
- Contract.Requires<ArgumentNullException>(returnTo != null);
+ Requires.NotNull(returnTo, "returnTo");
// Assemble the dictionary to sign, taking care to remove the signature itself
// in order to accurately reproduce the original signature (which of course didn't include
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/ChannelElements/SigningBindingElement.cs b/src/DotNetOpenAuth.OpenId/OpenId/ChannelElements/SigningBindingElement.cs
index f186adc..95a748e 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/ChannelElements/SigningBindingElement.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/ChannelElements/SigningBindingElement.cs
@@ -120,9 +120,9 @@ namespace DotNetOpenAuth.OpenId.ChannelElements {
/// <param name="association">The association to use to sign the message.</param>
/// <returns>The calculated signature of the method.</returns>
protected string GetSignature(ITamperResistantOpenIdMessage signedMessage, Association association) {
- Contract.Requires<ArgumentNullException>(signedMessage != null);
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(signedMessage.SignedParameterOrder));
- Contract.Requires<ArgumentNullException>(association != null);
+ Requires.NotNull(signedMessage, "signedMessage");
+ Requires.True(!String.IsNullOrEmpty(signedMessage.SignedParameterOrder), "signedMessage");
+ Requires.NotNull(association, "association");
// Prepare the parts to sign, taking care to replace an openid.mode value
// of check_authentication with its original id_res so the signature matches.
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/ChannelElements/SigningBindingElementContract.cs b/src/DotNetOpenAuth.OpenId/OpenId/ChannelElements/SigningBindingElementContract.cs
index c46cd12..bf8b18d 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/ChannelElements/SigningBindingElementContract.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/ChannelElements/SigningBindingElementContract.cs
@@ -45,7 +45,7 @@ namespace DotNetOpenAuth.OpenId.ChannelElements {
/// The association to use to sign or verify the message.
/// </returns>
protected override Association GetAssociation(ITamperResistantOpenIdMessage signedMessage) {
- Contract.Requires<ArgumentNullException>(signedMessage != null);
+ Requires.NotNull(signedMessage, "signedMessage");
throw new NotImplementedException();
}
@@ -57,7 +57,7 @@ namespace DotNetOpenAuth.OpenId.ChannelElements {
/// The referenced association; or <c>null</c> if such an association cannot be found.
/// </returns>
protected override Association GetSpecificAssociation(ITamperResistantOpenIdMessage signedMessage) {
- Contract.Requires<ArgumentNullException>(signedMessage != null);
+ Requires.NotNull(signedMessage, "signedMessage");
throw new NotImplementedException();
}
}
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/DiffieHellmanUtilities.cs b/src/DotNetOpenAuth.OpenId/OpenId/DiffieHellmanUtilities.cs
index 249f1f3..78f90c9 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/DiffieHellmanUtilities.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/DiffieHellmanUtilities.cs
@@ -37,8 +37,8 @@ namespace DotNetOpenAuth.OpenId {
/// <returns>The hashing algorithm to use.</returns>
/// <exception cref="ProtocolException">Thrown if no match could be found for the given <paramref name="sessionType"/>.</exception>
public static HashAlgorithm Lookup(Protocol protocol, string sessionType) {
- Contract.Requires<ArgumentNullException>(protocol != null);
- Contract.Requires<ArgumentNullException>(sessionType != null);
+ Requires.NotNull(protocol, "protocol");
+ Requires.NotNull(sessionType, "sessionType");
// We COULD use just First instead of FirstOrDefault, but we want to throw ProtocolException instead of InvalidOperationException.
DHSha match = diffieHellmanSessionTypes.FirstOrDefault(dhsha => String.Equals(dhsha.GetName(protocol), sessionType, StringComparison.Ordinal));
@@ -53,7 +53,7 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="hashSizeInBits">The hash size (in bits) that the DH session must have.</param>
/// <returns>The value to be used for the openid.session_type parameter, or null if no match was found.</returns>
internal static string GetNameForSize(Protocol protocol, int hashSizeInBits) {
- Contract.Requires<ArgumentNullException>(protocol != null);
+ Requires.NotNull(protocol, "protocol");
DHSha match = diffieHellmanSessionTypes.FirstOrDefault(dhsha => dhsha.Algorithm.HashSize == hashSizeInBits);
return match != null ? match.GetName(protocol) : null;
}
@@ -73,10 +73,10 @@ namespace DotNetOpenAuth.OpenId {
/// The secret itself if the encrypted version of the secret was given in <paramref name="remotePublicKey"/>.
/// </returns>
internal static byte[] SHAHashXorSecret(HashAlgorithm hasher, DiffieHellman dh, byte[] remotePublicKey, byte[] plainOrEncryptedSecret) {
- Contract.Requires<ArgumentNullException>(hasher != null);
- Contract.Requires<ArgumentNullException>(dh != null);
- Contract.Requires<ArgumentNullException>(remotePublicKey != null);
- Contract.Requires<ArgumentNullException>(plainOrEncryptedSecret != null);
+ Requires.NotNull(hasher, "hasher");
+ Requires.NotNull(dh, "dh");
+ Requires.NotNull(remotePublicKey, "remotePublicKey");
+ Requires.NotNull(plainOrEncryptedSecret, "plainOrEncryptedSecret");
byte[] sharedBlock = dh.DecryptKeyExchange(remotePublicKey);
byte[] sharedBlockHash = hasher.ComputeHash(EnsurePositive(sharedBlock));
@@ -102,7 +102,7 @@ namespace DotNetOpenAuth.OpenId {
/// This is to be consistent with OpenID spec section 4.2.
/// </remarks>
internal static byte[] EnsurePositive(byte[] inputBytes) {
- Contract.Requires<ArgumentNullException>(inputBytes != null);
+ Requires.NotNull(inputBytes, "inputBytes");
if (inputBytes.Length == 0) {
throw new ArgumentException(MessagingStrings.UnexpectedEmptyArray, "inputBytes");
}
@@ -128,8 +128,8 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="algorithm">The hashing algorithm used in this particular Diffie-Hellman session type.</param>
/// <param name="getName">A function that will return the value of the openid.session_type parameter for a given version of OpenID.</param>
public DHSha(HashAlgorithm algorithm, Func<Protocol, string> getName) {
- Contract.Requires<ArgumentNullException>(algorithm != null);
- Contract.Requires<ArgumentNullException>(getName != null);
+ Requires.NotNull(algorithm, "algorithm");
+ Requires.NotNull(getName, "getName");
this.GetName = getName;
this.Algorithm = algorithm;
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Extensions/AliasManager.cs b/src/DotNetOpenAuth.OpenId/OpenId/Extensions/AliasManager.cs
index 0a84266..f6878ec 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/Extensions/AliasManager.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/Extensions/AliasManager.cs
@@ -45,7 +45,7 @@ namespace DotNetOpenAuth.OpenId.Extensions {
/// <param name="typeUri">The type URI.</param>
/// <returns>The alias assigned to this type URI. Never null.</returns>
public string GetAlias(string typeUri) {
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(typeUri));
+ Requires.NotNullOrEmpty(typeUri, "typeUri");
string alias;
return this.typeUriToAliasMap.TryGetValue(typeUri, out alias) ? alias : this.AssignNewAlias(typeUri);
}
@@ -56,8 +56,8 @@ namespace DotNetOpenAuth.OpenId.Extensions {
/// <param name="alias">The alias.</param>
/// <param name="typeUri">The type URI.</param>
public void SetAlias(string alias, string typeUri) {
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(alias));
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(typeUri));
+ Requires.NotNullOrEmpty(alias, "alias");
+ Requires.NotNullOrEmpty(typeUri, "typeUri");
this.aliasToTypeUriMap.Add(alias, typeUri);
this.typeUriToAliasMap.Add(typeUri, alias);
}
@@ -68,7 +68,7 @@ namespace DotNetOpenAuth.OpenId.Extensions {
/// <param name="typeUris">The type URIs to create aliases for.</param>
/// <param name="preferredTypeUriToAliases">An optional dictionary of URI/alias pairs that suggest preferred aliases to use if available for certain type URIs.</param>
public void AssignAliases(IEnumerable<string> typeUris, IDictionary<string, string> preferredTypeUriToAliases) {
- Contract.Requires<ArgumentNullException>(typeUris != null);
+ Requires.NotNull(typeUris, "typeUris");
// First go through the actually used type URIs and see which ones have matching preferred aliases.
if (preferredTypeUriToAliases != null) {
@@ -103,7 +103,7 @@ namespace DotNetOpenAuth.OpenId.Extensions {
/// </summary>
/// <param name="preferredTypeUriToAliases">A dictionary of type URI keys and alias values.</param>
public void SetPreferredAliasesWhereNotSet(IDictionary<string, string> preferredTypeUriToAliases) {
- Contract.Requires<ArgumentNullException>(preferredTypeUriToAliases != null);
+ Requires.NotNull(preferredTypeUriToAliases, "preferredTypeUriToAliases");
foreach (var pair in preferredTypeUriToAliases) {
if (this.typeUriToAliasMap.ContainsKey(pair.Key)) {
@@ -128,7 +128,7 @@ namespace DotNetOpenAuth.OpenId.Extensions {
/// <returns>The Type URI.</returns>
/// <exception cref="ArgumentOutOfRangeException">Thrown if the given alias does not have a matching TypeURI.</exception>
public string ResolveAlias(string alias) {
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(alias));
+ Requires.NotNullOrEmpty(alias, "alias");
string typeUri = this.TryResolveAlias(alias);
if (typeUri == null) {
throw new ArgumentOutOfRangeException("alias");
@@ -142,7 +142,7 @@ namespace DotNetOpenAuth.OpenId.Extensions {
/// <param name="alias">The alias.</param>
/// <returns>The Type URI for the given alias, or null if none for that alias exist.</returns>
public string TryResolveAlias(string alias) {
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(alias));
+ Requires.NotNullOrEmpty(alias, "alias");
string typeUri = null;
this.aliasToTypeUriMap.TryGetValue(alias, out typeUri);
return typeUri;
@@ -154,7 +154,7 @@ namespace DotNetOpenAuth.OpenId.Extensions {
/// <param name="alias">The alias in question.</param>
/// <returns>True if the alias has already been assigned. False otherwise.</returns>
public bool IsAliasUsed(string alias) {
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(alias));
+ Requires.NotNullOrEmpty(alias, "alias");
return this.aliasToTypeUriMap.ContainsKey(alias);
}
@@ -166,7 +166,7 @@ namespace DotNetOpenAuth.OpenId.Extensions {
/// <c>true</c> if the given type URI already has an alias assigned; <c>false</c> otherwise.
/// </returns>
public bool IsAliasAssignedTo(string typeUri) {
- Contract.Requires<ArgumentNullException>(typeUri != null);
+ Requires.NotNull(typeUri, "typeUri");
return this.typeUriToAliasMap.ContainsKey(typeUri);
}
@@ -176,7 +176,7 @@ namespace DotNetOpenAuth.OpenId.Extensions {
/// <param name="typeUri">The type URI to assign a new alias to.</param>
/// <returns>The newly generated alias.</returns>
private string AssignNewAlias(string typeUri) {
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(typeUri));
+ Requires.NotNullOrEmpty(typeUri, "typeUri");
ErrorUtilities.VerifyInternal(!this.typeUriToAliasMap.ContainsKey(typeUri), "Oops! This type URI already has an alias!");
string alias = string.Format(CultureInfo.InvariantCulture, AliasFormat, this.typeUriToAliasMap.Count + 1);
this.typeUriToAliasMap.Add(typeUri, alias);
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Extensions/AttributeExchange/AXUtilities.cs b/src/DotNetOpenAuth.OpenId/OpenId/Extensions/AttributeExchange/AXUtilities.cs
index 2b947f7..96cc437 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/Extensions/AttributeExchange/AXUtilities.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/Extensions/AttributeExchange/AXUtilities.cs
@@ -21,7 +21,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.AttributeExchange {
/// <param name="collection">The attribute request collection.</param>
/// <param name="typeUri">The type URI of the required attribute.</param>
public static void AddRequired(this ICollection<AttributeRequest> collection, string typeUri) {
- Contract.Requires<ArgumentNullException>(collection != null);
+ Requires.NotNull(collection, "collection");
collection.Add(new AttributeRequest(typeUri, true));
}
@@ -31,7 +31,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.AttributeExchange {
/// <param name="collection">The attribute request collection.</param>
/// <param name="typeUri">The type URI of the requested attribute.</param>
public static void AddOptional(this ICollection<AttributeRequest> collection, string typeUri) {
- Contract.Requires<ArgumentNullException>(collection != null);
+ Requires.NotNull(collection, "collection");
collection.Add(new AttributeRequest(typeUri, false));
}
@@ -43,7 +43,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.AttributeExchange {
/// <param name="typeUri">The type URI of the attribute.</param>
/// <param name="values">The attribute values.</param>
public static void Add(this ICollection<AttributeValues> collection, string typeUri, params string[] values) {
- Contract.Requires<ArgumentNullException>(collection != null);
+ Requires.NotNull(collection, "collection");
collection.Add(new AttributeValues(typeUri, values));
}
@@ -53,8 +53,8 @@ namespace DotNetOpenAuth.OpenId.Extensions.AttributeExchange {
/// <param name="fields">The dictionary to fill with serialized attributes.</param>
/// <param name="attributes">The attributes.</param>
internal static void SerializeAttributes(IDictionary<string, string> fields, IEnumerable<AttributeValues> attributes) {
- Contract.Requires<ArgumentNullException>(fields != null);
- Contract.Requires<ArgumentNullException>(attributes != null);
+ Requires.NotNull(fields, "fields");
+ Requires.NotNull(attributes, "attributes");
AliasManager aliasManager = new AliasManager();
foreach (var att in attributes) {
@@ -123,7 +123,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.AttributeExchange {
/// <param name="fields">The data included in the extension message.</param>
/// <returns>The alias manager that provides lookup between aliases and type URIs.</returns>
private static AliasManager ParseAliases(IDictionary<string, string> fields) {
- Contract.Requires<ArgumentNullException>(fields != null);
+ Requires.NotNull(fields, "fields");
AliasManager aliasManager = new AliasManager();
const string TypePrefix = "type.";
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Extensions/AttributeExchange/AttributeRequest.cs b/src/DotNetOpenAuth.OpenId/OpenId/Extensions/AttributeExchange/AttributeRequest.cs
index 2dc9c69..cbcbff6 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/Extensions/AttributeExchange/AttributeRequest.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/Extensions/AttributeExchange/AttributeRequest.cs
@@ -36,7 +36,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.AttributeExchange {
/// </summary>
/// <param name="typeUri">The unique TypeURI for that describes the attribute being sought.</param>
public AttributeRequest(string typeUri) {
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(typeUri));
+ Requires.NotNullOrEmpty(typeUri, "typeUri");
this.TypeUri = typeUri;
}
@@ -84,7 +84,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.AttributeExchange {
}
set {
- Contract.Requires<ArgumentOutOfRangeException>(value > 0);
+ Requires.InRange(value > 0, "value");
this.count = value;
}
}
@@ -99,8 +99,8 @@ namespace DotNetOpenAuth.OpenId.Extensions.AttributeExchange {
/// the <see cref="FetchResponse"/> object.
/// </returns>
public AttributeValues Respond(params string[] values) {
- Contract.Requires<ArgumentNullException>(values != null);
- Contract.Requires<ArgumentException>(values.Length <= this.Count);
+ Requires.NotNull(values, "values");
+ Requires.True(values.Length <= this.Count, "values");
return new AttributeValues(this.TypeUri, values);
}
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Extensions/AttributeExchange/AttributeValues.cs b/src/DotNetOpenAuth.OpenId/OpenId/Extensions/AttributeExchange/AttributeValues.cs
index b2fc1fe..37ebe38 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/Extensions/AttributeExchange/AttributeValues.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/Extensions/AttributeExchange/AttributeValues.cs
@@ -25,7 +25,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.AttributeExchange {
/// <param name="typeUri">The TypeURI that uniquely identifies the attribute.</param>
/// <param name="values">The values for the attribute.</param>
public AttributeValues(string typeUri, params string[] values) {
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(typeUri));
+ Requires.NotNullOrEmpty(typeUri, "typeUri");
this.TypeUri = typeUri;
this.Values = (IList<string>)values ?? EmptyList<string>.Instance;
@@ -47,7 +47,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.AttributeExchange {
/// </summary>
/// <param name="typeUri">The TypeURI of the attribute whose values are being provided.</param>
internal AttributeValues(string typeUri) {
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(typeUri));
+ Requires.NotNullOrEmpty(typeUri, "typeUri");
this.TypeUri = typeUri;
this.Values = new List<string>(1);
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Extensions/ExtensionArgumentsManager.cs b/src/DotNetOpenAuth.OpenId/OpenId/Extensions/ExtensionArgumentsManager.cs
index 0a78df1..328d81f 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/Extensions/ExtensionArgumentsManager.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/Extensions/ExtensionArgumentsManager.cs
@@ -64,7 +64,7 @@ namespace DotNetOpenAuth.OpenId.Extensions {
/// <param name="query">The parameters in the OpenID message.</param>
/// <returns>The newly created instance of <see cref="ExtensionArgumentsManager"/>.</returns>
public static ExtensionArgumentsManager CreateIncomingExtensions(IDictionary<string, string> query) {
- Contract.Requires<ArgumentNullException>(query != null);
+ Requires.NotNull(query, "query");
var mgr = new ExtensionArgumentsManager();
mgr.protocol = Protocol.Detect(query);
mgr.isReadMode = true;
@@ -134,9 +134,9 @@ namespace DotNetOpenAuth.OpenId.Extensions {
/// <param name="extensionTypeUri">The extension type URI.</param>
/// <param name="arguments">The arguments for this extension to add to the message.</param>
public void AddExtensionArguments(string extensionTypeUri, IDictionary<string, string> arguments) {
- Contract.Requires<InvalidOperationException>(!this.ReadMode);
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(extensionTypeUri));
- Contract.Requires<ArgumentNullException>(arguments != null);
+ Requires.ValidState(!this.ReadMode);
+ Requires.NotNullOrEmpty(extensionTypeUri, "extensionTypeUri");
+ Requires.NotNull(arguments, "arguments");
if (arguments.Count == 0) {
return;
}
@@ -162,7 +162,7 @@ namespace DotNetOpenAuth.OpenId.Extensions {
/// </param>
/// <returns>A dictionary of key=value pairs to add to the message to carry the extension.</returns>
internal IDictionary<string, string> GetArgumentsToSend(bool includeOpenIdPrefix) {
- Contract.Requires<InvalidOperationException>(!this.ReadMode);
+ Requires.ValidState(!this.ReadMode);
Dictionary<string, string> args = new Dictionary<string, string>();
foreach (var typeUriAndExtension in this.extensions) {
string typeUri = typeUriAndExtension.Key;
@@ -195,8 +195,8 @@ namespace DotNetOpenAuth.OpenId.Extensions {
/// The fields included in the given extension, or null if the extension is not present.
/// </returns>
internal IDictionary<string, string> GetExtensionArguments(string extensionTypeUri) {
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(extensionTypeUri));
- Contract.Requires<InvalidOperationException>(this.ReadMode);
+ Requires.NotNullOrEmpty(extensionTypeUri, "extensionTypeUri");
+ Requires.ValidState(this.ReadMode);
IDictionary<string, string> extensionArgs;
this.extensions.TryGetValue(extensionTypeUri, out extensionArgs);
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Extensions/ExtensionsInteropHelper.cs b/src/DotNetOpenAuth.OpenId/OpenId/Extensions/ExtensionsInteropHelper.cs
index 13da4f3..f0af03d 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/Extensions/ExtensionsInteropHelper.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/Extensions/ExtensionsInteropHelper.cs
@@ -58,7 +58,7 @@ namespace DotNetOpenAuth.OpenId.Extensions {
/// <param name="targetFormat">The target format. Only one flag should be set.</param>
/// <returns>The AX attribute type URI in the target format.</returns>
internal static string TransformAXFormat(string axSchemaOrgFormatTypeUri, AXAttributeFormats targetFormat) {
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(axSchemaOrgFormatTypeUri));
+ Requires.NotNullOrEmpty(axSchemaOrgFormatTypeUri, "axSchemaOrgFormatTypeUri");
switch (targetFormat) {
case AXAttributeFormats.AXSchemaOrg:
@@ -78,7 +78,7 @@ namespace DotNetOpenAuth.OpenId.Extensions {
/// <param name="typeURIs">The type URIs to scan for recognized formats.</param>
/// <returns>The first AX type URI format recognized in the list.</returns>
internal static AXAttributeFormats DetectAXFormat(IEnumerable<string> typeURIs) {
- Contract.Requires<ArgumentNullException>(typeURIs != null);
+ Requires.NotNull(typeURIs, "typeURIs");
if (typeURIs.Any(uri => uri.StartsWith("http://axschema.org/", StringComparison.Ordinal))) {
return AXAttributeFormats.AXSchemaOrg;
@@ -103,8 +103,8 @@ namespace DotNetOpenAuth.OpenId.Extensions {
/// <param name="axSchemaOrgFormatAttribute">The attribute in axschema.org format.</param>
/// <param name="demandLevel">The demand level.</param>
internal static void FetchAttribute(FetchRequest ax, AXAttributeFormats format, string axSchemaOrgFormatAttribute, DemandLevel demandLevel) {
- Contract.Requires<ArgumentNullException>(ax != null);
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(axSchemaOrgFormatAttribute));
+ Requires.NotNull(ax, "ax");
+ Requires.NotNullOrEmpty(axSchemaOrgFormatAttribute, "axSchemaOrgFormatAttribute");
string typeUri = TransformAXFormat(axSchemaOrgFormatAttribute, format);
if (!ax.Attributes.Contains(typeUri)) {
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Extensions/ProviderAuthenticationPolicy/PapeUtilities.cs b/src/DotNetOpenAuth.OpenId/OpenId/Extensions/ProviderAuthenticationPolicy/PapeUtilities.cs
index eeaea31..d8ffb63 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/Extensions/ProviderAuthenticationPolicy/PapeUtilities.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/Extensions/ProviderAuthenticationPolicy/PapeUtilities.cs
@@ -46,7 +46,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.ProviderAuthenticationPolicy {
/// <returns>The concatenated string of elements.</returns>
/// <exception cref="FormatException">Thrown if any element in the sequence includes a space.</exception>
internal static string ConcatenateListOfElements(IEnumerable<string> values) {
- Contract.Requires<ArgumentNullException>(values != null);
+ Requires.NotNull(values, "values");
StringBuilder valuesList = new StringBuilder();
foreach (string value in values.Distinct()) {
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Extensions/ProviderAuthenticationPolicy/PolicyResponse.cs b/src/DotNetOpenAuth.OpenId/OpenId/Extensions/ProviderAuthenticationPolicy/PolicyResponse.cs
index 246ec07..1fddc22 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/Extensions/ProviderAuthenticationPolicy/PolicyResponse.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/Extensions/ProviderAuthenticationPolicy/PolicyResponse.cs
@@ -83,7 +83,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.ProviderAuthenticationPolicy {
}
set {
- Contract.Requires<ArgumentException>(!value.HasValue || value.Value.Kind != DateTimeKind.Unspecified, OpenIdStrings.UnspecifiedDateTimeKindNotAllowed);
+ Requires.True(!value.HasValue || value.Value.Kind != DateTimeKind.Unspecified, "value", OpenIdStrings.UnspecifiedDateTimeKindNotAllowed);
// Make sure that whatever is set here, it becomes UTC time.
if (value.HasValue) {
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Extensions/SimpleRegistration/ClaimsRequest.cs b/src/DotNetOpenAuth.OpenId/OpenId/Extensions/SimpleRegistration/ClaimsRequest.cs
index cec8042..18f63d4 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/Extensions/SimpleRegistration/ClaimsRequest.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/Extensions/SimpleRegistration/ClaimsRequest.cs
@@ -51,7 +51,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration {
/// <param name="typeUri">The type URI this extension was recognized by in the OpenID message.</param>
internal ClaimsRequest(string typeUri)
: this() {
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(typeUri));
+ Requires.NotNullOrEmpty(typeUri, "typeUri");
this.typeUriDeserializedFrom = typeUri;
}
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs b/src/DotNetOpenAuth.OpenId/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs
index d4df028..b50833b 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs
@@ -70,7 +70,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration {
/// </param>
internal ClaimsResponse(string typeUriToUse)
: base(new Version(1, 0), typeUriToUse, Constants.AdditionalTypeUris) {
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(typeUriToUse));
+ Requires.NotNullOrEmpty(typeUriToUse, "typeUriToUse");
}
/// <summary>
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/HmacShaAssociation.cs b/src/DotNetOpenAuth.OpenId/OpenId/HmacShaAssociation.cs
index 6955f48..d723756 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/HmacShaAssociation.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/HmacShaAssociation.cs
@@ -61,10 +61,10 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="totalLifeLength">The time duration the association will be good for.</param>
private HmacShaAssociation(HmacSha typeIdentity, string handle, byte[] secret, TimeSpan totalLifeLength)
: base(handle, secret, totalLifeLength, DateTime.UtcNow) {
- Contract.Requires<ArgumentNullException>(typeIdentity != null);
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(handle));
- Contract.Requires<ArgumentNullException>(secret != null);
- Contract.Requires<ArgumentOutOfRangeException>(totalLifeLength > TimeSpan.Zero);
+ Requires.NotNull(typeIdentity, "typeIdentity");
+ Requires.NotNullOrEmpty(handle, "handle");
+ Requires.NotNull(secret, "secret");
+ Requires.InRange(totalLifeLength > TimeSpan.Zero, "totalLifeLength");
Contract.Ensures(this.TotalLifeLength == totalLifeLength);
ErrorUtilities.VerifyProtocol(secret.Length == typeIdentity.SecretLength, OpenIdStrings.AssociationSecretAndTypeLengthMismatch, secret.Length, typeIdentity.GetAssociationType(Protocol.Default));
@@ -91,9 +91,9 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="totalLifeLength">How long the association will be good for.</param>
/// <returns>The newly created association.</returns>
public static HmacShaAssociation Create(Protocol protocol, string associationType, string handle, byte[] secret, TimeSpan totalLifeLength) {
- Contract.Requires<ArgumentNullException>(protocol != null);
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(associationType));
- Contract.Requires<ArgumentNullException>(secret != null);
+ Requires.NotNull(protocol, "protocol");
+ Requires.NotNullOrEmpty(associationType, "associationType");
+ Requires.NotNull(secret, "secret");
Contract.Ensures(Contract.Result<HmacShaAssociation>() != null);
HmacSha match = hmacShaAssociationTypes.FirstOrDefault(sha => String.Equals(sha.GetAssociationType(protocol), associationType, StringComparison.Ordinal));
ErrorUtilities.VerifyProtocol(match != null, OpenIdStrings.NoAssociationTypeFoundByName, associationType);
@@ -108,8 +108,8 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="totalLifeLength">Total lifetime.</param>
/// <returns>The newly created association.</returns>
public static HmacShaAssociation Create(string handle, byte[] secret, TimeSpan totalLifeLength) {
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(handle));
- Contract.Requires<ArgumentNullException>(secret != null);
+ Requires.NotNullOrEmpty(handle, "handle");
+ Requires.NotNull(secret, "secret");
Contract.Ensures(Contract.Result<HmacShaAssociation>() != null);
HmacSha shaType = hmacShaAssociationTypes.FirstOrDefault(sha => sha.SecretLength == secret.Length);
@@ -145,8 +145,8 @@ namespace DotNetOpenAuth.OpenId {
/// True if a qualifying association could be found; false otherwise.
/// </returns>
internal static bool TryFindBestAssociation(Protocol protocol, bool highSecurityIsBetter, SecuritySettings securityRequirements, bool requireMatchingDHSessionType, out string associationType, out string sessionType) {
- Contract.Requires<ArgumentNullException>(protocol != null);
- Contract.Requires<ArgumentNullException>(securityRequirements != null);
+ Requires.NotNull(protocol, "protocol");
+ Requires.NotNull(securityRequirements, "securityRequirements");
associationType = null;
sessionType = null;
@@ -186,9 +186,9 @@ namespace DotNetOpenAuth.OpenId {
/// <c>true</c> if the named association and session types are compatible; otherwise, <c>false</c>.
/// </returns>
internal static bool IsDHSessionCompatible(Protocol protocol, string associationType, string sessionType) {
- Contract.Requires<ArgumentNullException>(protocol != null);
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(associationType));
- Contract.Requires<ArgumentNullException>(sessionType != null);
+ Requires.NotNull(protocol, "protocol");
+ Requires.NotNullOrEmpty(associationType, "associationType");
+ Requires.NotNull(sessionType, "sessionType");
// All association types can work when no DH session is used at all.
if (string.Equals(sessionType, protocol.Args.SessionType.NoEncryption, StringComparison.Ordinal)) {
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/IIdentifierDiscoveryService.cs b/src/DotNetOpenAuth.OpenId/OpenId/IIdentifierDiscoveryService.cs
index fcea327..f5cefe2 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/IIdentifierDiscoveryService.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/IIdentifierDiscoveryService.cs
@@ -56,8 +56,8 @@ namespace DotNetOpenAuth.OpenId {
/// A sequence of service endpoints yielded by discovery. Must not be null, but may be empty.
/// </returns>
IEnumerable<IdentifierDiscoveryResult> IIdentifierDiscoveryService.Discover(Identifier identifier, IDirectWebRequestHandler requestHandler, out bool abortDiscoveryChain) {
- Contract.Requires<ArgumentNullException>(identifier != null);
- Contract.Requires<ArgumentNullException>(requestHandler != null);
+ Requires.NotNull(identifier, "identifier");
+ Requires.NotNull(requestHandler, "requestHandler");
Contract.Ensures(Contract.Result<IEnumerable<IdentifierDiscoveryResult>>() != null);
throw new NotImplementedException();
}
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/IProviderEndpoint.cs b/src/DotNetOpenAuth.OpenId/OpenId/IProviderEndpoint.cs
index 5d8918d..e2a8929 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/IProviderEndpoint.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/IProviderEndpoint.cs
@@ -134,8 +134,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// the extension in the request and see if a response comes back for that extension.
/// </remarks>
bool IProviderEndpoint.IsExtensionSupported(Type extensionType) {
- Contract.Requires<ArgumentNullException>(extensionType != null);
- Contract.Requires<ArgumentException>(typeof(IOpenIdMessageExtension).IsAssignableFrom(extensionType));
+ Requires.NotNullSubtype<IOpenIdMessageExtension>(extensionType, "extensionType");
throw new NotImplementedException();
}
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Identifier.cs b/src/DotNetOpenAuth.OpenId/OpenId/Identifier.cs
index b54d1fc..aeb0e6b 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/Identifier.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/Identifier.cs
@@ -103,7 +103,7 @@ namespace DotNetOpenAuth.OpenId {
[SuppressMessage("Microsoft.Usage", "CA2225:OperatorOverloadsHaveNamedAlternates", Justification = "Our named alternate is Parse.")]
[DebuggerStepThrough]
public static implicit operator Identifier(string identifier) {
- Contract.Requires<ArgumentException>(identifier == null || identifier.Length > 0);
+ Requires.True(identifier == null || identifier.Length > 0, "identifier");
Contract.Ensures((identifier == null) == (Contract.Result<Identifier>() == null));
if (identifier == null) {
@@ -151,7 +151,7 @@ namespace DotNetOpenAuth.OpenId {
/// <returns>An <see cref="Identifier"/> instance for the given value.</returns>
[SuppressMessage("Microsoft.Usage", "CA2234:PassSystemUriObjectsInsteadOfStrings", Justification = "Some of these identifiers are not properly formatted to be Uris at this stage.")]
public static Identifier Parse(string identifier) {
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(identifier));
+ Requires.NotNullOrEmpty(identifier, "identifier");
Contract.Ensures(Contract.Result<Identifier>() != null);
return Parse(identifier, false);
@@ -168,7 +168,7 @@ namespace DotNetOpenAuth.OpenId {
/// </returns>
[SuppressMessage("Microsoft.Usage", "CA2234:PassSystemUriObjectsInsteadOfStrings", Justification = "Some of these identifiers are not properly formatted to be Uris at this stage.")]
public static Identifier Parse(string identifier, bool serializeExactValue) {
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(identifier));
+ Requires.NotNullOrEmpty(identifier, "identifier");
Contract.Ensures(Contract.Result<Identifier>() != null);
Identifier id;
@@ -214,7 +214,7 @@ namespace DotNetOpenAuth.OpenId {
/// </returns>
[SuppressMessage("Microsoft.Usage", "CA2234:PassSystemUriObjectsInsteadOfStrings", Justification = "Some of these identifiers are not properly formatted to be Uris at this stage.")]
public static bool IsValid(string identifier) {
- Contract.Requires<ArgumentException>(!string.IsNullOrEmpty(identifier));
+ Requires.NotNullOrEmpty(identifier, "identifier");
return XriIdentifier.IsValidXri(identifier) || UriIdentifier.IsValidUri(identifier);
}
@@ -275,7 +275,7 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="identifier">The identifier.</param>
/// <returns>Either <see cref="XriIdentifier"/> or <see cref="UriIdentifier"/>.</returns>
internal static Identifier Reparse(Identifier identifier) {
- Contract.Requires<ArgumentNullException>(identifier != null);
+ Requires.NotNull(identifier, "identifier");
Contract.Ensures(Contract.Result<Identifier>() != null);
return Parse(identifier, identifier.IsDeserializedInstance);
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/IdentifierDiscoveryResult.cs b/src/DotNetOpenAuth.OpenId/OpenId/IdentifierDiscoveryResult.cs
index c851f24..07abf1e 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/IdentifierDiscoveryResult.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/IdentifierDiscoveryResult.cs
@@ -49,8 +49,8 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="servicePriority">The service priority.</param>
/// <param name="uriPriority">The URI priority.</param>
private IdentifierDiscoveryResult(ProviderEndpointDescription providerEndpoint, Identifier claimedIdentifier, Identifier userSuppliedIdentifier, Identifier providerLocalIdentifier, int? servicePriority, int? uriPriority) {
- Contract.Requires<ArgumentNullException>(providerEndpoint != null);
- Contract.Requires<ArgumentNullException>(claimedIdentifier != null);
+ Requires.NotNull(providerEndpoint, "providerEndpoint");
+ Requires.NotNull(claimedIdentifier, "claimedIdentifier");
this.ProviderEndpoint = providerEndpoint.Uri;
this.Capabilities = new ReadOnlyCollection<string>(providerEndpoint.Capabilities);
this.Version = providerEndpoint.Version;
@@ -366,7 +366,7 @@ namespace DotNetOpenAuth.OpenId {
/// <c>true</c> if the extension is supported by this endpoint; otherwise, <c>false</c>.
/// </returns>
public bool IsExtensionSupported(IOpenIdMessageExtension extension) {
- Contract.Requires<ArgumentNullException>(extension != null);
+ Requires.NotNull(extension, "extension");
// Consider the primary case.
if (this.IsTypeUriPresent(extension.TypeUri)) {
@@ -392,7 +392,7 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="uriPriority">The URI priority.</param>
/// <returns>The created <see cref="IdentifierDiscoveryResult"/> instance</returns>
internal static IdentifierDiscoveryResult CreateForProviderIdentifier(Identifier providerIdentifier, ProviderEndpointDescription providerEndpoint, int? servicePriority, int? uriPriority) {
- Contract.Requires<ArgumentNullException>(providerEndpoint != null);
+ Requires.NotNull(providerEndpoint, "providerEndpoint");
Protocol protocol = Protocol.Lookup(providerEndpoint.Version);
@@ -440,7 +440,7 @@ namespace DotNetOpenAuth.OpenId {
/// <c>true</c> if the type URI is present on the specified provider endpoint; otherwise, <c>false</c>.
/// </returns>
internal bool IsTypeUriPresent(string typeUri) {
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(typeUri));
+ Requires.NotNullOrEmpty(typeUri, "typeUri");
return this.Capabilities.Contains(typeUri);
}
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Messages/CheckAuthenticationRequest.cs b/src/DotNetOpenAuth.OpenId/OpenId/Messages/CheckAuthenticationRequest.cs
index db69d3d..273c444 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/Messages/CheckAuthenticationRequest.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/Messages/CheckAuthenticationRequest.cs
@@ -41,7 +41,7 @@ namespace DotNetOpenAuth.OpenId.Messages {
/// <param name="channel">The channel. This is used only within the constructor and is not stored in a field.</param>
internal CheckAuthenticationRequest(IndirectSignedResponse message, Channel channel)
: base(message.Version, message.ProviderEndpoint, GetProtocolConstant(message.Version, p => p.Args.Mode.check_authentication), MessageTransport.Direct) {
- Contract.Requires<ArgumentNullException>(channel != null);
+ Requires.NotNull(channel, "channel");
// Copy all message parts from the id_res message into this one,
// except for the openid.mode parameter.
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Messages/DirectResponseBase.cs b/src/DotNetOpenAuth.OpenId/OpenId/Messages/DirectResponseBase.cs
index e7619bc..da6a1f6 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/Messages/DirectResponseBase.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/Messages/DirectResponseBase.cs
@@ -54,7 +54,7 @@ namespace DotNetOpenAuth.OpenId.Messages {
/// <param name="responseVersion">The OpenID version of the response message.</param>
/// <param name="originatingRequest">The originating request. May be null in case the request is unrecognizable and this is an error response.</param>
protected DirectResponseBase(Version responseVersion, IDirectedProtocolMessage originatingRequest) {
- Contract.Requires<ArgumentNullException>(responseVersion != null);
+ Requires.NotNull(responseVersion, "responseVersion");
this.Version = responseVersion;
this.originatingRequest = originatingRequest;
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Messages/IndirectResponseBase.cs b/src/DotNetOpenAuth.OpenId/OpenId/Messages/IndirectResponseBase.cs
index fce6028..f23d912 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/Messages/IndirectResponseBase.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/Messages/IndirectResponseBase.cs
@@ -29,7 +29,7 @@ namespace DotNetOpenAuth.OpenId.Messages {
/// <param name="mode">The value of the openid.mode parameter.</param>
protected IndirectResponseBase(SignedResponseRequest request, string mode)
: base(GetVersion(request), GetReturnTo(request), mode, MessageTransport.Indirect) {
- Contract.Requires<ArgumentNullException>(request != null);
+ Requires.NotNull(request, "request");
this.OriginatingRequest = request;
}
@@ -91,7 +91,7 @@ namespace DotNetOpenAuth.OpenId.Messages {
/// instead of a <see cref="NullReferenceException"/>.
/// </remarks>
internal static Version GetVersion(IProtocolMessage message) {
- Contract.Requires<ArgumentNullException>(message != null);
+ Requires.NotNull(message, "message");
return message.Version;
}
@@ -105,7 +105,7 @@ namespace DotNetOpenAuth.OpenId.Messages {
/// instead of a <see cref="NullReferenceException"/>.
/// </remarks>
private static Uri GetReturnTo(SignedResponseRequest message) {
- Contract.Requires<ArgumentNullException>(message != null);
+ Requires.NotNull(message, "message");
ErrorUtilities.VerifyProtocol(message.ReturnTo != null, OpenIdStrings.ReturnToRequiredForResponse);
return message.ReturnTo;
}
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Messages/IndirectSignedResponse.cs b/src/DotNetOpenAuth.OpenId/OpenId/Messages/IndirectSignedResponse.cs
index baeae16..9a60757 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/Messages/IndirectSignedResponse.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/Messages/IndirectSignedResponse.cs
@@ -57,7 +57,7 @@ namespace DotNetOpenAuth.OpenId.Messages {
/// </param>
internal IndirectSignedResponse(SignedResponseRequest request)
: base(request, Protocol.Lookup(GetVersion(request)).Args.Mode.id_res) {
- Contract.Requires<ArgumentNullException>(request != null);
+ Requires.NotNull(request, "request");
this.ReturnTo = request.ReturnTo;
this.ProviderEndpoint = request.Recipient.StripQueryArgumentsWithPrefix(Protocol.openid.Prefix);
@@ -72,7 +72,7 @@ namespace DotNetOpenAuth.OpenId.Messages {
/// <param name="channel">The channel. This is used only within the constructor and is not stored in a field.</param>
internal IndirectSignedResponse(CheckAuthenticationRequest previouslySignedMessage, Channel channel)
: base(GetVersion(previouslySignedMessage), previouslySignedMessage.ReturnTo, Protocol.Lookup(GetVersion(previouslySignedMessage)).Args.Mode.id_res) {
- Contract.Requires<ArgumentNullException>(channel != null);
+ Requires.NotNull(channel, "channel");
// Copy all message parts from the check_authentication message into this one,
// except for the openid.mode parameter.
@@ -324,7 +324,7 @@ namespace DotNetOpenAuth.OpenId.Messages {
/// cannot verify the private signature made by the relying party.
/// </remarks>
internal string GetReturnToArgument(string key) {
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(key));
+ Requires.NotNullOrEmpty(key, "key");
ErrorUtilities.VerifyInternal(this.ReturnTo != null, "ReturnTo was expected to be required but is null.");
string value;
@@ -350,7 +350,7 @@ namespace DotNetOpenAuth.OpenId.Messages {
/// A dictionary of the signed message parts.
/// </returns>
internal IDictionary<string, string> GetSignedMessageParts(Channel channel) {
- Contract.Requires<ArgumentNullException>(channel != null);
+ Requires.NotNull(channel, "channel");
ITamperResistantOpenIdMessage signedSelf = this;
if (signedSelf.SignedParameterOrder == null) {
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Messages/NegativeAssertionResponse.cs b/src/DotNetOpenAuth.OpenId/OpenId/Messages/NegativeAssertionResponse.cs
index 5b6cb05..a6303ab 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/Messages/NegativeAssertionResponse.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/Messages/NegativeAssertionResponse.cs
@@ -114,8 +114,8 @@ namespace DotNetOpenAuth.OpenId.Messages {
/// <param name="channel">The channel to use to simulate construction of the message.</param>
/// <returns>The value to use for the user_setup_url parameter.</returns>
private static Uri ConstructUserSetupUrl(CheckIdRequest immediateRequest, Channel channel) {
- Contract.Requires<ArgumentNullException>(immediateRequest != null);
- Contract.Requires<ArgumentNullException>(channel != null);
+ Requires.NotNull(immediateRequest, "immediateRequest");
+ Requires.NotNull(channel, "channel");
ErrorUtilities.VerifyInternal(immediateRequest.Immediate, "Only immediate requests should be sent here.");
var setupRequest = new CheckIdRequest(immediateRequest.Version, immediateRequest.Recipient, AuthenticationRequestMode.Setup);
@@ -132,7 +132,7 @@ namespace DotNetOpenAuth.OpenId.Messages {
/// <param name="request">The request that we're responding to.</param>
/// <returns>The value of the openid.mode parameter to use.</returns>
private static string GetMode(SignedResponseRequest request) {
- Contract.Requires<ArgumentNullException>(request != null);
+ Requires.NotNull(request, "request");
Protocol protocol = Protocol.Lookup(request.Version);
return request.Immediate ? protocol.Args.Mode.setup_needed : protocol.Args.Mode.cancel;
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Messages/RequestBase.cs b/src/DotNetOpenAuth.OpenId/OpenId/Messages/RequestBase.cs
index 8e4cb9d..a24c7db 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/Messages/RequestBase.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/Messages/RequestBase.cs
@@ -49,8 +49,8 @@ namespace DotNetOpenAuth.OpenId.Messages {
/// <param name="mode">The value for the openid.mode parameter.</param>
/// <param name="transport">A value indicating whether the message will be transmitted directly or indirectly.</param>
protected RequestBase(Version version, Uri providerEndpoint, string mode, MessageTransport transport) {
- Contract.Requires<ArgumentNullException>(providerEndpoint != null);
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(mode));
+ Requires.NotNull(providerEndpoint, "providerEndpoint");
+ Requires.NotNullOrEmpty(mode, "mode");
this.Recipient = providerEndpoint;
this.Mode = mode;
@@ -178,7 +178,7 @@ namespace DotNetOpenAuth.OpenId.Messages {
/// instead of a <see cref="NullReferenceException"/>.
/// </remarks>
protected static string GetProtocolConstant(Version protocolVersion, Func<Protocol, string> mode) {
- Contract.Requires<ArgumentNullException>(protocolVersion != null);
+ Requires.NotNull(protocolVersion, "protocolVersion");
return mode(Protocol.Lookup(protocolVersion));
}
}
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Messages/SignedResponseRequest.cs b/src/DotNetOpenAuth.OpenId/OpenId/Messages/SignedResponseRequest.cs
index b1c9283..3719f96 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/Messages/SignedResponseRequest.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/Messages/SignedResponseRequest.cs
@@ -144,7 +144,7 @@ namespace DotNetOpenAuth.OpenId.Messages {
/// when and if a positive assertion comes back from the Provider.
/// </remarks>
internal void AddReturnToArguments(IEnumerable<KeyValuePair<string, string>> keysValues) {
- Contract.Requires<ArgumentNullException>(keysValues != null);
+ Requires.NotNull(keysValues, "keysValues");
ErrorUtilities.VerifyOperation(this.ReturnTo != null, OpenIdStrings.ReturnToRequiredForOperation);
UriBuilder returnToBuilder = new UriBuilder(this.ReturnTo);
returnToBuilder.AppendAndReplaceQueryArgs(keysValues);
@@ -175,7 +175,7 @@ namespace DotNetOpenAuth.OpenId.Messages {
/// </param>
/// <returns>checkid_immediate or checkid_setup</returns>
private static string GetMode(Version version, AuthenticationRequestMode mode) {
- Contract.Requires<ArgumentNullException>(version != null);
+ Requires.NotNull(version, "version");
Protocol protocol = Protocol.Lookup(version);
return mode == AuthenticationRequestMode.Immediate ? protocol.Args.Mode.checkid_immediate : protocol.Args.Mode.checkid_setup;
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/NoDiscoveryIdentifier.cs b/src/DotNetOpenAuth.OpenId/OpenId/NoDiscoveryIdentifier.cs
index 7dc2c0c..d1704fc 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/NoDiscoveryIdentifier.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/NoDiscoveryIdentifier.cs
@@ -29,7 +29,7 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="claimSsl">Whether this Identifier should claim to be SSL-secure, although no discovery will never generate service endpoints anyway.</param>
internal NoDiscoveryIdentifier(Identifier wrappedIdentifier, bool claimSsl)
: base(wrappedIdentifier.OriginalString, claimSsl) {
- Contract.Requires<ArgumentNullException>(wrappedIdentifier != null);
+ Requires.NotNull(wrappedIdentifier, "wrappedIdentifier");
this.wrappedIdentifier = wrappedIdentifier;
}
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/OpenIdUtilities.cs b/src/DotNetOpenAuth.OpenId/OpenId/OpenIdUtilities.cs
index 95b3427..b7f857e 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/OpenIdUtilities.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/OpenIdUtilities.cs
@@ -47,7 +47,7 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="message">The message.</param>
/// <returns>The OpenID protocol instance.</returns>
internal static Protocol GetProtocol(this IProtocolMessage message) {
- Contract.Requires<ArgumentNullException>(message != null);
+ Requires.NotNull(message, "message");
return Protocol.Lookup(message.Version);
}
@@ -116,8 +116,8 @@ namespace DotNetOpenAuth.OpenId {
/// <returns>The fully-qualified realm.</returns>
[SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", MessageId = "DotNetOpenAuth.OpenId.Realm", Justification = "Using ctor for validation.")]
internal static UriBuilder GetResolvedRealm(Page page, string realm, HttpRequestInfo requestContext) {
- Contract.Requires<ArgumentNullException>(page != null);
- Contract.Requires<ArgumentNullException>(requestContext != null);
+ Requires.NotNull(page, "page");
+ Requires.NotNull(requestContext, "requestContext");
// Allow for *. realm notation, as well as ASP.NET ~/ shortcuts.
@@ -159,7 +159,7 @@ namespace DotNetOpenAuth.OpenId {
/// can plug in.
/// </remarks>
internal static IList<IOpenIdExtensionFactory> GetExtensionFactories(this Channel channel) {
- Contract.Requires<ArgumentNullException>(channel != null);
+ Requires.NotNull(channel, "channel");
var extensionsBindingElement = channel.BindingElements.OfType<ExtensionsBindingElement>().SingleOrDefault();
ErrorUtilities.VerifyOperation(extensionsBindingElement != null, OpenIdStrings.UnsupportedChannelConfiguration);
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/OpenIdXrdsHelper.cs b/src/DotNetOpenAuth.OpenId/OpenId/OpenIdXrdsHelper.cs
index 9f1e0d7..9f996a5 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/OpenIdXrdsHelper.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/OpenIdXrdsHelper.cs
@@ -26,7 +26,7 @@ namespace DotNetOpenAuth.OpenId {
/// or for Provider's to perform RP discovery/verification as part of authentication.
/// </remarks>
internal static IEnumerable<RelyingPartyEndpointDescription> FindRelyingPartyReceivingEndpoints(this XrdsDocument xrds) {
- Contract.Requires<ArgumentNullException>(xrds != null);
+ Requires.NotNull(xrds, "xrds");
Contract.Ensures(Contract.Result<IEnumerable<RelyingPartyEndpointDescription>>() != null);
return from service in xrds.FindReturnToServices()
@@ -41,7 +41,7 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="xrds">The XrdsDocument to search.</param>
/// <returns>A sequence of the icon URLs in preferred order.</returns>
internal static IEnumerable<Uri> FindRelyingPartyIcons(this XrdsDocument xrds) {
- Contract.Requires<ArgumentNullException>(xrds != null);
+ Requires.NotNull(xrds, "xrds");
Contract.Ensures(Contract.Result<IEnumerable<Uri>>() != null);
return from xrd in xrds.XrdElements
@@ -57,7 +57,7 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="xrds">The XrdsDocument instance to use in this process.</param>
/// <returns>A sequence of service elements.</returns>
private static IEnumerable<ServiceElement> FindReturnToServices(this XrdsDocument xrds) {
- Contract.Requires<ArgumentNullException>(xrds != null);
+ Requires.NotNull(xrds, "xrds");
Contract.Ensures(Contract.Result<IEnumerable<ServiceElement>>() != null);
return from xrd in xrds.XrdElements
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Protocol.cs b/src/DotNetOpenAuth.OpenId/OpenId/Protocol.cs
index 5aacfd2..a651f3c 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/Protocol.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/Protocol.cs
@@ -157,7 +157,7 @@ namespace DotNetOpenAuth.OpenId {
/// of an incoming OpenID <i>indirect</i> message or <i>direct request</i>.
/// </summary>
internal static Protocol Detect(IDictionary<string, string> query) {
- Contract.Requires<ArgumentNullException>(query != null);
+ Requires.NotNull(query, "query");
return query.ContainsKey(V20.openid.ns) ? V20 : V11;
}
/// <summary>
@@ -165,7 +165,7 @@ namespace DotNetOpenAuth.OpenId {
/// of an incoming OpenID <i>direct</i> response message.
/// </summary>
internal static Protocol DetectFromDirectResponse(IDictionary<string, string> query) {
- Contract.Requires<ArgumentNullException>(query != null);
+ Requires.NotNull(query, "query");
return query.ContainsKey(V20.openidnp.ns) ? V20 : V11;
}
/// <summary>
@@ -173,7 +173,7 @@ namespace DotNetOpenAuth.OpenId {
/// of XRDS Service Type URIs included for some service.
/// </summary>
internal static Protocol Detect(IEnumerable<string> serviceTypeURIs) {
- Contract.Requires<ArgumentNullException>(serviceTypeURIs != null);
+ Requires.NotNull(serviceTypeURIs, "serviceTypeURIs");
return FindBestVersion(p => p.OPIdentifierServiceTypeURI, serviceTypeURIs) ??
FindBestVersion(p => p.ClaimedIdentifierServiceTypeURI, serviceTypeURIs) ??
FindBestVersion(p => p.RPReturnToTypeURI, serviceTypeURIs);
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Provider/IAuthenticationRequest.cs b/src/DotNetOpenAuth.OpenId/OpenId/Provider/IAuthenticationRequest.cs
index 4942397..1045282 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/Provider/IAuthenticationRequest.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/Provider/IAuthenticationRequest.cs
@@ -176,8 +176,8 @@ namespace DotNetOpenAuth.OpenId.Provider {
set {
IAuthenticationRequest req = this;
- Contract.Requires<InvalidOperationException>(!req.IsDelegatedIdentifier, OpenIdStrings.ClaimedIdentifierCannotBeSetOnDelegatedAuthentication);
- Contract.Requires<InvalidOperationException>(!req.IsDirectedIdentity || !(req.LocalIdentifier != null && req.LocalIdentifier != value), OpenIdStrings.IdentifierSelectRequiresMatchingIdentifiers);
+ Requires.ValidState(!req.IsDelegatedIdentifier, OpenIdStrings.ClaimedIdentifierCannotBeSetOnDelegatedAuthentication);
+ Requires.ValidState(!req.IsDirectedIdentity || !(req.LocalIdentifier != null && req.LocalIdentifier != value), OpenIdStrings.IdentifierSelectRequiresMatchingIdentifiers);
}
}
@@ -293,8 +293,8 @@ namespace DotNetOpenAuth.OpenId.Provider {
/// request before the <see cref="IAuthenticationRequest.ClaimedIdentifier"/> property is set.
/// </exception>
void IAuthenticationRequest.SetClaimedIdentifierFragment(string fragment) {
- Contract.Requires<InvalidOperationException>(!(((IAuthenticationRequest)this).IsDirectedIdentity && ((IAuthenticationRequest)this).ClaimedIdentifier == null), OpenIdStrings.ClaimedIdentifierMustBeSetFirst);
- Contract.Requires<InvalidOperationException>(!(((IAuthenticationRequest)this).ClaimedIdentifier is XriIdentifier), OpenIdStrings.FragmentNotAllowedOnXRIs);
+ Requires.ValidState(!(((IAuthenticationRequest)this).IsDirectedIdentity && ((IAuthenticationRequest)this).ClaimedIdentifier == null), OpenIdStrings.ClaimedIdentifierMustBeSetFirst);
+ Requires.ValidState(!(((IAuthenticationRequest)this).ClaimedIdentifier is XriIdentifier), OpenIdStrings.FragmentNotAllowedOnXRIs);
throw new NotImplementedException();
}
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Provider/IHostProcessedRequest.cs b/src/DotNetOpenAuth.OpenId/OpenId/Provider/IHostProcessedRequest.cs
index 4064ef1..809c0f3 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/Provider/IHostProcessedRequest.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/Provider/IHostProcessedRequest.cs
@@ -193,7 +193,7 @@ namespace DotNetOpenAuth.OpenId.Provider {
/// <para>See OpenID Authentication 2.0 spec section 9.2.1.</para>
/// </remarks>
RelyingPartyDiscoveryResult IHostProcessedRequest.IsReturnUrlDiscoverable(IDirectWebRequestHandler webRequestHandler) {
- Contract.Requires<ArgumentNullException>(webRequestHandler != null);
+ Requires.NotNull(webRequestHandler, "webRequestHandler");
throw new System.NotImplementedException();
}
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Provider/IProviderBehavior.cs b/src/DotNetOpenAuth.OpenId/OpenId/Provider/IProviderBehavior.cs
index 01b4ac8..9750625 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/Provider/IProviderBehavior.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/Provider/IProviderBehavior.cs
@@ -74,7 +74,7 @@ namespace DotNetOpenAuth.OpenId.Provider {
/// incompatible with each other.
/// </remarks>
void IProviderBehavior.ApplySecuritySettings(ProviderSecuritySettings securitySettings) {
- Contract.Requires<ArgumentNullException>(securitySettings != null);
+ Requires.NotNull(securitySettings, "securitySettings");
throw new System.NotImplementedException();
}
@@ -92,7 +92,7 @@ namespace DotNetOpenAuth.OpenId.Provider {
/// itself as that instance may be shared across many requests.
/// </remarks>
bool IProviderBehavior.OnIncomingRequest(IRequest request) {
- Contract.Requires<ArgumentNullException>(request != null);
+ Requires.NotNull(request, "request");
throw new System.NotImplementedException();
}
@@ -105,7 +105,7 @@ namespace DotNetOpenAuth.OpenId.Provider {
/// from handling it; <c>false</c> to allow other behaviors to process this request.
/// </returns>
bool IProviderBehavior.OnOutgoingResponse(IAuthenticationRequest request) {
- Contract.Requires<ArgumentNullException>(request != null);
+ Requires.NotNull(request, "request");
throw new System.NotImplementedException();
}
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Provider/IRequest.cs b/src/DotNetOpenAuth.OpenId/OpenId/Provider/IRequest.cs
index 1cb1a4b..1870bfe 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/Provider/IRequest.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/Provider/IRequest.cs
@@ -107,7 +107,7 @@ namespace DotNetOpenAuth.OpenId.Provider {
/// </summary>
/// <param name="extension">The extension to add to the response message.</param>
void IRequest.AddResponseExtension(IOpenIdMessageExtension extension) {
- Contract.Requires<ArgumentNullException>(extension != null);
+ Requires.NotNull(extension, "extension");
throw new NotImplementedException();
}
@@ -140,7 +140,7 @@ namespace DotNetOpenAuth.OpenId.Provider {
/// An instance of the extension initialized with values passed in with the request.
/// </returns>
IOpenIdMessageExtension IRequest.GetExtension(Type extensionType) {
- Contract.Requires<ArgumentNullException>(extensionType != null);
+ Requires.NotNull(extensionType, "extensionType");
throw new NotImplementedException();
}
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/ProviderEndpointDescription.cs b/src/DotNetOpenAuth.OpenId/OpenId/ProviderEndpointDescription.cs
index 6514ffd..092ec22 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/ProviderEndpointDescription.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/ProviderEndpointDescription.cs
@@ -29,8 +29,8 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="providerEndpoint">The OpenID Provider endpoint URL.</param>
/// <param name="openIdVersion">The OpenID version supported by this particular endpoint.</param>
internal ProviderEndpointDescription(Uri providerEndpoint, Version openIdVersion) {
- Contract.Requires<ArgumentNullException>(providerEndpoint != null);
- Contract.Requires<ArgumentNullException>(openIdVersion != null);
+ Requires.NotNull(providerEndpoint, "providerEndpoint");
+ Requires.NotNull(openIdVersion, "openIdVersion");
this.Uri = providerEndpoint;
this.Version = openIdVersion;
@@ -43,8 +43,8 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="providerEndpoint">The URI the provider listens on for OpenID requests.</param>
/// <param name="serviceTypeURIs">The set of services offered by this endpoint.</param>
internal ProviderEndpointDescription(Uri providerEndpoint, IEnumerable<string> serviceTypeURIs) {
- Contract.Requires<ArgumentNullException>(providerEndpoint != null);
- Contract.Requires<ArgumentNullException>(serviceTypeURIs != null);
+ Requires.NotNull(providerEndpoint, "providerEndpoint");
+ Requires.NotNull(serviceTypeURIs, "serviceTypeURIs");
this.Uri = providerEndpoint;
this.Capabilities = new ReadOnlyCollection<string>(serviceTypeURIs.ToList());
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Realm.cs b/src/DotNetOpenAuth.OpenId/OpenId/Realm.cs
index c00653b..685b922 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/Realm.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/Realm.cs
@@ -75,7 +75,7 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="realmUrl">The realm URL to use in the new instance.</param>
[SuppressMessage("Microsoft.Design", "CA1057:StringUriOverloadsCallSystemUriOverloads", Justification = "Not all realms are valid URLs (because of wildcards).")]
public Realm(string realmUrl) {
- Contract.Requires<ArgumentNullException>(realmUrl != null); // not non-zero check so we throw UriFormatException later
+ Requires.NotNull(realmUrl, "realmUrl"); // not non-zero check so we throw UriFormatException later
this.DomainWildcard = Regex.IsMatch(realmUrl, WildcardDetectionPattern);
this.uri = new Uri(Regex.Replace(realmUrl, WildcardDetectionPattern, m => m.Groups[1].Value));
if (!this.uri.Scheme.Equals("http", StringComparison.OrdinalIgnoreCase) &&
@@ -90,7 +90,7 @@ namespace DotNetOpenAuth.OpenId {
/// </summary>
/// <param name="realmUrl">The realm URL of the Relying Party.</param>
public Realm(Uri realmUrl) {
- Contract.Requires<ArgumentNullException>(realmUrl != null);
+ Requires.NotNull(realmUrl, "realmUrl");
this.uri = realmUrl;
if (!this.uri.Scheme.Equals("http", StringComparison.OrdinalIgnoreCase) &&
!this.uri.Scheme.Equals("https", StringComparison.OrdinalIgnoreCase)) {
@@ -123,7 +123,7 @@ namespace DotNetOpenAuth.OpenId {
/// </remarks>
public static Realm AutoDetect {
get {
- Contract.Requires<InvalidOperationException>(HttpContext.Current != null && HttpContext.Current.Request != null, MessagingStrings.HttpContextRequired);
+ Requires.ValidState(HttpContext.Current != null && HttpContext.Current.Request != null, MessagingStrings.HttpContextRequired);
Contract.Ensures(Contract.Result<Realm>() != null);
HttpRequestInfo requestInfo = new HttpRequestInfo(HttpContext.Current.Request);
@@ -489,7 +489,7 @@ namespace DotNetOpenAuth.OpenId {
/// when we should be throwing an <see cref="ArgumentNullException"/>.
/// </remarks>
private static string SafeUriBuilderToString(UriBuilder realmUriBuilder) {
- Contract.Requires<ArgumentNullException>(realmUriBuilder != null);
+ Requires.NotNull(realmUriBuilder, "realmUriBuilder");
// Note: we MUST use ToString. Uri property throws if wildcard is present.
// Note that Uri.ToString() should generally be avoided, but UriBuilder.ToString()
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/RelyingParty/IAuthenticationRequestContract.cs b/src/DotNetOpenAuth.OpenId/OpenId/RelyingParty/IAuthenticationRequestContract.cs
index cd36cc7..fa16c41 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/RelyingParty/IAuthenticationRequestContract.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/RelyingParty/IAuthenticationRequestContract.cs
@@ -73,26 +73,26 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
}
void IAuthenticationRequest.AddCallbackArguments(IDictionary<string, string> arguments) {
- Contract.Requires<ArgumentNullException>(arguments != null);
- Contract.Requires<ArgumentException>(arguments.Keys.All(k => !String.IsNullOrEmpty(k)));
- Contract.Requires<ArgumentException>(arguments.Values.All(v => v != null));
+ Requires.NotNull(arguments, "arguments");
+ Requires.True(arguments.Keys.All(k => !String.IsNullOrEmpty(k)), "arguments");
+ Requires.True(arguments.Values.All(v => v != null), "arguments");
throw new NotImplementedException();
}
void IAuthenticationRequest.AddCallbackArguments(string key, string value) {
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(key));
- Contract.Requires<ArgumentNullException>(value != null);
+ Requires.NotNullOrEmpty(key, "key");
+ Requires.NotNull(value, "value");
throw new NotImplementedException();
}
void IAuthenticationRequest.SetCallbackArgument(string key, string value) {
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(key));
- Contract.Requires<ArgumentNullException>(value != null);
+ Requires.NotNullOrEmpty(key, "key");
+ Requires.NotNull(value, "value");
throw new NotImplementedException();
}
void IAuthenticationRequest.AddExtension(IOpenIdMessageExtension extension) {
- Contract.Requires<ArgumentNullException>(extension != null);
+ Requires.NotNull(extension, "extension");
throw new NotImplementedException();
}
@@ -101,8 +101,8 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
}
void IAuthenticationRequest.SetUntrustedCallbackArgument(string key, string value) {
- Contract.Requires<ArgumentException>(!string.IsNullOrEmpty(key));
- Contract.Requires<ArgumentNullException>(value != null);
+ Requires.NotNullOrEmpty(key, "key");
+ Requires.NotNull(value, "value");
throw new NotImplementedException();
}
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/RelyingParty/IAuthenticationResponse.cs b/src/DotNetOpenAuth.OpenId/OpenId/RelyingParty/IAuthenticationResponse.cs
index a24220f..7b55f65 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/RelyingParty/IAuthenticationResponse.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/RelyingParty/IAuthenticationResponse.cs
@@ -367,7 +367,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// <para>Note that these values are NOT protected against tampering in transit.</para>
/// </remarks>
string IAuthenticationResponse.GetCallbackArgument(string key) {
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(key));
+ Requires.NotNullOrEmpty(key, "key");
throw new NotImplementedException();
}
@@ -432,8 +432,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// have not been tampered with since the Provider sent the message.</para>
/// </remarks>
IOpenIdMessageExtension IAuthenticationResponse.GetExtension(Type extensionType) {
- Contract.Requires<ArgumentNullException>(extensionType != null);
- Contract.Requires<ArgumentException>(typeof(IOpenIdMessageExtension).IsAssignableFrom(extensionType));
+ Requires.NotNullSubtype<IOpenIdMessageExtension>(extensionType, "extensionType");
////ErrorUtilities.VerifyArgument(typeof(IOpenIdMessageExtension).IsAssignableFrom(extensionType), string.Format(CultureInfo.CurrentCulture, OpenIdStrings.TypeMustImplementX, typeof(IOpenIdMessageExtension).FullName));
throw new NotImplementedException();
}
@@ -485,8 +484,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// have not been tampered with since the Provider sent the message.</para>
/// </remarks>
IOpenIdMessageExtension IAuthenticationResponse.GetUntrustedExtension(Type extensionType) {
- Contract.Requires<ArgumentNullException>(extensionType != null);
- Contract.Requires<ArgumentException>(typeof(IOpenIdMessageExtension).IsAssignableFrom(extensionType));
+ Requires.NotNullSubtype<IOpenIdMessageExtension>(extensionType, "extensionType");
////ErrorUtilities.VerifyArgument(typeof(IOpenIdMessageExtension).IsAssignableFrom(extensionType), string.Format(CultureInfo.CurrentCulture, OpenIdStrings.TypeMustImplementX, typeof(IOpenIdMessageExtension).FullName));
throw new NotImplementedException();
}
@@ -506,7 +504,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// used to make a security-sensitive decision.
/// </remarks>
string IAuthenticationResponse.GetUntrustedCallbackArgument(string key) {
- Contract.Requires<ArgumentException>(!string.IsNullOrEmpty(key));
+ Requires.NotNullOrEmpty(key, "key");
throw new NotImplementedException();
}
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/RelyingParty/IRelyingPartyBehavior.cs b/src/DotNetOpenAuth.OpenId/OpenId/RelyingParty/IRelyingPartyBehavior.cs
index 1bfa0db..28cad6d 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/RelyingParty/IRelyingPartyBehavior.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/RelyingParty/IRelyingPartyBehavior.cs
@@ -64,7 +64,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// incompatible with each other.
/// </remarks>
void IRelyingPartyBehavior.ApplySecuritySettings(RelyingPartySecuritySettings securitySettings) {
- Contract.Requires<ArgumentNullException>(securitySettings != null);
+ Requires.NotNull(securitySettings, "securitySettings");
}
/// <summary>
@@ -76,7 +76,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// without malfunctioning.
/// </remarks>
void IRelyingPartyBehavior.OnOutgoingAuthenticationRequest(IAuthenticationRequest request) {
- Contract.Requires<ArgumentNullException>(request != null);
+ Requires.NotNull(request, "request");
}
/// <summary>
@@ -84,7 +84,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// </summary>
/// <param name="assertion">The positive assertion.</param>
void IRelyingPartyBehavior.OnIncomingPositiveAssertion(IAuthenticationResponse assertion) {
- Contract.Requires<ArgumentNullException>(assertion != null);
+ Requires.NotNull(assertion, "assertion");
}
#endregion
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/RelyingPartyDescription.cs b/src/DotNetOpenAuth.OpenId/OpenId/RelyingPartyDescription.cs
index 7926e8f..ab0fd13 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/RelyingPartyDescription.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/RelyingPartyDescription.cs
@@ -28,8 +28,8 @@ namespace DotNetOpenAuth.OpenId {
/// The Type URIs of supported services advertised on a relying party's XRDS document.
/// </param>
internal RelyingPartyEndpointDescription(Uri returnTo, string[] supportedServiceTypeUris) {
- Contract.Requires<ArgumentNullException>(returnTo != null);
- Contract.Requires<ArgumentNullException>(supportedServiceTypeUris != null);
+ Requires.NotNull(returnTo, "returnTo");
+ Requires.NotNull(supportedServiceTypeUris, "supportedServiceTypeUris");
this.ReturnToEndpoint = returnTo;
this.Protocol = GetProtocolFromServices(supportedServiceTypeUris);
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/SecuritySettings.cs b/src/DotNetOpenAuth.OpenId/OpenId/SecuritySettings.cs
index 26f6d2a..a083cc6 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/SecuritySettings.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/SecuritySettings.cs
@@ -88,7 +88,7 @@ namespace DotNetOpenAuth.OpenId {
/// <c>true</c> if the association is permitted given the security requirements; otherwise, <c>false</c>.
/// </returns>
internal bool IsAssociationInPermittedRange(Association association) {
- Contract.Requires<ArgumentNullException>(association != null);
+ Requires.NotNull(association, "association");
return association.HashBitLength >= this.MinimumHashBitLength && association.HashBitLength <= this.MaximumHashBitLength;
}
}
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/UriIdentifier.cs b/src/DotNetOpenAuth.OpenId/OpenId/UriIdentifier.cs
index 3737135..aa72869 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/UriIdentifier.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/UriIdentifier.cs
@@ -99,7 +99,7 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="uri">The value this identifier will represent.</param>
internal UriIdentifier(string uri)
: this(uri, false) {
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(uri));
+ Requires.NotNullOrEmpty(uri, "uri");
}
/// <summary>
@@ -109,7 +109,7 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="requireSslDiscovery">if set to <c>true</c> [require SSL discovery].</param>
internal UriIdentifier(string uri, bool requireSslDiscovery)
: base(uri, requireSslDiscovery) {
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(uri));
+ Requires.NotNullOrEmpty(uri, "uri");
Uri canonicalUri;
bool schemePrepended;
if (!TryCanonicalize(uri, out canonicalUri, requireSslDiscovery, out schemePrepended)) {
@@ -137,7 +137,7 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="requireSslDiscovery">if set to <c>true</c> [require SSL discovery].</param>
internal UriIdentifier(Uri uri, bool requireSslDiscovery)
: base(uri != null ? uri.OriginalString : null, requireSslDiscovery) {
- Contract.Requires<ArgumentNullException>(uri != null);
+ Requires.NotNull(uri, "uri");
string uriAsString = uri.OriginalString;
if (schemeSubstitution) {
@@ -422,7 +422,7 @@ namespace DotNetOpenAuth.OpenId {
/// require network access are also done, such as lower-casing the hostname in the URI.
/// </remarks>
private static bool TryCanonicalize(string uri, out Uri canonicalUri, bool forceHttpsDefaultScheme, out bool schemePrepended) {
- Contract.Requires<ArgumentException>(!string.IsNullOrEmpty(uri));
+ Requires.NotNullOrEmpty(uri, "uri");
canonicalUri = null;
try {
@@ -454,7 +454,7 @@ namespace DotNetOpenAuth.OpenId {
/// </remarks>
[SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", Justification = "The user will see the result of this operation and they want to see it in lower case.")]
private static bool TryCanonicalize(string uri, out Uri canonicalUri) {
- Contract.Requires<ArgumentNullException>(uri != null);
+ Requires.NotNull(uri, "uri");
if (schemeSubstitution) {
UriBuilder uriBuilder = new UriBuilder(uri);
@@ -475,7 +475,7 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="normal">The ordinary URL or scheme name.</param>
/// <returns>The non-compressing equivalent scheme or URL for the given value.</returns>
private static string NormalSchemeToSpecialRoundTrippingScheme(string normal) {
- Contract.Requires<ArgumentException>(!string.IsNullOrEmpty(normal));
+ Requires.NotNullOrEmpty(normal, "normal");
Contract.Ensures(!string.IsNullOrEmpty(Contract.Result<string>()));
ErrorUtilities.VerifyInternal(schemeSubstitution, "Wrong schemeSubstitution value.");
@@ -503,7 +503,7 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="schemePrepended">if set to <c>true</c>, the scheme was prepended during normalization.</param>
/// <returns>The somewhat normalized URL.</returns>
private static string DoSimpleCanonicalize(string uri, bool forceHttpsDefaultScheme, out bool schemePrepended) {
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(uri));
+ Requires.NotNullOrEmpty(uri, "uri");
schemePrepended = false;
uri = uri.Trim();
@@ -546,7 +546,7 @@ namespace DotNetOpenAuth.OpenId {
/// </summary>
/// <param name="value">The value.</param>
internal SimpleUri(string value) {
- Contract.Requires<ArgumentException>(!string.IsNullOrEmpty(value));
+ Requires.NotNullOrEmpty(value, "value");
bool schemePrepended;
value = DoSimpleCanonicalize(value, false, out schemePrepended);
@@ -664,7 +664,7 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="path">The path to normalize.</param>
/// <returns>The given path, with exactly those characters escaped which should be.</returns>
private static string NormalizePathEscaping(string path) {
- Contract.Requires<ArgumentNullException>(path != null);
+ Requires.NotNull(path, "path");
string[] segments = path.Split('/');
for (int i = 0; i < segments.Length; i++) {
@@ -695,7 +695,7 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="standardScheme">The standard scheme that this parser will be subverting.</param>
public NonPathCompressingUriParser(string standardScheme)
: base(GenericUriParserOptions.DontCompressPath | GenericUriParserOptions.IriParsing | GenericUriParserOptions.Idn) {
- Contract.Requires<ArgumentException>(!string.IsNullOrEmpty(standardScheme));
+ Requires.NotNullOrEmpty(standardScheme, "standardScheme");
this.standardScheme = standardScheme;
}
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/XriDiscoveryProxyService.cs b/src/DotNetOpenAuth.OpenId/OpenId/XriDiscoveryProxyService.cs
index d80c59e..52bb92e 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/XriDiscoveryProxyService.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/XriDiscoveryProxyService.cs
@@ -72,8 +72,8 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="requestHandler">The request handler.</param>
/// <returns>The XRDS document.</returns>
private static XrdsDocument DownloadXrds(XriIdentifier identifier, IDirectWebRequestHandler requestHandler) {
- Contract.Requires<ArgumentNullException>(identifier != null);
- Contract.Requires<ArgumentNullException>(requestHandler != null);
+ Requires.NotNull(identifier, "identifier");
+ Requires.NotNull(requestHandler, "requestHandler");
Contract.Ensures(Contract.Result<XrdsDocument>() != null);
XrdsDocument doc;
using (var xrdsResponse = Yadis.Request(requestHandler, GetXrdsUrl(identifier), identifier.IsDiscoverySecureEndToEnd)) {
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/XriIdentifier.cs b/src/DotNetOpenAuth.OpenId/OpenId/XriIdentifier.cs
index b31d577..28460f1 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/XriIdentifier.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/XriIdentifier.cs
@@ -44,8 +44,8 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="xri">The string value of the XRI.</param>
internal XriIdentifier(string xri)
: this(xri, false) {
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(xri));
- Contract.Requires<FormatException>(IsValidXri(xri), OpenIdStrings.InvalidXri);
+ Requires.NotNullOrEmpty(xri, "xri");
+ Requires.Format(IsValidXri(xri), OpenIdStrings.InvalidXri);
}
/// <summary>
@@ -58,8 +58,8 @@ namespace DotNetOpenAuth.OpenId {
/// </param>
internal XriIdentifier(string xri, bool requireSsl)
: base(xri, requireSsl) {
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(xri));
- Contract.Requires<FormatException>(IsValidXri(xri), OpenIdStrings.InvalidXri);
+ Requires.NotNullOrEmpty(xri, "xri");
+ Requires.Format(IsValidXri(xri), OpenIdStrings.InvalidXri);
Contract.Assume(xri != null); // Proven by IsValidXri
this.OriginalXri = xri;
this.canonicalXri = CanonicalizeXri(xri);
@@ -131,7 +131,7 @@ namespace DotNetOpenAuth.OpenId {
/// <c>true</c> if the given string constitutes a valid XRI; otherwise, <c>false</c>.
/// </returns>
internal static bool IsValidXri(string xri) {
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(xri));
+ Requires.NotNullOrEmpty(xri, "xri");
xri = xri.Trim();
// TODO: better validation code here
@@ -182,7 +182,7 @@ namespace DotNetOpenAuth.OpenId {
/// <returns>The canonicalized form of the XRI.</returns>
/// <remarks>The canonical form, per the OpenID spec, is no scheme and no whitespace on either end.</remarks>
private static string CanonicalizeXri(string xri) {
- Contract.Requires<ArgumentNullException>(xri != null);
+ Requires.NotNull(xri, "xri");
Contract.Ensures(Contract.Result<string>() != null);
xri = xri.Trim();
if (xri.StartsWith(XriScheme, StringComparison.OrdinalIgnoreCase)) {