summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Core/Messaging/Reflection
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOpenAuth.Core/Messaging/Reflection')
-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
6 files changed, 6 insertions, 64 deletions
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.