summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Core/Messaging/MessageSerializer.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2012-12-26 20:22:14 -0800
committerAndrew Arnott <andrewarnott@gmail.com>2012-12-26 20:22:14 -0800
commit391397a341282d0c088bc9e9901ced9b19a62e5a (patch)
treebc1cc264acba9edc486eefbbfbb5fd4822111fb1 /src/DotNetOpenAuth.Core/Messaging/MessageSerializer.cs
parent8f48e3f1daedb77e451f9fe8ac497741c6bb06f9 (diff)
parent3475fab579db0f6a1454ebc83d2e8a9c271e4c18 (diff)
downloadDotNetOpenAuth-391397a341282d0c088bc9e9901ced9b19a62e5a.zip
DotNetOpenAuth-391397a341282d0c088bc9e9901ced9b19a62e5a.tar.gz
DotNetOpenAuth-391397a341282d0c088bc9e9901ced9b19a62e5a.tar.bz2
Merge branch 'retargeting-contracts'
Diffstat (limited to 'src/DotNetOpenAuth.Core/Messaging/MessageSerializer.cs')
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/MessageSerializer.cs16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/DotNetOpenAuth.Core/Messaging/MessageSerializer.cs b/src/DotNetOpenAuth.Core/Messaging/MessageSerializer.cs
index 7391867..1b30748 100644
--- a/src/DotNetOpenAuth.Core/Messaging/MessageSerializer.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/MessageSerializer.cs
@@ -14,11 +14,11 @@ namespace DotNetOpenAuth.Messaging {
using System.Reflection;
using System.Xml;
using DotNetOpenAuth.Messaging.Reflection;
+ using Validation;
/// <summary>
/// Serializes/deserializes OAuth messages for/from transit.
/// </summary>
- [ContractVerification(true)]
internal class MessageSerializer {
/// <summary>
/// The specific <see cref="IMessage"/>-derived type
@@ -31,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) {
- Requires.NotNullSubtype<IMessage>(messageType, "messageType");
- Contract.Ensures(this.messageType != null);
+ RequiresEx.NotNullSubtype<IMessage>(messageType, "messageType");
this.messageType = messageType;
}
@@ -43,9 +41,8 @@ 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) {
- Requires.NotNullSubtype<IMessage>(messageType, "messageType");
+ internal static MessageSerializer Get(Type messageType) {
+ RequiresEx.NotNullSubtype<IMessage>(messageType, "messageType");
return new MessageSerializer(messageType);
}
@@ -94,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;
@@ -150,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
@@ -160,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);
}