summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Core
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOpenAuth.Core')
-rw-r--r--src/DotNetOpenAuth.Core/Configuration/DotNetOpenAuthSection.cs2
-rw-r--r--src/DotNetOpenAuth.Core/Configuration/HostNameElement.cs2
-rw-r--r--src/DotNetOpenAuth.Core/Configuration/HostNameOrRegexCollection.cs2
-rw-r--r--src/DotNetOpenAuth.Core/Configuration/MessagingElement.cs3
-rw-r--r--src/DotNetOpenAuth.Core/Configuration/ReportingElement.cs2
-rw-r--r--src/DotNetOpenAuth.Core/Configuration/TrustedProviderConfigurationCollection.cs1
-rw-r--r--src/DotNetOpenAuth.Core/Configuration/TypeConfigurationCollection.cs3
-rw-r--r--src/DotNetOpenAuth.Core/Configuration/TypeConfigurationElement.cs6
-rw-r--r--src/DotNetOpenAuth.Core/Configuration/UntrustedWebRequestElement.cs1
-rw-r--r--src/DotNetOpenAuth.Core/DotNetOpenAuth.Core.csproj5
-rw-r--r--src/DotNetOpenAuth.Core/Logger.cs1
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/BinaryDataBagFormatter.cs1
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/Bindings/AsymmetricCryptoKeyStoreWrapper.cs11
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/Bindings/CryptoKey.cs3
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/Bindings/ExpiredMessageException.cs1
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/Bindings/ICryptoKeyStore.cs60
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/Bindings/StandardReplayProtectionBindingElement.cs1
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/CachedDirectWebResponse.cs7
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/Channel.cs33
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/ChannelContract.cs55
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/ChannelEventArgs.cs1
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/DataBag.cs1
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/DataBagFormatterBase.cs2
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/EnumerableCacheExtensions.cs1
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/ErrorUtilities.cs57
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/HttpRequestInfo.cs1
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/IChannelBindingElement.cs82
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/IDataBagFormatter.cs48
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/IDirectWebRequestHandler.cs119
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/IHttpDirectRequest.cs2
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/IHttpDirectRequestContract.cs75
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/IHttpDirectResponse.cs2
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/IHttpDirectResponseContract.cs43
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/IHttpIndirectResponse.cs1
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/IMessage.cs53
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/IMessageFactory.cs51
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/IMessageOriginalPayload.cs16
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/IMessageWithBinaryData.cs127
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/IProtocolMessageWithExtensions.cs93
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/IStreamSerializingDataBag.cs1
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/IncomingWebResponse.cs3
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/IncomingWebResponseContract.cs55
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/KeyedCollectionDelegate.cs1
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/MessageReceivingEndpoint.cs1
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/MessageSerializer.cs11
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs13
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/MultipartPostPart.cs1
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/NetworkDirectWebResponse.cs2
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/OutgoingWebResponse.cs1
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/OutgoingWebResponseActionResult.cs1
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/ProtocolException.cs1
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/Reflection/IMessagePartEncoder.cs43
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/Reflection/MessageDescription.cs2
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/Reflection/MessageDescriptionCollection.cs6
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/Reflection/MessageDictionary.cs4
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/Reflection/MessagePart.cs13
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/Reflection/ValueMapping.cs2
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/StandardMessageFactory.cs4
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/StandardMessageFactoryChannel.cs2
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/UriStyleMessageFormatter.cs1
-rw-r--r--src/DotNetOpenAuth.Core/Properties/AssemblyInfo.cs3
-rw-r--r--src/DotNetOpenAuth.Core/PureAttribute.cs22
-rw-r--r--src/DotNetOpenAuth.Core/Reporting.cs4
-rw-r--r--src/DotNetOpenAuth.Core/RequiresEx.cs25
-rw-r--r--src/DotNetOpenAuth.Core/UriUtil.cs16
-rw-r--r--src/DotNetOpenAuth.Core/Util.cs5
66 files changed, 62 insertions, 1156 deletions
diff --git a/src/DotNetOpenAuth.Core/Configuration/DotNetOpenAuthSection.cs b/src/DotNetOpenAuth.Core/Configuration/DotNetOpenAuthSection.cs
index 7c03c48..cdcd670 100644
--- a/src/DotNetOpenAuth.Core/Configuration/DotNetOpenAuthSection.cs
+++ b/src/DotNetOpenAuth.Core/Configuration/DotNetOpenAuthSection.cs
@@ -7,7 +7,6 @@
namespace DotNetOpenAuth.Configuration {
using System;
using System.Configuration;
- using System.Diagnostics.Contracts;
using System.Web;
using System.Web.Configuration;
@@ -15,7 +14,6 @@ namespace DotNetOpenAuth.Configuration {
/// Represents the section in the host's .config file that configures
/// this library's settings.
/// </summary>
- [ContractVerification(true)]
public class DotNetOpenAuthSection : ConfigurationSectionGroup {
/// <summary>
/// The name of the section under which this library's settings must be found.
diff --git a/src/DotNetOpenAuth.Core/Configuration/HostNameElement.cs b/src/DotNetOpenAuth.Core/Configuration/HostNameElement.cs
index b46ece9..5386314 100644
--- a/src/DotNetOpenAuth.Core/Configuration/HostNameElement.cs
+++ b/src/DotNetOpenAuth.Core/Configuration/HostNameElement.cs
@@ -6,12 +6,10 @@
namespace DotNetOpenAuth.Configuration {
using System.Configuration;
- using System.Diagnostics.Contracts;
/// <summary>
/// Represents the name of a single host or a regex pattern for host names.
/// </summary>
- [ContractVerification(true)]
internal class HostNameElement : ConfigurationElement {
/// <summary>
/// Gets the name of the @name attribute.
diff --git a/src/DotNetOpenAuth.Core/Configuration/HostNameOrRegexCollection.cs b/src/DotNetOpenAuth.Core/Configuration/HostNameOrRegexCollection.cs
index 27ba80e..8f537c3 100644
--- a/src/DotNetOpenAuth.Core/Configuration/HostNameOrRegexCollection.cs
+++ b/src/DotNetOpenAuth.Core/Configuration/HostNameOrRegexCollection.cs
@@ -7,14 +7,12 @@
namespace DotNetOpenAuth.Configuration {
using System.Collections.Generic;
using System.Configuration;
- using System.Diagnostics.Contracts;
using System.Text.RegularExpressions;
using Validation;
/// <summary>
/// Represents a collection of child elements that describe host names either as literal host names or regex patterns.
/// </summary>
- [ContractVerification(true)]
internal class HostNameOrRegexCollection : ConfigurationElementCollection {
/// <summary>
/// Initializes a new instance of the <see cref="HostNameOrRegexCollection"/> class.
diff --git a/src/DotNetOpenAuth.Core/Configuration/MessagingElement.cs b/src/DotNetOpenAuth.Core/Configuration/MessagingElement.cs
index ff98d36..64dfba3 100644
--- a/src/DotNetOpenAuth.Core/Configuration/MessagingElement.cs
+++ b/src/DotNetOpenAuth.Core/Configuration/MessagingElement.cs
@@ -7,14 +7,12 @@
namespace DotNetOpenAuth.Configuration {
using System;
using System.Configuration;
- using System.Diagnostics.Contracts;
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.Messaging.Bindings;
/// <summary>
/// Represents the &lt;messaging&gt; element in the host's .config file.
/// </summary>
- [ContractVerification(true)]
public class MessagingElement : ConfigurationSection {
/// <summary>
/// The name of the &lt;webResourceUrlProvider&gt; sub-element.
@@ -75,7 +73,6 @@ namespace DotNetOpenAuth.Configuration {
/// </summary>
public static MessagingElement Configuration {
get {
- Contract.Ensures(Contract.Result<MessagingElement>() != null);
return (MessagingElement)ConfigurationManager.GetSection(MessagingElementName) ?? new MessagingElement();
}
}
diff --git a/src/DotNetOpenAuth.Core/Configuration/ReportingElement.cs b/src/DotNetOpenAuth.Core/Configuration/ReportingElement.cs
index 0af8205..f0184a6 100644
--- a/src/DotNetOpenAuth.Core/Configuration/ReportingElement.cs
+++ b/src/DotNetOpenAuth.Core/Configuration/ReportingElement.cs
@@ -8,7 +8,6 @@ namespace DotNetOpenAuth.Configuration {
using System;
using System.Collections.Generic;
using System.Configuration;
- using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
@@ -76,7 +75,6 @@ namespace DotNetOpenAuth.Configuration {
/// </summary>
public static ReportingElement Configuration {
get {
- Contract.Ensures(Contract.Result<ReportingElement>() != null);
return (ReportingElement)ConfigurationManager.GetSection(ReportingElementName) ?? new ReportingElement();
}
}
diff --git a/src/DotNetOpenAuth.Core/Configuration/TrustedProviderConfigurationCollection.cs b/src/DotNetOpenAuth.Core/Configuration/TrustedProviderConfigurationCollection.cs
index 3f19d8c..de70f64 100644
--- a/src/DotNetOpenAuth.Core/Configuration/TrustedProviderConfigurationCollection.cs
+++ b/src/DotNetOpenAuth.Core/Configuration/TrustedProviderConfigurationCollection.cs
@@ -9,7 +9,6 @@ namespace DotNetOpenAuth.Configuration {
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics.CodeAnalysis;
- using System.Diagnostics.Contracts;
using Validation;
/// <summary>
diff --git a/src/DotNetOpenAuth.Core/Configuration/TypeConfigurationCollection.cs b/src/DotNetOpenAuth.Core/Configuration/TypeConfigurationCollection.cs
index 274622e..08bd2a1 100644
--- a/src/DotNetOpenAuth.Core/Configuration/TypeConfigurationCollection.cs
+++ b/src/DotNetOpenAuth.Core/Configuration/TypeConfigurationCollection.cs
@@ -8,7 +8,6 @@ namespace DotNetOpenAuth.Configuration {
using System;
using System.Collections.Generic;
using System.Configuration;
- using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using DotNetOpenAuth.Messaging;
@@ -18,7 +17,6 @@ namespace DotNetOpenAuth.Configuration {
/// A collection of <see cref="TypeConfigurationElement&lt;T&gt;"/>.
/// </summary>
/// <typeparam name="T">The type that all types specified in the elements must derive from.</typeparam>
- [ContractVerification(true)]
internal class TypeConfigurationCollection<T> : ConfigurationElementCollection
where T : class {
/// <summary>
@@ -45,7 +43,6 @@ namespace DotNetOpenAuth.Configuration {
/// <param name="allowInternals">if set to <c>true</c> then internal types may be instantiated.</param>
/// <returns>A sequence of instances generated from types in this collection. May be empty, but never null.</returns>
internal IEnumerable<T> CreateInstances(bool allowInternals) {
- Contract.Ensures(Contract.Result<IEnumerable<T>>() != null);
return from element in this.Cast<TypeConfigurationElement<T>>()
where !element.IsEmpty
select element.CreateInstance(default(T), allowInternals);
diff --git a/src/DotNetOpenAuth.Core/Configuration/TypeConfigurationElement.cs b/src/DotNetOpenAuth.Core/Configuration/TypeConfigurationElement.cs
index edbb614..a3a8140 100644
--- a/src/DotNetOpenAuth.Core/Configuration/TypeConfigurationElement.cs
+++ b/src/DotNetOpenAuth.Core/Configuration/TypeConfigurationElement.cs
@@ -8,7 +8,6 @@ namespace DotNetOpenAuth.Configuration {
using System;
using System.Configuration;
using System.Diagnostics.CodeAnalysis;
- using System.Diagnostics.Contracts;
using System.IO;
using System.Reflection;
using System.Web;
@@ -82,8 +81,6 @@ namespace DotNetOpenAuth.Configuration {
/// <param name="defaultValue">The value to return if no type is given in the .config file.</param>
/// <returns>The newly instantiated type.</returns>
public T CreateInstance(T defaultValue) {
- Contract.Ensures(Contract.Result<T>() != null || Contract.Result<T>() == defaultValue);
-
return this.CreateInstance(defaultValue, false);
}
@@ -95,8 +92,6 @@ namespace DotNetOpenAuth.Configuration {
/// <returns>The newly instantiated type.</returns>
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "No apparent problem. False positive?")]
public T CreateInstance(T defaultValue, bool allowInternals) {
- Contract.Ensures(Contract.Result<T>() != null || Contract.Result<T>() == defaultValue);
-
if (this.CustomType != null) {
if (!allowInternals) {
// Although .NET will usually prevent our instantiating non-public types,
@@ -132,7 +127,6 @@ namespace DotNetOpenAuth.Configuration {
/// be present.
/// </remarks>
private static T CreateInstanceFromXaml(Stream xaml) {
- Contract.Ensures(Contract.Result<T>() != null);
#if CLR4
return (T)XamlServices.Load(xaml);
#else
diff --git a/src/DotNetOpenAuth.Core/Configuration/UntrustedWebRequestElement.cs b/src/DotNetOpenAuth.Core/Configuration/UntrustedWebRequestElement.cs
index b49452a..a16522a 100644
--- a/src/DotNetOpenAuth.Core/Configuration/UntrustedWebRequestElement.cs
+++ b/src/DotNetOpenAuth.Core/Configuration/UntrustedWebRequestElement.cs
@@ -7,7 +7,6 @@
namespace DotNetOpenAuth.Configuration {
using System;
using System.Configuration;
- using System.Diagnostics.Contracts;
/// <summary>
/// Represents the section of a .config file where security policies regarding web requests
diff --git a/src/DotNetOpenAuth.Core/DotNetOpenAuth.Core.csproj b/src/DotNetOpenAuth.Core/DotNetOpenAuth.Core.csproj
index 12952f1..71965ed 100644
--- a/src/DotNetOpenAuth.Core/DotNetOpenAuth.Core.csproj
+++ b/src/DotNetOpenAuth.Core/DotNetOpenAuth.Core.csproj
@@ -27,12 +27,10 @@
<Compile Include="Messaging\Bindings\MemoryCryptoKeyStore.cs" />
<Compile Include="Messaging\BinaryDataBagFormatter.cs" />
<Compile Include="Messaging\CachedDirectWebResponse.cs" />
- <Compile Include="Messaging\ChannelContract.cs" />
<Compile Include="Messaging\DataBagFormatterBase.cs" />
<Compile Include="Messaging\HmacAlgorithms.cs" />
<Compile Include="Messaging\HttpRequestHeaders.cs" />
<Compile Include="Messaging\IHttpDirectRequest.cs" />
- <Compile Include="Messaging\IHttpDirectRequestContract.cs" />
<Compile Include="Messaging\IHttpIndirectResponse.cs" />
<Compile Include="Messaging\IMessageOriginalPayload.cs" />
<Compile Include="Messaging\DirectWebRequestOptions.cs" />
@@ -40,7 +38,6 @@
<Compile Include="Messaging\HostErrorException.cs" />
<Compile Include="Messaging\IHttpDirectResponse.cs" />
<Compile Include="Messaging\IExtensionMessage.cs" />
- <Compile Include="Messaging\IHttpDirectResponseContract.cs" />
<Compile Include="Messaging\IMessage.cs" />
<Compile Include="Messaging\IncomingWebResponse.cs" />
<Compile Include="Messaging\IDirectResponseProtocolMessage.cs" />
@@ -49,7 +46,6 @@
<Compile Include="Messaging\EmptyList.cs" />
<Compile Include="Messaging\ErrorUtilities.cs" />
<Compile Include="Messaging\IMessageWithEvents.cs" />
- <Compile Include="Messaging\IncomingWebResponseContract.cs" />
<Compile Include="Messaging\IProtocolMessageWithExtensions.cs" />
<Compile Include="Messaging\InternalErrorException.cs" />
<Compile Include="Messaging\IStreamSerializingDataBag.cs" />
@@ -137,6 +133,7 @@
<Compile Include="Loggers\TraceLogger.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Messaging\ReadOnlyDictionary.cs" />
+ <Compile Include="PureAttribute.cs" />
<Compile Include="Reporting.cs" />
<Compile Include="RequiresEx.cs" />
<Compile Include="Strings.Designer.cs">
diff --git a/src/DotNetOpenAuth.Core/Logger.cs b/src/DotNetOpenAuth.Core/Logger.cs
index 512c237..cf9343b 100644
--- a/src/DotNetOpenAuth.Core/Logger.cs
+++ b/src/DotNetOpenAuth.Core/Logger.cs
@@ -6,7 +6,6 @@
namespace DotNetOpenAuth {
using System;
- using System.Diagnostics.Contracts;
using System.Globalization;
using DotNetOpenAuth.Loggers;
using DotNetOpenAuth.Messaging;
diff --git a/src/DotNetOpenAuth.Core/Messaging/BinaryDataBagFormatter.cs b/src/DotNetOpenAuth.Core/Messaging/BinaryDataBagFormatter.cs
index b50d249..554205a 100644
--- a/src/DotNetOpenAuth.Core/Messaging/BinaryDataBagFormatter.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/BinaryDataBagFormatter.cs
@@ -8,7 +8,6 @@ namespace DotNetOpenAuth.Messaging {
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
- using System.Diagnostics.Contracts;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
diff --git a/src/DotNetOpenAuth.Core/Messaging/Bindings/AsymmetricCryptoKeyStoreWrapper.cs b/src/DotNetOpenAuth.Core/Messaging/Bindings/AsymmetricCryptoKeyStoreWrapper.cs
index edf62c4..0439908 100644
--- a/src/DotNetOpenAuth.Core/Messaging/Bindings/AsymmetricCryptoKeyStoreWrapper.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/Bindings/AsymmetricCryptoKeyStoreWrapper.cs
@@ -8,7 +8,6 @@ namespace DotNetOpenAuth.Messaging.Bindings {
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
- using System.Diagnostics.Contracts;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
@@ -150,16 +149,6 @@ namespace DotNetOpenAuth.Messaging.Bindings {
/// Gets the encrypted key.
/// </summary>
internal byte[] EncryptedKey { get; private set; }
-
- /// <summary>
- /// Invariant conditions.
- /// </summary>
- [ContractInvariantMethod]
- [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Code contracts")]
- [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = "Required for code contracts.")]
- private void ObjectInvariant() {
- Contract.Invariant(this.EncryptedKey != null);
- }
}
}
}
diff --git a/src/DotNetOpenAuth.Core/Messaging/Bindings/CryptoKey.cs b/src/DotNetOpenAuth.Core/Messaging/Bindings/CryptoKey.cs
index b4a5129..d6fef62 100644
--- a/src/DotNetOpenAuth.Core/Messaging/Bindings/CryptoKey.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/Bindings/CryptoKey.cs
@@ -8,7 +8,6 @@ namespace DotNetOpenAuth.Messaging.Bindings {
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
- using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using DotNetOpenAuth.Messaging;
@@ -46,7 +45,6 @@ namespace DotNetOpenAuth.Messaging.Bindings {
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "It's a buffer")]
public byte[] Key {
get {
- Contract.Ensures(Contract.Result<byte[]>() != null);
return this.key;
}
}
@@ -56,7 +54,6 @@ namespace DotNetOpenAuth.Messaging.Bindings {
/// </summary>
public DateTime ExpiresUtc {
get {
- Contract.Ensures(Contract.Result<DateTime>().Kind == DateTimeKind.Utc);
return this.expiresUtc;
}
}
diff --git a/src/DotNetOpenAuth.Core/Messaging/Bindings/ExpiredMessageException.cs b/src/DotNetOpenAuth.Core/Messaging/Bindings/ExpiredMessageException.cs
index 6e6d3bc..8c5db3c 100644
--- a/src/DotNetOpenAuth.Core/Messaging/Bindings/ExpiredMessageException.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/Bindings/ExpiredMessageException.cs
@@ -6,7 +6,6 @@
namespace DotNetOpenAuth.Messaging.Bindings {
using System;
- using System.Diagnostics.Contracts;
using System.Globalization;
using Validation;
diff --git a/src/DotNetOpenAuth.Core/Messaging/Bindings/ICryptoKeyStore.cs b/src/DotNetOpenAuth.Core/Messaging/Bindings/ICryptoKeyStore.cs
index 7493b19..ce7bf42 100644
--- a/src/DotNetOpenAuth.Core/Messaging/Bindings/ICryptoKeyStore.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/Bindings/ICryptoKeyStore.cs
@@ -8,7 +8,6 @@ namespace DotNetOpenAuth.Messaging.Bindings {
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
- using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using DotNetOpenAuth.Messaging;
@@ -24,7 +23,6 @@ namespace DotNetOpenAuth.Messaging.Bindings {
/// of the confidentiality of the keys. One possible mitigation is to asymmetrically encrypt
/// each key using a certificate installed in the server's certificate store.
/// </remarks>
- [ContractClass(typeof(ICryptoKeyStoreContract))]
public interface ICryptoKeyStore {
/// <summary>
/// Gets the key in a given bucket and handle.
@@ -58,62 +56,4 @@ namespace DotNetOpenAuth.Messaging.Bindings {
/// <param name="handle">The key handle. Case sensitive.</param>
void RemoveKey(string bucket, string handle);
}
-
- /// <summary>
- /// Code contract for the <see cref="ICryptoKeyStore"/> interface.
- /// </summary>
- [ContractClassFor(typeof(ICryptoKeyStore))]
- internal abstract class ICryptoKeyStoreContract : ICryptoKeyStore {
- /// <summary>
- /// Gets the key in a given bucket and handle.
- /// </summary>
- /// <param name="bucket">The bucket name. Case sensitive.</param>
- /// <param name="handle">The key handle. Case sensitive.</param>
- /// <returns>
- /// The cryptographic key, or <c>null</c> if no matching key was found.
- /// </returns>
- CryptoKey ICryptoKeyStore.GetKey(string bucket, string handle) {
- Requires.NotNullOrEmpty(bucket, "bucket");
- Requires.NotNullOrEmpty(handle, "handle");
- throw new NotImplementedException();
- }
-
- /// <summary>
- /// Gets a sequence of existing keys within a given bucket.
- /// </summary>
- /// <param name="bucket">The bucket name. Case sensitive.</param>
- /// <returns>
- /// A sequence of handles and keys, ordered by descending <see cref="CryptoKey.ExpiresUtc"/>.
- /// </returns>
- IEnumerable<KeyValuePair<string, CryptoKey>> ICryptoKeyStore.GetKeys(string bucket) {
- Requires.NotNullOrEmpty(bucket, "bucket");
- Contract.Ensures(Contract.Result<IEnumerable<KeyValuePair<string, CryptoKey>>>() != null);
- throw new NotImplementedException();
- }
-
- /// <summary>
- /// Stores a cryptographic key.
- /// </summary>
- /// <param name="bucket">The name of the bucket to store the key in. Case sensitive.</param>
- /// <param name="handle">The handle to the key, unique within the bucket. Case sensitive.</param>
- /// <param name="key">The key to store.</param>
- /// <exception cref="CryptoKeyCollisionException">Thrown in the event of a conflict with an existing key in the same bucket and with the same handle.</exception>
- void ICryptoKeyStore.StoreKey(string bucket, string handle, CryptoKey key) {
- Requires.NotNullOrEmpty(bucket, "bucket");
- Requires.NotNullOrEmpty(handle, "handle");
- Requires.NotNull(key, "key");
- throw new NotImplementedException();
- }
-
- /// <summary>
- /// Removes the key.
- /// </summary>
- /// <param name="bucket">The bucket name. Case sensitive.</param>
- /// <param name="handle">The key handle. Case sensitive.</param>
- void ICryptoKeyStore.RemoveKey(string bucket, string handle) {
- Requires.NotNullOrEmpty(bucket, "bucket");
- Requires.NotNullOrEmpty(handle, "handle");
- throw new NotImplementedException();
- }
- }
}
diff --git a/src/DotNetOpenAuth.Core/Messaging/Bindings/StandardReplayProtectionBindingElement.cs b/src/DotNetOpenAuth.Core/Messaging/Bindings/StandardReplayProtectionBindingElement.cs
index 8c2afec..45bccdf 100644
--- a/src/DotNetOpenAuth.Core/Messaging/Bindings/StandardReplayProtectionBindingElement.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/Bindings/StandardReplayProtectionBindingElement.cs
@@ -7,7 +7,6 @@
namespace DotNetOpenAuth.Messaging.Bindings {
using System;
using System.Diagnostics;
- using System.Diagnostics.Contracts;
using Validation;
/// <summary>
diff --git a/src/DotNetOpenAuth.Core/Messaging/CachedDirectWebResponse.cs b/src/DotNetOpenAuth.Core/Messaging/CachedDirectWebResponse.cs
index 322586a..20b1831 100644
--- a/src/DotNetOpenAuth.Core/Messaging/CachedDirectWebResponse.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/CachedDirectWebResponse.cs
@@ -8,7 +8,6 @@ namespace DotNetOpenAuth.Messaging {
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
- using System.Diagnostics.Contracts;
using System.IO;
using System.Net;
using System.Text;
@@ -17,7 +16,6 @@ namespace DotNetOpenAuth.Messaging {
/// <summary>
/// Cached details on the response from a direct web request to a remote party.
/// </summary>
- [ContractVerification(true)]
[DebuggerDisplay("{Status} {ContentType.MediaType}, length: {ResponseStream.Length}")]
internal class CachedDirectWebResponse : IncomingWebResponse {
/// <summary>
@@ -161,14 +159,13 @@ namespace DotNetOpenAuth.Messaging {
[SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "System.Diagnostics.Contracts.__ContractsRuntime.Assume(System.Boolean,System.String,System.String)", Justification = "No localization required.")]
private static MemoryStream CacheNetworkStreamAndClose(HttpWebResponse response, int maximumBytesToRead) {
Requires.NotNull(response, "response");
- Contract.Ensures(Contract.Result<MemoryStream>() != null);
// Now read and cache the network stream
Stream networkStream = response.GetResponseStream();
MemoryStream cachedStream = new MemoryStream(response.ContentLength < 0 ? 4 * 1024 : Math.Min((int)response.ContentLength, maximumBytesToRead));
try {
- Contract.Assume(networkStream.CanRead, "HttpWebResponse.GetResponseStream() always returns a readable stream."); // CC missing
- Contract.Assume(cachedStream.CanWrite, "This is a MemoryStream -- it's always writable."); // CC missing
+ Assumes.True(networkStream.CanRead, "HttpWebResponse.GetResponseStream() always returns a readable stream."); // CC missing
+ Assumes.True(cachedStream.CanWrite, "This is a MemoryStream -- it's always writable."); // CC missing
networkStream.CopyTo(cachedStream);
cachedStream.Seek(0, SeekOrigin.Begin);
diff --git a/src/DotNetOpenAuth.Core/Messaging/Channel.cs b/src/DotNetOpenAuth.Core/Messaging/Channel.cs
index 09a203e..9c2ba8c 100644
--- a/src/DotNetOpenAuth.Core/Messaging/Channel.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/Channel.cs
@@ -30,8 +30,6 @@ namespace DotNetOpenAuth.Messaging {
/// Manages sending direct messages to a remote party and receiving responses.
/// </summary>
[SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling", Justification = "Unavoidable.")]
- [ContractVerification(true)]
- [ContractClass(typeof(ChannelContract))]
public abstract class Channel : IDisposable {
/// <summary>
/// The encoding to use when writing out POST entity strings.
@@ -234,9 +232,8 @@ namespace DotNetOpenAuth.Messaging {
/// </summary>
protected internal ReadOnlyCollection<IChannelBindingElement> BindingElements {
get {
- Contract.Ensures(Contract.Result<ReadOnlyCollection<IChannelBindingElement>>() != null);
var result = this.outgoingBindingElements.AsReadOnly();
- Contract.Assume(result != null); // should be an implicit BCL contract
+ Assumes.True(result != null); // should be an implicit BCL contract
return result;
}
}
@@ -253,8 +250,6 @@ namespace DotNetOpenAuth.Messaging {
/// </summary>
protected internal ReadOnlyCollection<IChannelBindingElement> IncomingBindingElements {
get {
- Contract.Ensures(Contract.Result<ReadOnlyCollection<IChannelBindingElement>>().All(be => be.Channel != null));
- Contract.Ensures(Contract.Result<ReadOnlyCollection<IChannelBindingElement>>().All(be => be != null));
return this.incomingBindingElements.AsReadOnly();
}
}
@@ -341,7 +336,6 @@ namespace DotNetOpenAuth.Messaging {
/// <returns>The pending user agent redirect based message to be sent as an HttpResponse.</returns>
public OutgoingWebResponse PrepareResponse(IProtocolMessage message) {
Requires.NotNull(message, "message");
- Contract.Ensures(Contract.Result<OutgoingWebResponse>() != null);
this.ProcessOutgoingMessage(message);
Logger.Channel.DebugFormat("Sending message: {0}", message.GetType().Name);
@@ -421,7 +415,6 @@ namespace DotNetOpenAuth.Messaging {
public bool TryReadFromRequest<TRequest>(HttpRequestBase httpRequest, out TRequest request)
where TRequest : class, IProtocolMessage {
Requires.NotNull(httpRequest, "httpRequest");
- Contract.Ensures(Contract.Result<bool>() == (Contract.ValueAtReturn<TRequest>(out request) != null));
IProtocolMessage untypedRequest = this.ReadFromRequest(httpRequest);
if (untypedRequest == null) {
@@ -512,7 +505,6 @@ namespace DotNetOpenAuth.Messaging {
public TResponse Request<TResponse>(IDirectedProtocolMessage requestMessage)
where TResponse : class, IProtocolMessage {
Requires.NotNull(requestMessage, "requestMessage");
- Contract.Ensures(Contract.Result<TResponse>() != null);
IProtocolMessage response = this.Request(requestMessage);
ErrorUtilities.VerifyProtocol(response != null, MessagingStrings.ExpectedMessageNotReceived, typeof(TResponse));
@@ -636,10 +628,9 @@ namespace DotNetOpenAuth.Messaging {
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Costly call should not be a property.")]
protected internal virtual HttpRequestBase GetRequestFromContext() {
RequiresEx.ValidState(HttpContext.Current != null && HttpContext.Current.Request != null, MessagingStrings.HttpContextRequired);
- Contract.Ensures(Contract.Result<HttpRequestBase>() != null);
- Contract.Assume(HttpContext.Current.Request.Url != null);
- Contract.Assume(HttpContext.Current.Request.RawUrl != null);
+ Assumes.True(HttpContext.Current.Request.Url != null);
+ Assumes.True(HttpContext.Current.Request.RawUrl != null);
return new HttpRequestWrapper(HttpContext.Current.Request);
}
@@ -786,7 +777,7 @@ namespace DotNetOpenAuth.Messaging {
Logger.Channel.DebugFormat("Incoming HTTP request: {0} {1}", request.HttpMethod, request.GetPublicFacingUrl().AbsoluteUri);
// Search Form data first, and if nothing is there search the QueryString
- Contract.Assume(request.Form != null && request.GetQueryStringBeforeRewriting() != null);
+ Assumes.True(request.Form != null && request.GetQueryStringBeforeRewriting() != null);
var fields = request.Form.ToDictionary();
if (fields.Count == 0 && request.HttpMethod != "POST") { // OpenID 2.0 section 4.1.2
fields = request.GetQueryStringBeforeRewriting().ToDictionary();
@@ -840,11 +831,10 @@ namespace DotNetOpenAuth.Messaging {
Requires.NotNull(message, "message");
Requires.That(message.Recipient != null, "message", MessagingStrings.DirectedMessageMissingRecipient);
Requires.That((message.HttpMethods & (HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.PostRequest)) != 0, "message", "GET or POST expected.");
- Contract.Ensures(Contract.Result<OutgoingWebResponse>() != null);
- Contract.Assert(message != null && message.Recipient != null);
+ Assumes.True(message != null && message.Recipient != null);
var messageAccessor = this.MessageDescriptions.GetAccessor(message);
- Contract.Assert(message != null && message.Recipient != null);
+ Assumes.True(message != null && message.Recipient != null);
var fields = messageAccessor.Serialize();
OutgoingWebResponse response = null;
@@ -890,7 +880,6 @@ namespace DotNetOpenAuth.Messaging {
Requires.NotNull(message, "message");
Requires.That(message.Recipient != null, "message", MessagingStrings.DirectedMessageMissingRecipient);
Requires.NotNull(fields, "fields");
- Contract.Ensures(Contract.Result<OutgoingWebResponse>() != null);
// As part of this redirect, we include an HTML body in order to get passed some proxy filters
// such as WebSense.
@@ -927,7 +916,6 @@ namespace DotNetOpenAuth.Messaging {
Requires.NotNull(message, "message");
Requires.That(message.Recipient != null, "message", MessagingStrings.DirectedMessageMissingRecipient);
Requires.NotNull(fields, "fields");
- Contract.Ensures(Contract.Result<OutgoingWebResponse>() != null);
WebHeaderCollection headers = new WebHeaderCollection();
headers.Add(HttpResponseHeader.ContentType, "text/html");
@@ -975,7 +963,6 @@ namespace DotNetOpenAuth.Messaging {
protected virtual HttpWebRequest CreateHttpRequest(IDirectedProtocolMessage request) {
Requires.NotNull(request, "request");
Requires.That(request.Recipient != null, "request", MessagingStrings.DirectedMessageMissingRecipient);
- Contract.Ensures(Contract.Result<HttpWebRequest>() != null);
throw new NotImplementedException();
}
@@ -1040,7 +1027,7 @@ namespace DotNetOpenAuth.Messaging {
MessageProtections appliedProtection = MessageProtections.None;
foreach (IChannelBindingElement bindingElement in this.outgoingBindingElements) {
- Contract.Assume(bindingElement.Channel != null);
+ Assumes.True(bindingElement.Channel != null);
MessageProtections? elementProtection = bindingElement.ProcessOutgoingMessage(message);
if (elementProtection.HasValue) {
Logger.Bindings.DebugFormat("Binding element {0} applied to message.", bindingElement.GetType().FullName);
@@ -1130,7 +1117,6 @@ namespace DotNetOpenAuth.Messaging {
/// </remarks>
protected virtual HttpWebRequest InitializeRequestAsPost(IDirectedProtocolMessage requestMessage) {
Requires.NotNull(requestMessage, "requestMessage");
- Contract.Ensures(Contract.Result<HttpWebRequest>() != null);
var messageAccessor = this.MessageDescriptions.GetAccessor(requestMessage);
var fields = messageAccessor.Serialize();
@@ -1165,7 +1151,6 @@ namespace DotNetOpenAuth.Messaging {
/// </remarks>
protected virtual HttpWebRequest InitializeRequestAsPut(IDirectedProtocolMessage requestMessage) {
Requires.NotNull(requestMessage, "requestMessage");
- Contract.Ensures(Contract.Result<HttpWebRequest>() != null);
HttpWebRequest request = this.InitializeRequestAsGet(requestMessage);
request.Method = "PUT";
@@ -1182,7 +1167,6 @@ namespace DotNetOpenAuth.Messaging {
/// </remarks>
protected virtual HttpWebRequest InitializeRequestAsDelete(IDirectedProtocolMessage requestMessage) {
Requires.NotNull(requestMessage, "requestMessage");
- Contract.Ensures(Contract.Result<HttpWebRequest>() != null);
HttpWebRequest request = this.InitializeRequestAsGet(requestMessage);
request.Method = "DELETE";
@@ -1255,7 +1239,7 @@ namespace DotNetOpenAuth.Messaging {
MessageProtections appliedProtection = MessageProtections.None;
foreach (IChannelBindingElement bindingElement in this.IncomingBindingElements) {
- Contract.Assume(bindingElement.Channel != null); // CC bug: this.IncomingBindingElements ensures this... why must we assume it here?
+ Assumes.True(bindingElement.Channel != null); // CC bug: this.IncomingBindingElements ensures this... why must we assume it here?
MessageProtections? elementProtection = bindingElement.ProcessIncomingMessage(message);
if (elementProtection.HasValue) {
Logger.Bindings.DebugFormat("Binding element {0} applied to message.", bindingElement.GetType().FullName);
@@ -1352,7 +1336,6 @@ namespace DotNetOpenAuth.Messaging {
/// <exception cref="ProtocolException">Thrown when the binding elements are incomplete or inconsistent with each other.</exception>
private static IEnumerable<IChannelBindingElement> ValidateAndPrepareBindingElements(IEnumerable<IChannelBindingElement> elements) {
Requires.NullOrNotNullElements(elements, "elements");
- Contract.Ensures(Contract.Result<IEnumerable<IChannelBindingElement>>() != null);
if (elements == null) {
return new IChannelBindingElement[0];
}
diff --git a/src/DotNetOpenAuth.Core/Messaging/ChannelContract.cs b/src/DotNetOpenAuth.Core/Messaging/ChannelContract.cs
deleted file mode 100644
index 82f2955..0000000
--- a/src/DotNetOpenAuth.Core/Messaging/ChannelContract.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="ChannelContract.cs" company="Outercurve Foundation">
-// Copyright (c) Outercurve Foundation. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace DotNetOpenAuth.Messaging {
- using System;
- using System.Collections.Generic;
- using System.Diagnostics.Contracts;
- using Validation;
-
- /// <summary>
- /// Code contract for the <see cref="Channel"/> class.
- /// </summary>
- [ContractClassFor(typeof(Channel))]
- internal abstract class ChannelContract : Channel {
- /// <summary>
- /// Prevents a default instance of the ChannelContract class from being created.
- /// </summary>
- private ChannelContract()
- : base(null, null) {
- }
-
- /// <summary>
- /// Gets the protocol message that may be in the given HTTP response.
- /// </summary>
- /// <param name="response">The response that is anticipated to contain an protocol message.</param>
- /// <returns>
- /// The deserialized message parts, if found. Null otherwise.
- /// </returns>
- /// <exception cref="ProtocolException">Thrown when the response is not valid.</exception>
- protected override IDictionary<string, string> ReadFromResponseCore(IncomingWebResponse response) {
- Requires.NotNull(response, "response");
- throw new NotImplementedException();
- }
-
- /// <summary>
- /// Queues a message for sending in the response stream where the fields
- /// are sent in the response stream in querystring style.
- /// </summary>
- /// <param name="response">The message to send as a response.</param>
- /// <returns>
- /// The pending user agent redirect based message to be sent as an HttpResponse.
- /// </returns>
- /// <remarks>
- /// This method implements spec V1.0 section 5.3.
- /// </remarks>
- protected override OutgoingWebResponse PrepareDirectResponse(IProtocolMessage response) {
- Requires.NotNull(response, "response");
- Contract.Ensures(Contract.Result<OutgoingWebResponse>() != null);
- throw new NotImplementedException();
- }
- }
-}
diff --git a/src/DotNetOpenAuth.Core/Messaging/ChannelEventArgs.cs b/src/DotNetOpenAuth.Core/Messaging/ChannelEventArgs.cs
index 5cf74ad..5c69e4d 100644
--- a/src/DotNetOpenAuth.Core/Messaging/ChannelEventArgs.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/ChannelEventArgs.cs
@@ -6,7 +6,6 @@
namespace DotNetOpenAuth.Messaging {
using System;
- using System.Diagnostics.Contracts;
using Validation;
/// <summary>
diff --git a/src/DotNetOpenAuth.Core/Messaging/DataBag.cs b/src/DotNetOpenAuth.Core/Messaging/DataBag.cs
index 66b83ac..8469676 100644
--- a/src/DotNetOpenAuth.Core/Messaging/DataBag.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/DataBag.cs
@@ -8,7 +8,6 @@ namespace DotNetOpenAuth.Messaging {
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
- using System.Diagnostics.Contracts;
using Validation;
/// <summary>
diff --git a/src/DotNetOpenAuth.Core/Messaging/DataBagFormatterBase.cs b/src/DotNetOpenAuth.Core/Messaging/DataBagFormatterBase.cs
index f60423b..210a95e 100644
--- a/src/DotNetOpenAuth.Core/Messaging/DataBagFormatterBase.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/DataBagFormatterBase.cs
@@ -8,7 +8,6 @@ namespace DotNetOpenAuth.Messaging {
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
- using System.Diagnostics.Contracts;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
@@ -305,7 +304,6 @@ namespace DotNetOpenAuth.Messaging {
private byte[] CalculateSignature(byte[] bytesToSign, string symmetricSecretHandle) {
Requires.NotNull(bytesToSign, "bytesToSign");
RequiresEx.ValidState(this.asymmetricSigning != null || this.cryptoKeyStore != null);
- Contract.Ensures(Contract.Result<byte[]>() != null);
if (this.asymmetricSigning != null) {
using (var hasher = SHA1.Create()) {
diff --git a/src/DotNetOpenAuth.Core/Messaging/EnumerableCacheExtensions.cs b/src/DotNetOpenAuth.Core/Messaging/EnumerableCacheExtensions.cs
index f5c4b36..0886ef2 100644
--- a/src/DotNetOpenAuth.Core/Messaging/EnumerableCacheExtensions.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/EnumerableCacheExtensions.cs
@@ -9,7 +9,6 @@ namespace DotNetOpenAuth.Messaging {
using System;
using System.Collections;
using System.Collections.Generic;
- using System.Diagnostics.Contracts;
using Validation;
/// <summary>
diff --git a/src/DotNetOpenAuth.Core/Messaging/ErrorUtilities.cs b/src/DotNetOpenAuth.Core/Messaging/ErrorUtilities.cs
index 95c87f1..71c904b 100644
--- a/src/DotNetOpenAuth.Core/Messaging/ErrorUtilities.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/ErrorUtilities.cs
@@ -16,7 +16,6 @@ namespace DotNetOpenAuth.Messaging {
/// <summary>
/// A collection of error checking and reporting methods.
/// </summary>
- [ContractVerification(true)]
[Pure]
internal static class ErrorUtilities {
/// <summary>
@@ -29,7 +28,7 @@ namespace DotNetOpenAuth.Messaging {
[Pure]
internal static Exception Wrap(Exception inner, string errorMessage, params object[] args) {
Requires.NotNull(args, "args");
- Contract.Assume(errorMessage != null);
+ Assumes.True(errorMessage != null);
return new ProtocolException(string.Format(CultureInfo.CurrentCulture, errorMessage, args), inner);
}
@@ -59,8 +58,6 @@ namespace DotNetOpenAuth.Messaging {
/// <exception cref="InternalErrorException">Thrown if <paramref name="condition"/> evaluates to <c>false</c>.</exception>
[Pure]
internal static void VerifyInternal(bool condition, string errorMessage) {
- Contract.Ensures(condition);
- Contract.EnsuresOnThrow<InternalErrorException>(!condition);
if (!condition) {
ThrowInternal(errorMessage);
}
@@ -76,9 +73,7 @@ namespace DotNetOpenAuth.Messaging {
[Pure]
internal static void VerifyInternal(bool condition, string errorMessage, params object[] args) {
Requires.NotNull(args, "args");
- Contract.Ensures(condition);
- Contract.EnsuresOnThrow<InternalErrorException>(!condition);
- Contract.Assume(errorMessage != null);
+ Assumes.True(errorMessage != null);
if (!condition) {
errorMessage = string.Format(CultureInfo.CurrentCulture, errorMessage, args);
throw new InternalErrorException(errorMessage);
@@ -93,8 +88,6 @@ namespace DotNetOpenAuth.Messaging {
/// <exception cref="InvalidOperationException">Thrown if <paramref name="condition"/> evaluates to <c>false</c>.</exception>
[Pure]
internal static void VerifyOperation(bool condition, string errorMessage) {
- Contract.Ensures(condition);
- Contract.EnsuresOnThrow<InvalidOperationException>(!condition);
if (!condition) {
throw new InvalidOperationException(errorMessage);
}
@@ -108,8 +101,6 @@ namespace DotNetOpenAuth.Messaging {
/// <exception cref="NotSupportedException">Thrown if <paramref name="condition"/> evaluates to <c>false</c>.</exception>
[Pure]
internal static void VerifySupported(bool condition, string errorMessage) {
- Contract.Ensures(condition);
- Contract.EnsuresOnThrow<NotSupportedException>(!condition);
if (!condition) {
throw new NotSupportedException(errorMessage);
}
@@ -125,9 +116,7 @@ namespace DotNetOpenAuth.Messaging {
[Pure]
internal static void VerifySupported(bool condition, string errorMessage, params object[] args) {
Requires.NotNull(args, "args");
- Contract.Ensures(condition);
- Contract.EnsuresOnThrow<NotSupportedException>(!condition);
- Contract.Assume(errorMessage != null);
+ Assumes.True(errorMessage != null);
if (!condition) {
throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, errorMessage, args));
}
@@ -143,9 +132,7 @@ namespace DotNetOpenAuth.Messaging {
[Pure]
internal static void VerifyOperation(bool condition, string errorMessage, params object[] args) {
Requires.NotNull(args, "args");
- Contract.Ensures(condition);
- Contract.EnsuresOnThrow<InvalidOperationException>(!condition);
- Contract.Assume(errorMessage != null);
+ Assumes.True(errorMessage != null);
if (!condition) {
errorMessage = string.Format(CultureInfo.CurrentCulture, errorMessage, args);
throw new InvalidOperationException(errorMessage);
@@ -162,9 +149,7 @@ namespace DotNetOpenAuth.Messaging {
[Pure]
internal static void VerifyHost(bool condition, string errorMessage, params object[] args) {
Requires.NotNull(args, "args");
- Contract.Ensures(condition);
- Contract.EnsuresOnThrow<ProtocolException>(!condition);
- Contract.Assume(errorMessage != null);
+ Assumes.True(errorMessage != null);
if (!condition) {
throw new HostErrorException(string.Format(CultureInfo.CurrentCulture, errorMessage, args));
}
@@ -182,9 +167,7 @@ namespace DotNetOpenAuth.Messaging {
internal static void VerifyProtocol(bool condition, IProtocolMessage faultedMessage, string errorMessage, params object[] args) {
Requires.NotNull(args, "args");
Requires.NotNull(faultedMessage, "faultedMessage");
- Contract.Ensures(condition);
- Contract.EnsuresOnThrow<ProtocolException>(!condition);
- Contract.Assume(errorMessage != null);
+ Assumes.True(errorMessage != null);
if (!condition) {
throw new ProtocolException(string.Format(CultureInfo.CurrentCulture, errorMessage, args), faultedMessage);
}
@@ -200,9 +183,7 @@ namespace DotNetOpenAuth.Messaging {
[Pure]
internal static void VerifyProtocol(bool condition, string unformattedMessage, params object[] args) {
Requires.NotNull(args, "args");
- Contract.Ensures(condition);
- Contract.EnsuresOnThrow<ProtocolException>(!condition);
- Contract.Assume(unformattedMessage != null);
+ Assumes.True(unformattedMessage != null);
if (!condition) {
var exception = new ProtocolException(string.Format(CultureInfo.CurrentCulture, unformattedMessage, args));
if (Logger.Messaging.IsErrorEnabled) {
@@ -232,7 +213,7 @@ namespace DotNetOpenAuth.Messaging {
[Pure]
internal static Exception ThrowProtocol(string unformattedMessage, params object[] args) {
Requires.NotNull(args, "args");
- Contract.Assume(unformattedMessage != null);
+ Assumes.True(unformattedMessage != null);
VerifyProtocol(false, unformattedMessage, args);
// we never reach here, but this allows callers to "throw" this method.
@@ -248,7 +229,7 @@ namespace DotNetOpenAuth.Messaging {
[Pure]
internal static Exception ThrowFormat(string message, params object[] args) {
Requires.NotNull(args, "args");
- Contract.Assume(message != null);
+ Assumes.True(message != null);
throw new FormatException(string.Format(CultureInfo.CurrentCulture, message, args));
}
@@ -262,9 +243,7 @@ namespace DotNetOpenAuth.Messaging {
[Pure]
internal static void VerifyFormat(bool condition, string message, params object[] args) {
Requires.NotNull(args, "args");
- Contract.Ensures(condition);
- Contract.EnsuresOnThrow<FormatException>(!condition);
- Contract.Assume(message != null);
+ Assumes.True(message != null);
if (!condition) {
throw ThrowFormat(message, args);
}
@@ -280,9 +259,7 @@ namespace DotNetOpenAuth.Messaging {
[Pure]
internal static void VerifyArgument(bool condition, string message, params object[] args) {
Requires.NotNull(args, "args");
- Contract.Ensures(condition);
- Contract.EnsuresOnThrow<ArgumentException>(!condition);
- Contract.Assume(message != null);
+ Assumes.True(message != null);
if (!condition) {
throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, message, args));
}
@@ -298,7 +275,7 @@ namespace DotNetOpenAuth.Messaging {
[Pure]
internal static Exception ThrowArgumentNamed(string parameterName, string message, params object[] args) {
Requires.NotNull(args, "args");
- Contract.Assume(message != null);
+ Assumes.True(message != null);
throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, message, args), parameterName);
}
@@ -313,9 +290,7 @@ namespace DotNetOpenAuth.Messaging {
[Pure]
internal static void VerifyArgumentNamed(bool condition, string parameterName, string message, params object[] args) {
Requires.NotNull(args, "args");
- Contract.Ensures(condition);
- Contract.EnsuresOnThrow<ArgumentException>(!condition);
- Contract.Assume(message != null);
+ Assumes.True(message != null);
if (!condition) {
throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, message, args), parameterName);
}
@@ -329,8 +304,6 @@ namespace DotNetOpenAuth.Messaging {
/// <exception cref="ArgumentNullException">Thrown if <paramref name="value"/> is null.</exception>
[Pure]
internal static void VerifyArgumentNotNull(object value, string paramName) {
- Contract.Ensures(value != null);
- Contract.EnsuresOnThrow<ArgumentNullException>(value == null);
if (value == null) {
throw new ArgumentNullException(paramName);
}
@@ -345,8 +318,6 @@ namespace DotNetOpenAuth.Messaging {
/// <exception cref="ArgumentException">Thrown if <paramref name="value"/> has zero length.</exception>
[Pure]
internal static void VerifyNonZeroLength(string value, string paramName) {
- Contract.Ensures((value != null && value.Length > 0) && !string.IsNullOrEmpty(value));
- Contract.EnsuresOnThrow<ArgumentException>(value == null || value.Length == 0);
VerifyArgumentNotNull(value, paramName);
if (value.Length == 0) {
throw new ArgumentException(MessagingStrings.UnexpectedEmptyString, paramName);
@@ -359,8 +330,6 @@ namespace DotNetOpenAuth.Messaging {
/// <exception cref="InvalidOperationException">Thrown if <see cref="HttpContext.Current"/> == <c>null</c></exception>
[Pure]
internal static void VerifyHttpContext() {
- Contract.Ensures(HttpContext.Current != null);
- Contract.Ensures(HttpContext.Current.Request != null);
ErrorUtilities.VerifyOperation(HttpContext.Current != null && HttpContext.Current.Request != null, MessagingStrings.HttpContextRequired);
}
diff --git a/src/DotNetOpenAuth.Core/Messaging/HttpRequestInfo.cs b/src/DotNetOpenAuth.Core/Messaging/HttpRequestInfo.cs
index 465ed43..55233c2 100644
--- a/src/DotNetOpenAuth.Core/Messaging/HttpRequestInfo.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/HttpRequestInfo.cs
@@ -9,7 +9,6 @@ namespace DotNetOpenAuth.Messaging {
using System.Collections.Specialized;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
- using System.Diagnostics.Contracts;
using System.Globalization;
using System.IO;
using System.Net;
diff --git a/src/DotNetOpenAuth.Core/Messaging/IChannelBindingElement.cs b/src/DotNetOpenAuth.Core/Messaging/IChannelBindingElement.cs
index d52e1d5..fca46a0 100644
--- a/src/DotNetOpenAuth.Core/Messaging/IChannelBindingElement.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/IChannelBindingElement.cs
@@ -6,14 +6,12 @@
namespace DotNetOpenAuth.Messaging {
using System;
- using System.Diagnostics.Contracts;
using Validation;
/// <summary>
/// An interface that must be implemented by message transforms/validators in order
/// to be included in the channel stack.
/// </summary>
- [ContractClass(typeof(IChannelBindingElementContract))]
public interface IChannelBindingElement {
/// <summary>
/// Gets or sets the channel that this binding element belongs to.
@@ -64,84 +62,4 @@ namespace DotNetOpenAuth.Messaging {
/// </remarks>
MessageProtections? ProcessIncomingMessage(IProtocolMessage message);
}
-
- /// <summary>
- /// Code Contract for the <see cref="IChannelBindingElement"/> interface.
- /// </summary>
- [ContractClassFor(typeof(IChannelBindingElement))]
- internal abstract class IChannelBindingElementContract : IChannelBindingElement {
- /// <summary>
- /// Prevents a default instance of the <see cref="IChannelBindingElementContract"/> class from being created.
- /// </summary>
- private IChannelBindingElementContract() {
- }
-
- #region IChannelBindingElement Members
-
- /// <summary>
- /// Gets or sets the channel that this binding element belongs to.
- /// </summary>
- /// <value></value>
- /// <remarks>
- /// This property is set by the channel when it is first constructed.
- /// </remarks>
- Channel IChannelBindingElement.Channel {
- get { throw new NotImplementedException(); }
- set { throw new NotImplementedException(); }
- }
-
- /// <summary>
- /// Gets the protection commonly offered (if any) by this binding element.
- /// </summary>
- /// <value></value>
- /// <remarks>
- /// This value is used to assist in sorting binding elements in the channel stack.
- /// </remarks>
- MessageProtections IChannelBindingElement.Protection {
- get { throw new NotImplementedException(); }
- }
-
- /// <summary>
- /// Prepares a message for sending based on the rules of this channel binding element.
- /// </summary>
- /// <param name="message">The message to prepare for sending.</param>
- /// <returns>
- /// The protections (if any) that this binding element applied to the message.
- /// Null if this binding element did not even apply to this binding element.
- /// </returns>
- /// <remarks>
- /// Implementations that provide message protection must honor the
- /// <see cref="MessagePartAttribute.RequiredProtection"/> properties where applicable.
- /// </remarks>
- MessageProtections? IChannelBindingElement.ProcessOutgoingMessage(IProtocolMessage message) {
- Requires.NotNull(message, "message");
- Assumes.True(((IChannelBindingElement)this).Channel != null);
- throw new NotImplementedException();
- }
-
- /// <summary>
- /// Performs any transformation on an incoming message that may be necessary and/or
- /// validates an incoming message based on the rules of this channel binding element.
- /// </summary>
- /// <param name="message">The incoming message to process.</param>
- /// <returns>
- /// The protections (if any) that this binding element applied to the message.
- /// Null if this binding element did not even apply to this binding element.
- /// </returns>
- /// <exception cref="ProtocolException">
- /// Thrown when the binding element rules indicate that this message is invalid and should
- /// NOT be processed.
- /// </exception>
- /// <remarks>
- /// Implementations that provide message protection must honor the
- /// <see cref="MessagePartAttribute.RequiredProtection"/> properties where applicable.
- /// </remarks>
- MessageProtections? IChannelBindingElement.ProcessIncomingMessage(IProtocolMessage message) {
- Requires.NotNull(message, "message");
- RequiresEx.ValidState(((IChannelBindingElement)this).Channel != null);
- throw new NotImplementedException();
- }
-
- #endregion
- }
}
diff --git a/src/DotNetOpenAuth.Core/Messaging/IDataBagFormatter.cs b/src/DotNetOpenAuth.Core/Messaging/IDataBagFormatter.cs
index 65badc1..955d7c0 100644
--- a/src/DotNetOpenAuth.Core/Messaging/IDataBagFormatter.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/IDataBagFormatter.cs
@@ -6,14 +6,12 @@
namespace DotNetOpenAuth.Messaging {
using System;
- using System.Diagnostics.Contracts;
using Validation;
/// <summary>
/// A serializer for <see cref="DataBag"/>-derived types
/// </summary>
/// <typeparam name="T">The DataBag-derived type that is to be serialized/deserialized.</typeparam>
- [ContractClass(typeof(IDataBagFormatterContract<>))]
internal interface IDataBagFormatter<in T> where T : DataBag {
/// <summary>
/// Serializes the specified message.
@@ -31,50 +29,4 @@ namespace DotNetOpenAuth.Messaging {
/// <param name="messagePartName">The name of the parameter whose value is to be deserialized. Used for error message generation, but may be <c>null</c>.</param>
void Deserialize(T message, string data, IProtocolMessage containingMessage = null, string messagePartName = null);
}
-
- /// <summary>
- /// Contract class for the IDataBagFormatter interface.
- /// </summary>
- /// <typeparam name="T">The type of DataBag to serialize.</typeparam>
- [ContractClassFor(typeof(IDataBagFormatter<>))]
- internal abstract class IDataBagFormatterContract<T> : IDataBagFormatter<T> where T : DataBag, new() {
- /// <summary>
- /// Prevents a default instance of the <see cref="IDataBagFormatterContract&lt;T&gt;"/> class from being created.
- /// </summary>
- private IDataBagFormatterContract() {
- }
-
- #region IDataBagFormatter<T> Members
-
- /// <summary>
- /// Serializes the specified message.
- /// </summary>
- /// <param name="message">The message to serialize. Must not be null.</param>
- /// <returns>A non-null, non-empty value.</returns>
- string IDataBagFormatter<T>.Serialize(T message) {
- Requires.NotNull(message, "message");
- Contract.Ensures(!string.IsNullOrEmpty(Contract.Result<string>()));
-
- throw new System.NotImplementedException();
- }
-
- /// <summary>
- /// Deserializes a <see cref="DataBag"/>.
- /// </summary>
- /// <param name="message">The instance to deserialize into</param>
- /// <param name="data">The serialized form of the <see cref="DataBag"/> to deserialize. Must not be null or empty.</param>
- /// <param name="containingMessage">The message that contains the <see cref="DataBag"/> serialized value. Must not be nulll.</param>
- /// <param name="messagePartName">Name of the message part whose value is to be deserialized. Used for exception messages.</param>
- void IDataBagFormatter<T>.Deserialize(T message, string data, IProtocolMessage containingMessage, string messagePartName) {
- Requires.NotNull(message, "message");
- Requires.NotNull(containingMessage, "containingMessage");
- Requires.NotNullOrEmpty(data, "data");
- Requires.NotNullOrEmpty(messagePartName, "messagePartName");
- Contract.Ensures(Contract.Result<T>() != null);
-
- throw new System.NotImplementedException();
- }
-
- #endregion
- }
} \ No newline at end of file
diff --git a/src/DotNetOpenAuth.Core/Messaging/IDirectWebRequestHandler.cs b/src/DotNetOpenAuth.Core/Messaging/IDirectWebRequestHandler.cs
index 3a60280..f3975b3 100644
--- a/src/DotNetOpenAuth.Core/Messaging/IDirectWebRequestHandler.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/IDirectWebRequestHandler.cs
@@ -19,7 +19,6 @@ namespace DotNetOpenAuth.Messaging {
/// <remarks>
/// Implementations of this interface must be thread safe.
/// </remarks>
- [ContractClass(typeof(IDirectWebRequestHandlerContract))]
public interface IDirectWebRequestHandler {
/// <summary>
/// Determines whether this instance can support the specified options.
@@ -103,122 +102,4 @@ namespace DotNetOpenAuth.Messaging {
/// </remarks>
IncomingWebResponse GetResponse(HttpWebRequest request, DirectWebRequestOptions options);
}
-
- /// <summary>
- /// Code contract for the <see cref="IDirectWebRequestHandler"/> type.
- /// </summary>
- [ContractClassFor(typeof(IDirectWebRequestHandler))]
- internal abstract class IDirectWebRequestHandlerContract : IDirectWebRequestHandler {
- #region IDirectWebRequestHandler Members
-
- /// <summary>
- /// Determines whether this instance can support the specified options.
- /// </summary>
- /// <param name="options">The set of options that might be given in a subsequent web request.</param>
- /// <returns>
- /// <c>true</c> if this instance can support the specified options; otherwise, <c>false</c>.
- /// </returns>
- bool IDirectWebRequestHandler.CanSupport(DirectWebRequestOptions options) {
- throw new System.NotImplementedException();
- }
-
- /// <summary>
- /// Prepares an <see cref="HttpWebRequest"/> that contains an POST entity for sending the entity.
- /// </summary>
- /// <param name="request">The <see cref="HttpWebRequest"/> that should contain the entity.</param>
- /// <returns>
- /// The stream the caller should write out the entity data to.
- /// </returns>
- /// <exception cref="ProtocolException">Thrown for any network error.</exception>
- /// <remarks>
- /// <para>The caller should have set the <see cref="HttpWebRequest.ContentLength"/>
- /// and any other appropriate properties <i>before</i> calling this method.
- /// Callers <i>must</i> close and dispose of the request stream when they are done
- /// writing to it to avoid taking up the connection too long and causing long waits on
- /// subsequent requests.</para>
- /// <para>Implementations should catch <see cref="WebException"/> and wrap it in a
- /// <see cref="ProtocolException"/> to abstract away the transport and provide
- /// a single exception type for hosts to catch.</para>
- /// </remarks>
- Stream IDirectWebRequestHandler.GetRequestStream(HttpWebRequest request) {
- Requires.NotNull(request, "request");
- throw new System.NotImplementedException();
- }
-
- /// <summary>
- /// Prepares an <see cref="HttpWebRequest"/> that contains an POST entity for sending the entity.
- /// </summary>
- /// <param name="request">The <see cref="HttpWebRequest"/> that should contain the entity.</param>
- /// <param name="options">The options to apply to this web request.</param>
- /// <returns>
- /// The stream the caller should write out the entity data to.
- /// </returns>
- /// <exception cref="ProtocolException">Thrown for any network error.</exception>
- /// <remarks>
- /// <para>The caller should have set the <see cref="HttpWebRequest.ContentLength"/>
- /// and any other appropriate properties <i>before</i> calling this method.
- /// Callers <i>must</i> close and dispose of the request stream when they are done
- /// writing to it to avoid taking up the connection too long and causing long waits on
- /// subsequent requests.</para>
- /// <para>Implementations should catch <see cref="WebException"/> and wrap it in a
- /// <see cref="ProtocolException"/> to abstract away the transport and provide
- /// a single exception type for hosts to catch.</para>
- /// </remarks>
- Stream IDirectWebRequestHandler.GetRequestStream(HttpWebRequest request, DirectWebRequestOptions options) {
- Requires.NotNull(request, "request");
- RequiresEx.Support(((IDirectWebRequestHandler)this).CanSupport(options), MessagingStrings.DirectWebRequestOptionsNotSupported);
- ////ErrorUtilities.VerifySupported(((IDirectWebRequestHandler)this).CanSupport(options), string.Format(MessagingStrings.DirectWebRequestOptionsNotSupported, options, this.GetType().Name));
- throw new System.NotImplementedException();
- }
-
- /// <summary>
- /// Processes an <see cref="HttpWebRequest"/> and converts the
- /// <see cref="HttpWebResponse"/> to a <see cref="IncomingWebResponse"/> instance.
- /// </summary>
- /// <param name="request">The <see cref="HttpWebRequest"/> to handle.</param>
- /// <returns>
- /// An instance of <see cref="IncomingWebResponse"/> describing the response.
- /// </returns>
- /// <exception cref="ProtocolException">Thrown for any network error.</exception>
- /// <remarks>
- /// Implementations should catch <see cref="WebException"/> and wrap it in a
- /// <see cref="ProtocolException"/> to abstract away the transport and provide
- /// a single exception type for hosts to catch. The <see cref="WebException.Response"/>
- /// value, if set, should be Closed before throwing.
- /// </remarks>
- IncomingWebResponse IDirectWebRequestHandler.GetResponse(HttpWebRequest request) {
- Requires.NotNull(request, "request");
- Contract.Ensures(Contract.Result<IncomingWebResponse>() != null);
- Contract.Ensures(Contract.Result<IncomingWebResponse>().ResponseStream != null);
- throw new System.NotImplementedException();
- }
-
- /// <summary>
- /// Processes an <see cref="HttpWebRequest"/> and converts the
- /// <see cref="HttpWebResponse"/> to a <see cref="IncomingWebResponse"/> instance.
- /// </summary>
- /// <param name="request">The <see cref="HttpWebRequest"/> to handle.</param>
- /// <param name="options">The options to apply to this web request.</param>
- /// <returns>
- /// An instance of <see cref="IncomingWebResponse"/> describing the response.
- /// </returns>
- /// <exception cref="ProtocolException">Thrown for any network error.</exception>
- /// <remarks>
- /// Implementations should catch <see cref="WebException"/> and wrap it in a
- /// <see cref="ProtocolException"/> to abstract away the transport and provide
- /// a single exception type for hosts to catch. The <see cref="WebException.Response"/>
- /// value, if set, should be Closed before throwing.
- /// </remarks>
- IncomingWebResponse IDirectWebRequestHandler.GetResponse(HttpWebRequest request, DirectWebRequestOptions options) {
- Requires.NotNull(request, "request");
- Contract.Ensures(Contract.Result<IncomingWebResponse>() != null);
- Contract.Ensures(Contract.Result<IncomingWebResponse>().ResponseStream != null);
- RequiresEx.Support(((IDirectWebRequestHandler)this).CanSupport(options), MessagingStrings.DirectWebRequestOptionsNotSupported);
-
- ////ErrorUtilities.VerifySupported(((IDirectWebRequestHandler)this).CanSupport(options), string.Format(MessagingStrings.DirectWebRequestOptionsNotSupported, options, this.GetType().Name));
- throw new System.NotImplementedException();
- }
-
- #endregion
- }
}
diff --git a/src/DotNetOpenAuth.Core/Messaging/IHttpDirectRequest.cs b/src/DotNetOpenAuth.Core/Messaging/IHttpDirectRequest.cs
index 7153334..7b26869 100644
--- a/src/DotNetOpenAuth.Core/Messaging/IHttpDirectRequest.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/IHttpDirectRequest.cs
@@ -5,13 +5,11 @@
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.Messaging {
- using System.Diagnostics.Contracts;
using System.Net;
/// <summary>
/// An interface that allows direct request messages to capture the details of the HTTP request they arrived on.
/// </summary>
- [ContractClass(typeof(IHttpDirectRequestContract))]
public interface IHttpDirectRequest : IMessage {
/// <summary>
/// Gets the HTTP headers of the request.
diff --git a/src/DotNetOpenAuth.Core/Messaging/IHttpDirectRequestContract.cs b/src/DotNetOpenAuth.Core/Messaging/IHttpDirectRequestContract.cs
deleted file mode 100644
index cfde6cf..0000000
--- a/src/DotNetOpenAuth.Core/Messaging/IHttpDirectRequestContract.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="IHttpDirectRequestContract.cs" company="Outercurve Foundation">
-// Copyright (c) Outercurve Foundation. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace DotNetOpenAuth.Messaging {
- using System;
- using System.Collections.Generic;
- using System.Diagnostics.Contracts;
- using System.Linq;
- using System.Net;
- using System.Text;
-
- /// <summary>
- /// Contract class for the <see cref="IHttpDirectRequest"/> interface.
- /// </summary>
- [ContractClassFor(typeof(IHttpDirectRequest))]
- public abstract class IHttpDirectRequestContract : IHttpDirectRequest {
- #region IHttpDirectRequest Members
-
- /// <summary>
- /// Gets the HTTP headers of the request.
- /// </summary>
- /// <value>May be an empty collection, but must not be <c>null</c>.</value>
- WebHeaderCollection IHttpDirectRequest.Headers {
- get {
- Contract.Ensures(Contract.Result<WebHeaderCollection>() != null);
- throw new NotImplementedException();
- }
- }
-
- #endregion
-
- #region IMessage Members
-
- /// <summary>
- /// Gets the version of the protocol or extension this message is prepared to implement.
- /// </summary>
- /// <remarks>
- /// Implementations of this interface should ensure that this property never returns null.
- /// </remarks>
- Version IMessage.Version {
- get { throw new NotImplementedException(); }
- }
-
- /// <summary>
- /// Gets the extra, non-standard Protocol parameters included in the message.
- /// </summary>
- /// <remarks>
- /// Implementations of this interface should ensure that this property never returns null.
- /// </remarks>
- IDictionary<string, string> IMessage.ExtraData {
- get { throw new NotImplementedException(); }
- }
-
- /// <summary>
- /// Checks the message state for conformity to the protocol specification
- /// and throws an exception if the message is invalid.
- /// </summary>
- /// <remarks>
- /// <para>Some messages have required fields, or combinations of fields that must relate to each other
- /// in specialized ways. After deserializing a message, this method checks the state of the
- /// message to see if it conforms to the protocol.</para>
- /// <para>Note that this property should <i>not</i> check signatures or perform any state checks
- /// outside this scope of this particular message.</para>
- /// </remarks>
- /// <exception cref="ProtocolException">Thrown if the message is invalid.</exception>
- void IMessage.EnsureValidMessage() {
- throw new NotImplementedException();
- }
-
- #endregion
- }
-}
diff --git a/src/DotNetOpenAuth.Core/Messaging/IHttpDirectResponse.cs b/src/DotNetOpenAuth.Core/Messaging/IHttpDirectResponse.cs
index d942366..f455fcf 100644
--- a/src/DotNetOpenAuth.Core/Messaging/IHttpDirectResponse.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/IHttpDirectResponse.cs
@@ -5,14 +5,12 @@
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.Messaging {
- using System.Diagnostics.Contracts;
using System.Net;
/// <summary>
/// An interface that allows direct response messages to specify
/// HTTP transport specific properties.
/// </summary>
- [ContractClass(typeof(IHttpDirectResponseContract))]
public interface IHttpDirectResponse {
/// <summary>
/// Gets the HTTP status code that the direct response should be sent with.
diff --git a/src/DotNetOpenAuth.Core/Messaging/IHttpDirectResponseContract.cs b/src/DotNetOpenAuth.Core/Messaging/IHttpDirectResponseContract.cs
deleted file mode 100644
index a04ba62..0000000
--- a/src/DotNetOpenAuth.Core/Messaging/IHttpDirectResponseContract.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="IHttpDirectResponseContract.cs" company="Outercurve Foundation">
-// Copyright (c) Outercurve Foundation. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace DotNetOpenAuth.Messaging {
- using System;
- using System.Collections.Generic;
- using System.Diagnostics.Contracts;
- using System.Linq;
- using System.Net;
- using System.Text;
-
- /// <summary>
- /// Contract class for the <see cref="IHttpDirectResponse"/> interface.
- /// </summary>
- [ContractClassFor(typeof(IHttpDirectResponse))]
- public abstract class IHttpDirectResponseContract : IHttpDirectResponse {
- #region IHttpDirectResponse Members
-
- /// <summary>
- /// Gets the HTTP status code that the direct response should be sent with.
- /// </summary>
- /// <value></value>
- HttpStatusCode IHttpDirectResponse.HttpStatusCode {
- get { throw new NotImplementedException(); }
- }
-
- /// <summary>
- /// Gets the HTTP headers to add to the response.
- /// </summary>
- /// <value>May be an empty collection, but must not be <c>null</c>.</value>
- WebHeaderCollection IHttpDirectResponse.Headers {
- get {
- Contract.Ensures(Contract.Result<WebHeaderCollection>() != null);
- throw new NotImplementedException();
- }
- }
-
- #endregion
- }
-}
diff --git a/src/DotNetOpenAuth.Core/Messaging/IHttpIndirectResponse.cs b/src/DotNetOpenAuth.Core/Messaging/IHttpIndirectResponse.cs
index e0e8665..c9ab73b 100644
--- a/src/DotNetOpenAuth.Core/Messaging/IHttpIndirectResponse.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/IHttpIndirectResponse.cs
@@ -5,7 +5,6 @@
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.Messaging {
- using System.Diagnostics.Contracts;
using System.Net;
/// <summary>
diff --git a/src/DotNetOpenAuth.Core/Messaging/IMessage.cs b/src/DotNetOpenAuth.Core/Messaging/IMessage.cs
index 62673ef..c007913 100644
--- a/src/DotNetOpenAuth.Core/Messaging/IMessage.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/IMessage.cs
@@ -7,14 +7,12 @@
namespace DotNetOpenAuth.Messaging {
using System;
using System.Collections.Generic;
- using System.Diagnostics.Contracts;
using System.Text;
/// <summary>
/// The interface that classes must implement to be serialized/deserialized
/// as protocol or extension messages.
/// </summary>
- [ContractClass(typeof(IMessageContract))]
public interface IMessage {
/// <summary>
/// Gets the version of the protocol or extension this message is prepared to implement.
@@ -46,55 +44,4 @@ namespace DotNetOpenAuth.Messaging {
/// <exception cref="ProtocolException">Thrown if the message is invalid.</exception>
void EnsureValidMessage();
}
-
- /// <summary>
- /// Code contract for the <see cref="IMessage"/> interface.
- /// </summary>
- [ContractClassFor(typeof(IMessage))]
- internal abstract class IMessageContract : IMessage {
- /// <summary>
- /// Prevents a default instance of the <see cref="IMessageContract"/> class from being created.
- /// </summary>
- private IMessageContract() {
- }
-
- /// <summary>
- /// Gets the version of the protocol or extension this message is prepared to implement.
- /// </summary>
- Version IMessage.Version {
- get {
- Contract.Ensures(Contract.Result<Version>() != null);
- return default(Version); // dummy return
- }
- }
-
- /// <summary>
- /// Gets the extra, non-standard Protocol parameters included in the message.
- /// </summary>
- /// <value></value>
- /// <remarks>
- /// Implementations of this interface should ensure that this property never returns null.
- /// </remarks>
- IDictionary<string, string> IMessage.ExtraData {
- get {
- Contract.Ensures(Contract.Result<IDictionary<string, string>>() != null);
- return default(IDictionary<string, string>);
- }
- }
-
- /// <summary>
- /// Checks the message state for conformity to the protocol specification
- /// and throws an exception if the message is invalid.
- /// </summary>
- /// <remarks>
- /// <para>Some messages have required fields, or combinations of fields that must relate to each other
- /// in specialized ways. After deserializing a message, this method checks the state of the
- /// message to see if it conforms to the protocol.</para>
- /// <para>Note that this property should <i>not</i> check signatures or perform any state checks
- /// outside this scope of this particular message.</para>
- /// </remarks>
- /// <exception cref="ProtocolException">Thrown if the message is invalid.</exception>
- void IMessage.EnsureValidMessage() {
- }
- }
}
diff --git a/src/DotNetOpenAuth.Core/Messaging/IMessageFactory.cs b/src/DotNetOpenAuth.Core/Messaging/IMessageFactory.cs
index 49b9086..1e86328 100644
--- a/src/DotNetOpenAuth.Core/Messaging/IMessageFactory.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/IMessageFactory.cs
@@ -7,14 +7,12 @@
namespace DotNetOpenAuth.Messaging {
using System;
using System.Collections.Generic;
- using System.Diagnostics.Contracts;
using Validation;
/// <summary>
/// A tool to analyze an incoming message to figure out what concrete class
/// is designed to deserialize it and instantiates that class.
/// </summary>
- [ContractClass(typeof(IMessageFactoryContract))]
public interface IMessageFactory {
/// <summary>
/// Analyzes an incoming request message payload to discover what kind of
@@ -42,53 +40,4 @@ namespace DotNetOpenAuth.Messaging {
/// </returns>
IDirectResponseProtocolMessage GetNewResponseMessage(IDirectedProtocolMessage request, IDictionary<string, string> fields);
}
-
- /// <summary>
- /// Code contract for the <see cref="IMessageFactory"/> interface.
- /// </summary>
- [ContractClassFor(typeof(IMessageFactory))]
- internal abstract class IMessageFactoryContract : IMessageFactory {
- /// <summary>
- /// Prevents a default instance of the <see cref="IMessageFactoryContract"/> class from being created.
- /// </summary>
- private IMessageFactoryContract() {
- }
-
- #region IMessageFactory Members
-
- /// <summary>
- /// Analyzes an incoming request message payload to discover what kind of
- /// message is embedded in it and returns the type, or null if no match is found.
- /// </summary>
- /// <param name="recipient">The intended or actual recipient of the request message.</param>
- /// <param name="fields">The name/value pairs that make up the message payload.</param>
- /// <returns>
- /// A newly instantiated <see cref="IProtocolMessage"/>-derived object that this message can
- /// deserialize to. Null if the request isn't recognized as a valid protocol message.
- /// </returns>
- IDirectedProtocolMessage IMessageFactory.GetNewRequestMessage(MessageReceivingEndpoint recipient, IDictionary<string, string> fields) {
- Requires.NotNull(recipient, "recipient");
- Requires.NotNull(fields, "fields");
-
- throw new NotImplementedException();
- }
-
- /// <summary>
- /// Analyzes an incoming request message payload to discover what kind of
- /// message is embedded in it and returns the type, or null if no match is found.
- /// </summary>
- /// <param name="request">The message that was sent as a request that resulted in the response.</param>
- /// <param name="fields">The name/value pairs that make up the message payload.</param>
- /// <returns>
- /// A newly instantiated <see cref="IProtocolMessage"/>-derived object that this message can
- /// deserialize to. Null if the request isn't recognized as a valid protocol message.
- /// </returns>
- IDirectResponseProtocolMessage IMessageFactory.GetNewResponseMessage(IDirectedProtocolMessage request, IDictionary<string, string> fields) {
- Requires.NotNull(request, "request");
- Requires.NotNull(fields, "fields");
- throw new NotImplementedException();
- }
-
- #endregion
- }
}
diff --git a/src/DotNetOpenAuth.Core/Messaging/IMessageOriginalPayload.cs b/src/DotNetOpenAuth.Core/Messaging/IMessageOriginalPayload.cs
index 099f54b..33fa860 100644
--- a/src/DotNetOpenAuth.Core/Messaging/IMessageOriginalPayload.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/IMessageOriginalPayload.cs
@@ -8,14 +8,12 @@ namespace DotNetOpenAuth.Messaging {
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
- using System.Diagnostics.Contracts;
using System.Text;
/// <summary>
/// An interface that appears on messages that need to retain a description of
/// what their literal payload was when they were deserialized.
/// </summary>
- [ContractClass(typeof(IMessageOriginalPayloadContract))]
public interface IMessageOriginalPayload {
/// <summary>
/// Gets or sets the original message parts, before any normalization or default values were assigned.
@@ -23,18 +21,4 @@ namespace DotNetOpenAuth.Messaging {
[SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "By design")]
IDictionary<string, string> OriginalPayload { get; set; }
}
-
- /// <summary>
- /// Code contract for the <see cref="IMessageOriginalPayload"/> interface.
- /// </summary>
- [ContractClassFor(typeof(IMessageOriginalPayload))]
- internal abstract class IMessageOriginalPayloadContract : IMessageOriginalPayload {
- /// <summary>
- /// Gets or sets the original message parts, before any normalization or default values were assigned.
- /// </summary>
- IDictionary<string, string> IMessageOriginalPayload.OriginalPayload {
- get { throw new NotImplementedException(); }
- set { throw new NotImplementedException(); }
- }
- }
}
diff --git a/src/DotNetOpenAuth.Core/Messaging/IMessageWithBinaryData.cs b/src/DotNetOpenAuth.Core/Messaging/IMessageWithBinaryData.cs
index 60e1f50..2992678 100644
--- a/src/DotNetOpenAuth.Core/Messaging/IMessageWithBinaryData.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/IMessageWithBinaryData.cs
@@ -7,7 +7,6 @@
namespace DotNetOpenAuth.Messaging {
using System;
using System.Collections.Generic;
- using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
@@ -15,7 +14,6 @@ namespace DotNetOpenAuth.Messaging {
/// The interface that classes must implement to be serialized/deserialized
/// as protocol or extension messages that uses POST multi-part data for binary content.
/// </summary>
- [ContractClass(typeof(IMessageWithBinaryDataContract))]
public interface IMessageWithBinaryData : IDirectedProtocolMessage {
/// <summary>
/// Gets the parts of the message that carry binary data.
@@ -28,129 +26,4 @@ namespace DotNetOpenAuth.Messaging {
/// </summary>
bool SendAsMultipart { get; }
}
-
- /// <summary>
- /// The contract class for the <see cref="IMessageWithBinaryData"/> interface.
- /// </summary>
- [ContractClassFor(typeof(IMessageWithBinaryData))]
- internal abstract class IMessageWithBinaryDataContract : IMessageWithBinaryData {
- /// <summary>
- /// Prevents a default instance of the <see cref="IMessageWithBinaryDataContract"/> class from being created.
- /// </summary>
- private IMessageWithBinaryDataContract() {
- }
-
- #region IMessageWithBinaryData Members
-
- /// <summary>
- /// Gets the parts of the message that carry binary data.
- /// </summary>
- /// <value>A list of parts. Never null.</value>
- IList<MultipartPostPart> IMessageWithBinaryData.BinaryData {
- get {
- Contract.Ensures(Contract.Result<IList<MultipartPostPart>>() != null);
- throw new NotImplementedException();
- }
- }
-
- /// <summary>
- /// Gets a value indicating whether this message should be sent as multi-part POST.
- /// </summary>
- bool IMessageWithBinaryData.SendAsMultipart {
- get { throw new NotImplementedException(); }
- }
-
- #endregion
-
- #region IMessage Properties
-
- /// <summary>
- /// Gets the version of the protocol or extension this message is prepared to implement.
- /// </summary>
- /// <value></value>
- /// <remarks>
- /// Implementations of this interface should ensure that this property never returns null.
- /// </remarks>
- Version IMessage.Version {
- get {
- return default(Version); // dummy return
- }
- }
-
- /// <summary>
- /// Gets the extra, non-standard Protocol parameters included in the message.
- /// </summary>
- /// <value></value>
- /// <remarks>
- /// Implementations of this interface should ensure that this property never returns null.
- /// </remarks>
- IDictionary<string, string> IMessage.ExtraData {
- get {
- return default(IDictionary<string, string>);
- }
- }
-
- #endregion
-
- #region IDirectedProtocolMessage Members
-
- /// <summary>
- /// Gets the preferred method of transport for the message.
- /// </summary>
- /// <remarks>
- /// For indirect messages this will likely be GET+POST, which both can be simulated in the user agent:
- /// the GET with a simple 301 Redirect, and the POST with an HTML form in the response with javascript
- /// to automate submission.
- /// </remarks>
- HttpDeliveryMethods IDirectedProtocolMessage.HttpMethods {
- get { throw new NotImplementedException(); }
- }
-
- /// <summary>
- /// Gets the URL of the intended receiver of this message.
- /// </summary>
- Uri IDirectedProtocolMessage.Recipient {
- get { throw new NotImplementedException(); }
- }
-
- #endregion
-
- #region IProtocolMessage Members
-
- /// <summary>
- /// Gets the level of protection this message requires.
- /// </summary>
- MessageProtections IProtocolMessage.RequiredProtection {
- get { throw new NotImplementedException(); }
- }
-
- /// <summary>
- /// Gets a value indicating whether this is a direct or indirect message.
- /// </summary>
- MessageTransport IProtocolMessage.Transport {
- get { throw new NotImplementedException(); }
- }
-
- #endregion
-
- #region IMessage methods
-
- /// <summary>
- /// Checks the message state for conformity to the protocol specification
- /// and throws an exception if the message is invalid.
- /// </summary>
- /// <remarks>
- /// <para>Some messages have required fields, or combinations of fields that must relate to each other
- /// in specialized ways. After deserializing a message, this method checks the state of the
- /// message to see if it conforms to the protocol.</para>
- /// <para>Note that this property should <i>not</i> check signatures or perform any state checks
- /// outside this scope of this particular message.</para>
- /// </remarks>
- /// <exception cref="ProtocolException">Thrown if the message is invalid.</exception>
- void IMessage.EnsureValidMessage() {
- throw new NotImplementedException();
- }
-
- #endregion
- }
}
diff --git a/src/DotNetOpenAuth.Core/Messaging/IProtocolMessageWithExtensions.cs b/src/DotNetOpenAuth.Core/Messaging/IProtocolMessageWithExtensions.cs
index c492e65..436c7a9 100644
--- a/src/DotNetOpenAuth.Core/Messaging/IProtocolMessageWithExtensions.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/IProtocolMessageWithExtensions.cs
@@ -7,12 +7,10 @@
namespace DotNetOpenAuth.Messaging {
using System;
using System.Collections.Generic;
- using System.Diagnostics.Contracts;
/// <summary>
/// A protocol message that supports adding extensions to the payload for transmission.
/// </summary>
- [ContractClass(typeof(IProtocolMessageWithExtensionsContract))]
public interface IProtocolMessageWithExtensions : IProtocolMessage {
/// <summary>
/// Gets the list of extensions that are included with this message.
@@ -22,95 +20,4 @@ namespace DotNetOpenAuth.Messaging {
/// </remarks>
IList<IExtensionMessage> Extensions { get; }
}
-
- /// <summary>
- /// Code contract for the <see cref="IProtocolMessageWithExtensions"/> interface.
- /// </summary>
- [ContractClassFor(typeof(IProtocolMessageWithExtensions))]
- internal abstract class IProtocolMessageWithExtensionsContract : IProtocolMessageWithExtensions {
- /// <summary>
- /// Prevents a default instance of the <see cref="IProtocolMessageWithExtensionsContract"/> class from being created.
- /// </summary>
- private IProtocolMessageWithExtensionsContract() {
- }
-
- #region IProtocolMessageWithExtensions Members
-
- /// <summary>
- /// Gets the list of extensions that are included with this message.
- /// </summary>
- /// <remarks>
- /// Implementations of this interface should ensure that this property never returns null.
- /// </remarks>
- IList<IExtensionMessage> IProtocolMessageWithExtensions.Extensions {
- get {
- Contract.Ensures(Contract.Result<IList<IExtensionMessage>>() != null);
- throw new NotImplementedException();
- }
- }
-
- #endregion
-
- #region IProtocolMessage Members
-
- /// <summary>
- /// Gets the level of protection this message requires.
- /// </summary>
- MessageProtections IProtocolMessage.RequiredProtection {
- get { throw new NotImplementedException(); }
- }
-
- /// <summary>
- /// Gets a value indicating whether this is a direct or indirect message.
- /// </summary>
- MessageTransport IProtocolMessage.Transport {
- get { throw new NotImplementedException(); }
- }
-
- #endregion
-
- #region IMessage Members
-
- /// <summary>
- /// Gets the version of the protocol or extension this message is prepared to implement.
- /// </summary>
- /// <remarks>
- /// Implementations of this interface should ensure that this property never returns null.
- /// </remarks>
- Version IMessage.Version {
- get {
- throw new NotImplementedException();
- }
- }
-
- /// <summary>
- /// Gets the extra, non-standard Protocol parameters included in the message.
- /// </summary>
- /// <remarks>
- /// Implementations of this interface should ensure that this property never returns null.
- /// </remarks>
- IDictionary<string, string> IMessage.ExtraData {
- get {
- throw new NotImplementedException();
- }
- }
-
- /// <summary>
- /// Checks the message state for conformity to the protocol specification
- /// and throws an exception if the message is invalid.
- /// </summary>
- /// <remarks>
- /// <para>Some messages have required fields, or combinations of fields that must relate to each other
- /// in specialized ways. After deserializing a message, this method checks the state of the
- /// message to see if it conforms to the protocol.</para>
- /// <para>Note that this property should <i>not</i> check signatures or perform any state checks
- /// outside this scope of this particular message.</para>
- /// </remarks>
- /// <exception cref="ProtocolException">Thrown if the message is invalid.</exception>
- void IMessage.EnsureValidMessage() {
- throw new NotImplementedException();
- }
-
- #endregion
- }
}
diff --git a/src/DotNetOpenAuth.Core/Messaging/IStreamSerializingDataBag.cs b/src/DotNetOpenAuth.Core/Messaging/IStreamSerializingDataBag.cs
index 42608f4..16fed67 100644
--- a/src/DotNetOpenAuth.Core/Messaging/IStreamSerializingDataBag.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/IStreamSerializingDataBag.cs
@@ -6,7 +6,6 @@
namespace DotNetOpenAuth.Messaging {
using System;
- using System.Diagnostics.Contracts;
using System.IO;
/// <summary>
diff --git a/src/DotNetOpenAuth.Core/Messaging/IncomingWebResponse.cs b/src/DotNetOpenAuth.Core/Messaging/IncomingWebResponse.cs
index 285eddd..abb01a1 100644
--- a/src/DotNetOpenAuth.Core/Messaging/IncomingWebResponse.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/IncomingWebResponse.cs
@@ -7,7 +7,6 @@
namespace DotNetOpenAuth.Messaging {
using System;
using System.Diagnostics.CodeAnalysis;
- using System.Diagnostics.Contracts;
using System.Globalization;
using System.IO;
using System.Net;
@@ -18,8 +17,6 @@ namespace DotNetOpenAuth.Messaging {
/// <summary>
/// Details on the incoming response from a direct web request to a remote party.
/// </summary>
- [ContractVerification(true)]
- [ContractClass(typeof(IncomingWebResponseContract))]
public abstract class IncomingWebResponse : IDisposable {
/// <summary>
/// The encoding to use in reading a response that does not declare its own content encoding.
diff --git a/src/DotNetOpenAuth.Core/Messaging/IncomingWebResponseContract.cs b/src/DotNetOpenAuth.Core/Messaging/IncomingWebResponseContract.cs
deleted file mode 100644
index 6798ed3..0000000
--- a/src/DotNetOpenAuth.Core/Messaging/IncomingWebResponseContract.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="IncomingWebResponseContract.cs" company="Outercurve Foundation">
-// Copyright (c) Outercurve Foundation. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace DotNetOpenAuth.Messaging {
- using System;
- using System.Diagnostics.Contracts;
- using System.IO;
- using Validation;
-
- /// <summary>
- /// Code contract for the <see cref="IncomingWebResponse"/> class.
- /// </summary>
- [ContractClassFor(typeof(IncomingWebResponse))]
- internal abstract class IncomingWebResponseContract : IncomingWebResponse {
- /// <summary>
- /// Gets the body of the HTTP response.
- /// </summary>
- /// <value></value>
- public override Stream ResponseStream {
- get { throw new NotImplementedException(); }
- }
-
- /// <summary>
- /// Creates a text reader for the response stream.
- /// </summary>
- /// <returns>
- /// The text reader, initialized for the proper encoding.
- /// </returns>
- public override StreamReader GetResponseReader() {
- Contract.Ensures(Contract.Result<StreamReader>() != null);
- throw new NotImplementedException();
- }
-
- /// <summary>
- /// Gets an offline snapshot version of this instance.
- /// </summary>
- /// <param name="maximumBytesToCache">The maximum bytes from the response stream to cache.</param>
- /// <returns>A snapshot version of this instance.</returns>
- /// <remarks>
- /// If this instance is a <see cref="NetworkDirectWebResponse"/> creating a snapshot
- /// will automatically close and dispose of the underlying response stream.
- /// If this instance is a <see cref="CachedDirectWebResponse"/>, the result will
- /// be the self same instance.
- /// </remarks>
- internal override CachedDirectWebResponse GetSnapshot(int maximumBytesToCache) {
- Requires.Range(maximumBytesToCache >= 0, "maximumBytesToCache");
- RequiresEx.ValidState(this.RequestUri != null);
- Contract.Ensures(Contract.Result<CachedDirectWebResponse>() != null);
- throw new NotImplementedException();
- }
- }
-}
diff --git a/src/DotNetOpenAuth.Core/Messaging/KeyedCollectionDelegate.cs b/src/DotNetOpenAuth.Core/Messaging/KeyedCollectionDelegate.cs
index daf780e..251ff30 100644
--- a/src/DotNetOpenAuth.Core/Messaging/KeyedCollectionDelegate.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/KeyedCollectionDelegate.cs
@@ -7,7 +7,6 @@
namespace DotNetOpenAuth.Messaging {
using System;
using System.Collections.ObjectModel;
- using System.Diagnostics.Contracts;
using Validation;
/// <summary>
diff --git a/src/DotNetOpenAuth.Core/Messaging/MessageReceivingEndpoint.cs b/src/DotNetOpenAuth.Core/Messaging/MessageReceivingEndpoint.cs
index 808d42b..34be92d 100644
--- a/src/DotNetOpenAuth.Core/Messaging/MessageReceivingEndpoint.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/MessageReceivingEndpoint.cs
@@ -7,7 +7,6 @@
namespace DotNetOpenAuth.Messaging {
using System;
using System.Diagnostics;
- using System.Diagnostics.Contracts;
using Validation;
/// <summary>
diff --git a/src/DotNetOpenAuth.Core/Messaging/MessageSerializer.cs b/src/DotNetOpenAuth.Core/Messaging/MessageSerializer.cs
index 81ae8df..1b30748 100644
--- a/src/DotNetOpenAuth.Core/Messaging/MessageSerializer.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/MessageSerializer.cs
@@ -19,7 +19,6 @@ namespace DotNetOpenAuth.Messaging {
/// <summary>
/// Serializes/deserializes OAuth messages for/from transit.
/// </summary>
- [ContractVerification(true)]
internal class MessageSerializer {
/// <summary>
/// The specific <see cref="IMessage"/>-derived type
@@ -32,10 +31,8 @@ namespace DotNetOpenAuth.Messaging {
/// </summary>
/// <param name="messageType">The specific <see cref="IMessage"/>-derived type
/// that will be serialized and deserialized using this class.</param>
- [ContractVerification(false)] // bugs/limitations in CC static analysis
private MessageSerializer(Type messageType) {
RequiresEx.NotNullSubtype<IMessage>(messageType, "messageType");
- Contract.Ensures(this.messageType != null);
this.messageType = messageType;
}
@@ -44,8 +41,7 @@ namespace DotNetOpenAuth.Messaging {
/// </summary>
/// <param name="messageType">The type of message that will be serialized/deserialized.</param>
/// <returns>A message serializer for the given message type.</returns>
- [ContractVerification(false)] // bugs/limitations in CC static analysis
- internal static MessageSerializer Get(Type messageType) {
+ internal static MessageSerializer Get(Type messageType) {
RequiresEx.NotNullSubtype<IMessage>(messageType, "messageType");
return new MessageSerializer(messageType);
@@ -95,7 +91,7 @@ namespace DotNetOpenAuth.Messaging {
string type = "string";
MessagePart partDescription;
if (messageDictionary.Description.Mapping.TryGetValue(pair.Key, out partDescription)) {
- Contract.Assume(partDescription != null);
+ Assumes.True(partDescription != null);
if (partDescription.IsRequired || partDescription.IsNondefaultValueSet(messageDictionary.Message)) {
include = true;
Type formattingType = partDescription.PreferredFormattingType;
@@ -151,7 +147,6 @@ namespace DotNetOpenAuth.Messaging {
[SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = "Parallel design with Deserialize method.")]
internal IDictionary<string, string> Serialize(MessageDictionary messageDictionary) {
Requires.NotNull(messageDictionary, "messageDictionary");
- Contract.Ensures(Contract.Result<IDictionary<string, string>>() != null);
// Rather than hand back the whole message dictionary (which
// includes keys with blank values), create a new dictionary
@@ -161,7 +156,7 @@ namespace DotNetOpenAuth.Messaging {
foreach (var pair in messageDictionary) {
MessagePart partDescription;
if (messageDictionary.Description.Mapping.TryGetValue(pair.Key, out partDescription)) {
- Contract.Assume(partDescription != null);
+ Assumes.True(partDescription != null);
if (partDescription.IsRequired || partDescription.IsNondefaultValueSet(messageDictionary.Message)) {
result.Add(pair.Key, pair.Value);
}
diff --git a/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs b/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs
index 8abe3d7..fffb855 100644
--- a/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs
@@ -9,7 +9,6 @@ namespace DotNetOpenAuth.Messaging {
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics.CodeAnalysis;
- using System.Diagnostics.Contracts;
using System.Globalization;
using System.IO;
using System.IO.Compression;
@@ -590,7 +589,6 @@ namespace DotNetOpenAuth.Messaging {
/// <returns>A sequence of key=value pairs discovered in the header. Never null, but may be empty.</returns>
internal static IEnumerable<KeyValuePair<string, string>> ParseAuthorizationHeader(string scheme, string authorizationHeader) {
Requires.NotNullOrEmpty(scheme, "scheme");
- Contract.Ensures(Contract.Result<IEnumerable<KeyValuePair<string, string>>>() != null);
string prefix = scheme + " ";
if (authorizationHeader != null) {
@@ -622,7 +620,6 @@ namespace DotNetOpenAuth.Messaging {
internal static string CombineKeyHandleAndPayload(string handle, string payload) {
Requires.NotNullOrEmpty(handle, "handle");
Requires.NotNullOrEmpty(payload, "payload");
- Contract.Ensures(!string.IsNullOrEmpty(Contract.Result<string>()));
return handle + "!" + payload;
}
@@ -718,7 +715,6 @@ namespace DotNetOpenAuth.Messaging {
internal static string ComputeHash(this HashAlgorithm algorithm, string value, Encoding encoding = null) {
Requires.NotNull(algorithm, "algorithm");
Requires.NotNull(value, "value");
- Contract.Ensures(Contract.Result<string>() != null);
encoding = encoding ?? Encoding.UTF8;
byte[] bytesToHash = encoding.GetBytes(value);
@@ -737,7 +733,6 @@ namespace DotNetOpenAuth.Messaging {
internal static string ComputeHash(this HashAlgorithm algorithm, IDictionary<string, string> data, Encoding encoding = null) {
Requires.NotNull(algorithm, "algorithm");
Requires.NotNull(data, "data");
- Contract.Ensures(Contract.Result<string>() != null);
// 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
@@ -758,7 +753,6 @@ namespace DotNetOpenAuth.Messaging {
internal static string ComputeHash(this HashAlgorithm algorithm, IEnumerable<KeyValuePair<string, string>> sortedData, Encoding encoding = null) {
Requires.NotNull(algorithm, "algorithm");
Requires.NotNull(sortedData, "sortedData");
- Contract.Ensures(Contract.Result<string>() != null);
return ComputeHash(algorithm, CreateQueryString(sortedData), encoding);
}
@@ -980,7 +974,6 @@ namespace DotNetOpenAuth.Messaging {
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "No apparent problem. False positive?")]
internal static byte[] Compress(byte[] buffer, CompressionMethod method = CompressionMethod.Deflate) {
Requires.NotNull(buffer, "buffer");
- Contract.Ensures(Contract.Result<byte[]>() != null);
using (var ms = new MemoryStream()) {
Stream compressingStream = null;
@@ -1017,7 +1010,6 @@ namespace DotNetOpenAuth.Messaging {
[SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times", Justification = "This Dispose is safe.")]
internal static byte[] Decompress(byte[] buffer, CompressionMethod method = CompressionMethod.Deflate) {
Requires.NotNull(buffer, "buffer");
- Contract.Ensures(Contract.Result<byte[]>() != null);
using (var compressedDataStream = new MemoryStream(buffer)) {
using (var decompressedDataStream = new MemoryStream()) {
@@ -1071,7 +1063,6 @@ namespace DotNetOpenAuth.Messaging {
/// <returns>A data buffer.</returns>
internal static byte[] FromBase64WebSafeString(string base64WebSafe) {
Requires.NotNullOrEmpty(base64WebSafe, "base64WebSafe");
- Contract.Ensures(Contract.Result<byte[]>() != null);
// Restore the padding characters and original URL-unsafe characters.
int missingPaddingCharacters;
@@ -1435,7 +1426,6 @@ namespace DotNetOpenAuth.Messaging {
/// <returns>The formulated querystring style string.</returns>
internal static string CreateQueryString(IEnumerable<KeyValuePair<string, string>> args) {
Requires.NotNull(args, "args");
- Contract.Ensures(Contract.Result<string>() != null);
if (!args.Any()) {
return string.Empty;
@@ -1639,7 +1629,6 @@ namespace DotNetOpenAuth.Messaging {
/// <c>Dictionary&lt;string, string&gt;</c> does not allow null keys.
/// </remarks>
internal static Dictionary<string, string> ToDictionary(this NameValueCollection nvc) {
- Contract.Ensures((nvc != null && Contract.Result<Dictionary<string, string>>() != null) || (nvc == null && Contract.Result<Dictionary<string, string>>() == null));
return ToDictionary(nvc, false);
}
@@ -1655,7 +1644,6 @@ namespace DotNetOpenAuth.Messaging {
/// <returns>The generated dictionary, or null if <paramref name="nvc"/> is null.</returns>
/// <exception cref="ArgumentException">Thrown if <paramref name="throwOnNullKey"/> is <c>true</c> and a null key is encountered.</exception>
internal static Dictionary<string, string> ToDictionary(this NameValueCollection nvc, bool throwOnNullKey) {
- Contract.Ensures((nvc != null && Contract.Result<Dictionary<string, string>>() != null) || (nvc == null && Contract.Result<Dictionary<string, string>>() == null));
if (nvc == null) {
return null;
}
@@ -1709,7 +1697,6 @@ namespace DotNetOpenAuth.Messaging {
Requires.NotNull(source, "source");
Requires.NotNull(comparer, "comparer");
Requires.NotNull(keySelector, "keySelector");
- Contract.Ensures(Contract.Result<IOrderedEnumerable<TSource>>() != null);
return System.Linq.Enumerable.OrderBy<TSource, TKey>(source, keySelector, new ComparisonHelper<TKey>(comparer));
}
diff --git a/src/DotNetOpenAuth.Core/Messaging/MultipartPostPart.cs b/src/DotNetOpenAuth.Core/Messaging/MultipartPostPart.cs
index 8a175d6..b4a0968 100644
--- a/src/DotNetOpenAuth.Core/Messaging/MultipartPostPart.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/MultipartPostPart.cs
@@ -8,7 +8,6 @@ namespace DotNetOpenAuth.Messaging {
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
- using System.Diagnostics.Contracts;
using System.IO;
using System.Net;
using System.Text;
diff --git a/src/DotNetOpenAuth.Core/Messaging/NetworkDirectWebResponse.cs b/src/DotNetOpenAuth.Core/Messaging/NetworkDirectWebResponse.cs
index 2ad6cfc..754d71d 100644
--- a/src/DotNetOpenAuth.Core/Messaging/NetworkDirectWebResponse.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/NetworkDirectWebResponse.cs
@@ -7,7 +7,6 @@
namespace DotNetOpenAuth.Messaging {
using System;
using System.Diagnostics;
- using System.Diagnostics.Contracts;
using System.IO;
using System.Net;
using System.Text;
@@ -17,7 +16,6 @@ namespace DotNetOpenAuth.Messaging {
/// A live network HTTP response
/// </summary>
[DebuggerDisplay("{Status} {ContentType.MediaType}")]
- [ContractVerification(true)]
internal class NetworkDirectWebResponse : IncomingWebResponse, IDisposable {
/// <summary>
/// The network response object, used to initialize this instance, that still needs
diff --git a/src/DotNetOpenAuth.Core/Messaging/OutgoingWebResponse.cs b/src/DotNetOpenAuth.Core/Messaging/OutgoingWebResponse.cs
index 2e99e4c..be7774f 100644
--- a/src/DotNetOpenAuth.Core/Messaging/OutgoingWebResponse.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/OutgoingWebResponse.cs
@@ -8,7 +8,6 @@ namespace DotNetOpenAuth.Messaging {
using System;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
- using System.Diagnostics.Contracts;
using System.IO;
using System.Net;
using System.Net.Mime;
diff --git a/src/DotNetOpenAuth.Core/Messaging/OutgoingWebResponseActionResult.cs b/src/DotNetOpenAuth.Core/Messaging/OutgoingWebResponseActionResult.cs
index d8bb1a6..bc2f985 100644
--- a/src/DotNetOpenAuth.Core/Messaging/OutgoingWebResponseActionResult.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/OutgoingWebResponseActionResult.cs
@@ -6,7 +6,6 @@
namespace DotNetOpenAuth.Messaging {
using System;
- using System.Diagnostics.Contracts;
using System.Web.Mvc;
using DotNetOpenAuth.Messaging;
using Validation;
diff --git a/src/DotNetOpenAuth.Core/Messaging/ProtocolException.cs b/src/DotNetOpenAuth.Core/Messaging/ProtocolException.cs
index 982e1c0..4bc3590 100644
--- a/src/DotNetOpenAuth.Core/Messaging/ProtocolException.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/ProtocolException.cs
@@ -7,7 +7,6 @@
namespace DotNetOpenAuth.Messaging {
using System;
using System.Collections.Generic;
- using System.Diagnostics.Contracts;
using System.Security;
using System.Security.Permissions;
diff --git a/src/DotNetOpenAuth.Core/Messaging/Reflection/IMessagePartEncoder.cs b/src/DotNetOpenAuth.Core/Messaging/Reflection/IMessagePartEncoder.cs
index 98c9cce..017c7d7 100644
--- a/src/DotNetOpenAuth.Core/Messaging/Reflection/IMessagePartEncoder.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/Reflection/IMessagePartEncoder.cs
@@ -7,7 +7,6 @@
namespace DotNetOpenAuth.Messaging.Reflection {
using System;
using System.Collections.Generic;
- using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using Validation;
@@ -18,7 +17,6 @@ namespace DotNetOpenAuth.Messaging.Reflection {
/// <remarks>
/// Implementations of this interface must include a default constructor and must be thread-safe.
/// </remarks>
- [ContractClass(typeof(IMessagePartEncoderContract))]
public interface IMessagePartEncoder {
/// <summary>
/// Encodes the specified value.
@@ -35,45 +33,4 @@ namespace DotNetOpenAuth.Messaging.Reflection {
/// <exception cref="FormatException">Thrown when the string value given cannot be decoded into the required object type.</exception>
object Decode(string value);
}
-
- /// <summary>
- /// Code contract for the <see cref="IMessagePartEncoder"/> type.
- /// </summary>
- [ContractClassFor(typeof(IMessagePartEncoder))]
- internal abstract class IMessagePartEncoderContract : IMessagePartEncoder {
- /// <summary>
- /// Initializes a new instance of the <see cref="IMessagePartEncoderContract"/> class.
- /// </summary>
- protected IMessagePartEncoderContract() {
- }
-
- #region IMessagePartEncoder Members
-
- /// <summary>
- /// Encodes the specified value.
- /// </summary>
- /// <param name="value">The value. Guaranteed to never be null.</param>
- /// <returns>
- /// The <paramref name="value"/> in string form, ready for message transport.
- /// </returns>
- string IMessagePartEncoder.Encode(object value) {
- Requires.NotNull(value, "value");
- throw new NotImplementedException();
- }
-
- /// <summary>
- /// Decodes the specified value.
- /// </summary>
- /// <param name="value">The string value carried by the transport. Guaranteed to never be null, although it may be empty.</param>
- /// <returns>
- /// The deserialized form of the given string.
- /// </returns>
- /// <exception cref="FormatException">Thrown when the string value given cannot be decoded into the required object type.</exception>
- object IMessagePartEncoder.Decode(string value) {
- Requires.NotNull(value, "value");
- throw new NotImplementedException();
- }
-
- #endregion
- }
}
diff --git a/src/DotNetOpenAuth.Core/Messaging/Reflection/MessageDescription.cs b/src/DotNetOpenAuth.Core/Messaging/Reflection/MessageDescription.cs
index 8a34be6..cd04e1d 100644
--- a/src/DotNetOpenAuth.Core/Messaging/Reflection/MessageDescription.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/Reflection/MessageDescription.cs
@@ -81,7 +81,6 @@ namespace DotNetOpenAuth.Messaging.Reflection {
[Pure]
internal MessageDictionary GetDictionary(IMessage message) {
Requires.NotNull(message, "message");
- Contract.Ensures(Contract.Result<MessageDictionary>() != null);
return this.GetDictionary(message, false);
}
@@ -94,7 +93,6 @@ namespace DotNetOpenAuth.Messaging.Reflection {
[Pure]
internal MessageDictionary GetDictionary(IMessage message, bool getOriginalValues) {
Requires.NotNull(message, "message");
- Contract.Ensures(Contract.Result<MessageDictionary>() != null);
return new MessageDictionary(message, this, getOriginalValues);
}
diff --git a/src/DotNetOpenAuth.Core/Messaging/Reflection/MessageDescriptionCollection.cs b/src/DotNetOpenAuth.Core/Messaging/Reflection/MessageDescriptionCollection.cs
index e3d612e..f27a7af 100644
--- a/src/DotNetOpenAuth.Core/Messaging/Reflection/MessageDescriptionCollection.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/Reflection/MessageDescriptionCollection.cs
@@ -15,7 +15,6 @@ namespace DotNetOpenAuth.Messaging.Reflection {
/// <summary>
/// A cache of <see cref="MessageDescription"/> instances.
/// </summary>
- [ContractVerification(true)]
internal class MessageDescriptionCollection : IEnumerable<MessageDescription> {
/// <summary>
/// A dictionary of reflected message types and the generated reflection information.
@@ -71,7 +70,6 @@ namespace DotNetOpenAuth.Messaging.Reflection {
internal MessageDescription Get(Type messageType, Version messageVersion) {
RequiresEx.NotNullSubtype<IMessage>(messageType, "messageType");
Requires.NotNull(messageVersion, "messageVersion");
- Contract.Ensures(Contract.Result<MessageDescription>() != null);
MessageTypeAndVersion key = new MessageTypeAndVersion(messageType, messageVersion);
@@ -107,7 +105,6 @@ namespace DotNetOpenAuth.Messaging.Reflection {
[Pure]
internal MessageDescription Get(IMessage message) {
Requires.NotNull(message, "message");
- Contract.Ensures(Contract.Result<MessageDescription>() != null);
return this.Get(message.GetType(), message.Version);
}
@@ -137,8 +134,7 @@ namespace DotNetOpenAuth.Messaging.Reflection {
/// <summary>
/// A struct used as the key to bundle message type and version.
/// </summary>
- [ContractVerification(true)]
- private struct MessageTypeAndVersion {
+ private struct MessageTypeAndVersion {
/// <summary>
/// Backing store for the <see cref="Type"/> property.
/// </summary>
diff --git a/src/DotNetOpenAuth.Core/Messaging/Reflection/MessageDictionary.cs b/src/DotNetOpenAuth.Core/Messaging/Reflection/MessageDictionary.cs
index c3e6f65..a2dddb2 100644
--- a/src/DotNetOpenAuth.Core/Messaging/Reflection/MessageDictionary.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/Reflection/MessageDictionary.cs
@@ -18,7 +18,6 @@ namespace DotNetOpenAuth.Messaging.Reflection {
/// provides access to both well-defined message properties and "extra"
/// name/value pairs that have no properties associated with them.
/// </summary>
- [ContractVerification(false)]
internal class MessageDictionary : IDictionary<string, string> {
/// <summary>
/// The <see cref="IMessage"/> instance manipulated by this dictionary.
@@ -56,7 +55,6 @@ namespace DotNetOpenAuth.Messaging.Reflection {
/// </summary>
public IMessage Message {
get {
- Contract.Ensures(Contract.Result<IMessage>() != null);
return this.message;
}
}
@@ -66,7 +64,6 @@ namespace DotNetOpenAuth.Messaging.Reflection {
/// </summary>
public MessageDescription Description {
get {
- Contract.Ensures(Contract.Result<MessageDescription>() != null);
return this.description;
}
}
@@ -381,7 +378,6 @@ namespace DotNetOpenAuth.Messaging.Reflection {
/// <returns>The generated dictionary.</returns>
[Pure]
public IDictionary<string, string> Serialize() {
- Contract.Ensures(Contract.Result<IDictionary<string, string>>() != null);
return this.Serializer.Serialize(this);
}
diff --git a/src/DotNetOpenAuth.Core/Messaging/Reflection/MessagePart.cs b/src/DotNetOpenAuth.Core/Messaging/Reflection/MessagePart.cs
index 6c9aef3..add4beb 100644
--- a/src/DotNetOpenAuth.Core/Messaging/Reflection/MessagePart.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/Reflection/MessagePart.cs
@@ -9,7 +9,6 @@ namespace DotNetOpenAuth.Messaging.Reflection {
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
- using System.Diagnostics.Contracts;
using System.Globalization;
using System.Linq;
using System.Net.Security;
@@ -21,7 +20,6 @@ namespace DotNetOpenAuth.Messaging.Reflection {
/// <summary>
/// Describes an individual member of a message and assists in its serialization.
/// </summary>
- [ContractVerification(true)]
[DebuggerDisplay("MessagePart {Name}")]
internal class MessagePart {
/// <summary>
@@ -67,20 +65,20 @@ namespace DotNetOpenAuth.Messaging.Reflection {
[SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline", Justification = "Much more efficient initialization when we can call methods.")]
static MessagePart() {
Func<string, Uri> safeUri = str => {
- Contract.Assume(str != null);
+ Assumes.True(str != null);
return new Uri(str);
};
Func<string, bool> safeBool = str => {
- Contract.Assume(str != null);
+ Assumes.True(str != null);
return bool.Parse(str);
};
Func<byte[], string> safeFromByteArray = bytes => {
- Contract.Assume(bytes != null);
+ Assumes.True(bytes != null);
return Convert.ToBase64String(bytes);
};
Func<string, byte[]> safeToByteArray = str => {
- Contract.Assume(str != null);
+ Assumes.True(str != null);
return Convert.FromBase64String(str);
};
Map<Uri>(uri => uri.AbsoluteUri, uri => uri.OriginalString, safeUri);
@@ -120,7 +118,7 @@ namespace DotNetOpenAuth.Messaging.Reflection {
this.memberDeclaredType = (this.field != null) ? this.field.FieldType : this.property.PropertyType;
this.defaultMemberValue = DeriveDefaultValue(this.memberDeclaredType);
- Contract.Assume(this.memberDeclaredType != null); // CC missing PropertyInfo.PropertyType ensures result != null
+ Assumes.True(this.memberDeclaredType != null); // CC missing PropertyInfo.PropertyType ensures result != null
if (attribute.Encoder == null) {
if (!converters.TryGetValue(this.memberDeclaredType, out this.converter)) {
if (this.memberDeclaredType.IsGenericType &&
@@ -395,7 +393,6 @@ namespace DotNetOpenAuth.Messaging.Reflection {
/// <returns>An instance of the desired encoder.</returns>
private static IMessagePartEncoder GetEncoder(Type messagePartEncoder) {
Requires.NotNull(messagePartEncoder, "messagePartEncoder");
- Contract.Ensures(Contract.Result<IMessagePartEncoder>() != null);
IMessagePartEncoder encoder;
lock (encoders) {
diff --git a/src/DotNetOpenAuth.Core/Messaging/Reflection/ValueMapping.cs b/src/DotNetOpenAuth.Core/Messaging/Reflection/ValueMapping.cs
index 7acff7e..c45eb5d 100644
--- a/src/DotNetOpenAuth.Core/Messaging/Reflection/ValueMapping.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/Reflection/ValueMapping.cs
@@ -6,13 +6,11 @@
namespace DotNetOpenAuth.Messaging.Reflection {
using System;
- using System.Diagnostics.Contracts;
using Validation;
/// <summary>
/// A pair of conversion functions to map some type to a string and back again.
/// </summary>
- [ContractVerification(true)]
internal struct ValueMapping {
/// <summary>
/// The mapping function that converts some custom type to a string.
diff --git a/src/DotNetOpenAuth.Core/Messaging/StandardMessageFactory.cs b/src/DotNetOpenAuth.Core/Messaging/StandardMessageFactory.cs
index 37ab864..fd35e5f 100644
--- a/src/DotNetOpenAuth.Core/Messaging/StandardMessageFactory.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/StandardMessageFactory.cs
@@ -7,7 +7,6 @@
namespace DotNetOpenAuth.Messaging {
using System;
using System.Collections.Generic;
- using System.Diagnostics.Contracts;
using System.Linq;
using System.Reflection;
using System.Text;
@@ -209,7 +208,6 @@ namespace DotNetOpenAuth.Messaging {
protected virtual IDirectedProtocolMessage InstantiateAsRequest(MessageDescription messageDescription, MessageReceivingEndpoint recipient) {
Requires.NotNull(messageDescription, "messageDescription");
Requires.NotNull(recipient, "recipient");
- Contract.Ensures(Contract.Result<IDirectedProtocolMessage>() != null);
ConstructorInfo ctor = this.requestMessageTypes[messageDescription];
return (IDirectedProtocolMessage)ctor.Invoke(new object[] { recipient.Location, messageDescription.MessageVersion });
@@ -224,7 +222,6 @@ namespace DotNetOpenAuth.Messaging {
protected virtual IDirectResponseProtocolMessage InstantiateAsResponse(MessageDescription messageDescription, IDirectedProtocolMessage request) {
Requires.NotNull(messageDescription, "messageDescription");
Requires.NotNull(request, "request");
- Contract.Ensures(Contract.Result<IDirectResponseProtocolMessage>() != null);
Type requestType = request.GetType();
var ctors = this.FindMatchingResponseConstructors(messageDescription, requestType);
@@ -278,7 +275,6 @@ namespace DotNetOpenAuth.Messaging {
private static int CountInCommon(ICollection<string> collection1, ICollection<string> collection2, StringComparison comparison = StringComparison.Ordinal) {
Requires.NotNull(collection1, "collection1");
Requires.NotNull(collection2, "collection2");
- Contract.Ensures(Contract.Result<int>() >= 0 && Contract.Result<int>() <= Math.Min(collection1.Count, collection2.Count));
return collection1.Count(value1 => collection2.Any(value2 => string.Equals(value1, value2, comparison)));
}
diff --git a/src/DotNetOpenAuth.Core/Messaging/StandardMessageFactoryChannel.cs b/src/DotNetOpenAuth.Core/Messaging/StandardMessageFactoryChannel.cs
index 2c9f0ce..9cb80b0 100644
--- a/src/DotNetOpenAuth.Core/Messaging/StandardMessageFactoryChannel.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/StandardMessageFactoryChannel.cs
@@ -7,7 +7,6 @@
namespace DotNetOpenAuth.Messaging {
using System;
using System.Collections.Generic;
- using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using Reflection;
@@ -99,7 +98,6 @@ namespace DotNetOpenAuth.Messaging {
{
Requires.NotNull(messageTypes, "messageTypes");
Requires.NotNull(descriptionsCache, "descriptionsCache");
- Contract.Ensures(Contract.Result<IEnumerable<MessageDescription>>() != null);
// Get all the MessageDescription objects through the standard cache,
// so that perhaps it will be a quick lookup, or at least it will be
diff --git a/src/DotNetOpenAuth.Core/Messaging/UriStyleMessageFormatter.cs b/src/DotNetOpenAuth.Core/Messaging/UriStyleMessageFormatter.cs
index b5ae6bc..1d7c424 100644
--- a/src/DotNetOpenAuth.Core/Messaging/UriStyleMessageFormatter.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/UriStyleMessageFormatter.cs
@@ -7,7 +7,6 @@
namespace DotNetOpenAuth.Messaging {
using System;
using System.Collections.Generic;
- using System.Diagnostics.Contracts;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
diff --git a/src/DotNetOpenAuth.Core/Properties/AssemblyInfo.cs b/src/DotNetOpenAuth.Core/Properties/AssemblyInfo.cs
index 21cbb94..7f8a591 100644
--- a/src/DotNetOpenAuth.Core/Properties/AssemblyInfo.cs
+++ b/src/DotNetOpenAuth.Core/Properties/AssemblyInfo.cs
@@ -7,7 +7,6 @@
// We DON'T put an AssemblyVersionAttribute in here because it is generated in the build.
using System;
-using System.Diagnostics.Contracts;
using System.Net;
using System.Reflection;
using System.Resources;
@@ -31,8 +30,6 @@ using System.Web.UI;
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("7d73990c-47c0-4256-9f20-a893add9e289")]
-[assembly: ContractVerification(true)]
-
#if StrongNameSigned
// See comment at top of this file. We need this so that strong-naming doesn't
// keep this assembly from being useful to shared host (medium trust) web sites.
diff --git a/src/DotNetOpenAuth.Core/PureAttribute.cs b/src/DotNetOpenAuth.Core/PureAttribute.cs
new file mode 100644
index 0000000..04f7ead
--- /dev/null
+++ b/src/DotNetOpenAuth.Core/PureAttribute.cs
@@ -0,0 +1,22 @@
+//-----------------------------------------------------------------------
+// <copyright file="PureAttribute.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace System.Diagnostics.Contracts {
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Text;
+
+#if !CLR4
+ /// <summary>
+ /// Designates a type or member as one that does not mutate any objects that were allocated
+ /// before the invocation of the member.
+ /// </summary>
+ [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = false)]
+ internal sealed class PureAttribute : Attribute {
+ }
+#endif
+}
diff --git a/src/DotNetOpenAuth.Core/Reporting.cs b/src/DotNetOpenAuth.Core/Reporting.cs
index dc8482f..f902fd6 100644
--- a/src/DotNetOpenAuth.Core/Reporting.cs
+++ b/src/DotNetOpenAuth.Core/Reporting.cs
@@ -9,7 +9,6 @@ namespace DotNetOpenAuth {
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
- using System.Diagnostics.Contracts;
using System.Globalization;
using System.IO;
using System.IO.IsolatedStorage;
@@ -535,8 +534,6 @@ namespace DotNetOpenAuth {
/// </summary>
/// <returns>An isolated storage location appropriate for our host.</returns>
private static IsolatedStorageFile GetIsolatedStorage() {
- Contract.Ensures(Contract.Result<IsolatedStorageFile>() != null);
-
IsolatedStorageFile result = null;
// We'll try for whatever storage location we can get,
@@ -569,7 +566,6 @@ namespace DotNetOpenAuth {
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "No apparent problem. False positive?")]
private static Guid GetOrCreateOriginIdentity() {
RequiresEx.ValidState(file != null, "file not set.");
- Contract.Ensures(Contract.Result<Guid>() != Guid.Empty);
Guid identityGuid = Guid.Empty;
const int GuidLength = 16;
diff --git a/src/DotNetOpenAuth.Core/RequiresEx.cs b/src/DotNetOpenAuth.Core/RequiresEx.cs
index 8779b2f..1a077c4 100644
--- a/src/DotNetOpenAuth.Core/RequiresEx.cs
+++ b/src/DotNetOpenAuth.Core/RequiresEx.cs
@@ -23,16 +23,11 @@ namespace DotNetOpenAuth {
/// Validates some expression describing the acceptable condition for an argument evaluates to true.
/// </summary>
/// <param name="condition">The expression that must evaluate to true to avoid an <see cref="InvalidOperationException"/>.</param>
-#if !CLR4
- [ContractArgumentValidator]
-#endif
[Pure, DebuggerStepThrough]
internal static void ValidState(bool condition) {
if (!condition) {
throw new InvalidOperationException();
}
-
- Contract.EndContractBlock();
}
/// <summary>
@@ -40,16 +35,11 @@ namespace DotNetOpenAuth {
/// </summary>
/// <param name="condition">The expression that must evaluate to true to avoid an <see cref="InvalidOperationException"/>.</param>
/// <param name="message">The message to include with the exception.</param>
-#if !CLR4
- [ContractArgumentValidator]
-#endif
[Pure, DebuggerStepThrough]
internal static void ValidState(bool condition, string message) {
if (!condition) {
throw new InvalidOperationException(message);
}
-
- Contract.EndContractBlock();
}
/// <summary>
@@ -58,16 +48,11 @@ namespace DotNetOpenAuth {
/// <param name="condition">The expression that must evaluate to true to avoid an <see cref="InvalidOperationException"/>.</param>
/// <param name="unformattedMessage">The unformatted message.</param>
/// <param name="args">Formatting arguments.</param>
-#if !CLR4
- [ContractArgumentValidator]
-#endif
[Pure, DebuggerStepThrough]
internal static void ValidState(bool condition, string unformattedMessage, params object[] args) {
if (!condition) {
throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, unformattedMessage, args));
}
-
- Contract.EndContractBlock();
}
/// <summary>
@@ -76,15 +61,10 @@ namespace DotNetOpenAuth {
/// <typeparam name="T">The type that the argument must be or derive from.</typeparam>
/// <param name="type">The type given in the argument.</param>
/// <param name="parameterName">Name of the parameter.</param>
-#if !CLR4
- [ContractArgumentValidator]
-#endif
[Pure, DebuggerStepThrough]
internal static void NotNullSubtype<T>(Type type, string parameterName) {
Requires.NotNull(type, parameterName);
Requires.That(typeof(T).IsAssignableFrom(type), parameterName, MessagingStrings.UnexpectedType, typeof(T).FullName, type.FullName);
-
- Contract.EndContractBlock();
}
/// <summary>
@@ -92,16 +72,11 @@ namespace DotNetOpenAuth {
/// </summary>
/// <param name="condition">The expression that must evaluate to true to avoid an <see cref="FormatException"/>.</param>
/// <param name="message">The message.</param>
-#if !CLR4
- [ContractArgumentValidator]
-#endif
[Pure, DebuggerStepThrough]
internal static void Format(bool condition, string message) {
if (!condition) {
throw new FormatException(message);
}
-
- Contract.EndContractBlock();
}
/// <summary>
diff --git a/src/DotNetOpenAuth.Core/UriUtil.cs b/src/DotNetOpenAuth.Core/UriUtil.cs
index 824ab6b..25b92a2 100644
--- a/src/DotNetOpenAuth.Core/UriUtil.cs
+++ b/src/DotNetOpenAuth.Core/UriUtil.cs
@@ -8,7 +8,6 @@ namespace DotNetOpenAuth {
using System;
using System.Collections.Specialized;
using System.Diagnostics.CodeAnalysis;
- using System.Diagnostics.Contracts;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
@@ -19,7 +18,6 @@ namespace DotNetOpenAuth {
/// <summary>
/// Utility methods for working with URIs.
/// </summary>
- [ContractVerification(true)]
internal static class UriUtil {
/// <summary>
/// Tests a URI for the presence of an OAuth payload.
@@ -29,15 +27,14 @@ namespace DotNetOpenAuth {
/// <returns>
/// True if the URI contains an OAuth message.
/// </returns>
- [ContractVerification(false)] // bugs/limitations in CC static analysis
- internal static bool QueryStringContainPrefixedParameters(this Uri uri, string prefix) {
+ internal static bool QueryStringContainPrefixedParameters(this Uri uri, string prefix) {
Requires.NotNullOrEmpty(prefix, "prefix");
if (uri == null) {
return false;
}
NameValueCollection nvc = HttpUtility.ParseQueryString(uri.Query);
- Contract.Assume(nvc != null); // BCL
+ Assumes.True(nvc != null); // BCL
return nvc.Keys.OfType<string>().Any(key => key.StartsWith(prefix, StringComparison.Ordinal));
}
@@ -61,7 +58,6 @@ namespace DotNetOpenAuth {
/// <returns>The string version of the Uri.</returns>
internal static string ToStringWithImpliedPorts(this UriBuilder builder) {
Requires.NotNull(builder, "builder");
- Contract.Ensures(Contract.Result<string>() != null);
// We only check for implied ports on HTTP and HTTPS schemes since those
// are the only ones supported by OpenID anyway.
@@ -74,7 +70,7 @@ namespace DotNetOpenAuth {
// we're removing only the port (and not something in the query string that
// looks like a port.
string result = Regex.Replace(url, @"^(https?://[^:]+):\d+", m => m.Groups[1].Value, RegexOptions.IgnoreCase);
- Contract.Assume(result != null); // Regex.Replace never returns null
+ Assumes.True(result != null); // Regex.Replace never returns null
return result;
} else {
// The port must be explicitly given anyway.
@@ -96,12 +92,12 @@ namespace DotNetOpenAuth {
}
if (page != null && !designMode) {
- Contract.Assume(page.Request != null);
+ Assumes.True(page.Request != null);
// Validate new value by trying to construct a Realm object based on it.
string relativeUrl = page.ResolveUrl(value);
- Contract.Assume(page.Request.Url != null);
- Contract.Assume(relativeUrl != null);
+ Assumes.True(page.Request.Url != null);
+ Assumes.True(relativeUrl != null);
new Uri(page.Request.Url, relativeUrl); // throws an exception on failure.
} else {
// We can't fully test it, but it should start with either ~/ or a protocol.
diff --git a/src/DotNetOpenAuth.Core/Util.cs b/src/DotNetOpenAuth.Core/Util.cs
index fc293d2..ec28c50 100644
--- a/src/DotNetOpenAuth.Core/Util.cs
+++ b/src/DotNetOpenAuth.Core/Util.cs
@@ -6,7 +6,6 @@
namespace DotNetOpenAuth {
using System;
using System.Collections.Generic;
- using System.Diagnostics.Contracts;
using System.Globalization;
using System.Net;
using System.Reflection;
@@ -22,7 +21,6 @@ namespace DotNetOpenAuth {
/// <summary>
/// A grab-bag utility class.
/// </summary>
- [ContractVerification(true)]
internal static class Util {
/// <summary>
/// The base namespace for this library from which all other namespaces derive.
@@ -139,7 +137,6 @@ namespace DotNetOpenAuth {
/// <param name="list">The list of elements.</param>
/// <param name="multiLineElements">if set to <c>true</c>, special formatting will be applied to the output to make it clear where one element ends and the next begins.</param>
/// <returns>An object whose ToString method will perform the actual work of generating the string.</returns>
- [ContractVerification(false)]
internal static object ToStringDeferred<T>(this IEnumerable<T> list, bool multiLineElements) {
return new DelayedToString<IEnumerable<T>>(
list,
@@ -148,7 +145,7 @@ namespace DotNetOpenAuth {
ErrorUtilities.VerifyArgumentNotNull(l, "l");
string newLine = Environment.NewLine;
- ////Contract.Assume(newLine != null && newLine.Length > 0);
+ ////Assumes.True(newLine != null && newLine.Length > 0);
StringBuilder sb = new StringBuilder();
if (multiLineElements) {
sb.AppendLine("[{");