summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2009-05-18 19:37:19 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2009-05-18 19:37:19 -0700
commit203faf9106a55cc96b778fa65e8bc32b22a41fc4 (patch)
treee87817f696dd03850412e4ef5311d8a12040fcd5
parentc5760d00e60436f86ea225db937ca37c553a11c9 (diff)
downloadDotNetOpenAuth-203faf9106a55cc96b778fa65e8bc32b22a41fc4.zip
DotNetOpenAuth-203faf9106a55cc96b778fa65e8bc32b22a41fc4.tar.gz
DotNetOpenAuth-203faf9106a55cc96b778fa65e8bc32b22a41fc4.tar.bz2
FxCop and CC fixes.
-rw-r--r--src/DotNetOpenAuth/InfoCard/Token/Token.cs5
-rw-r--r--src/DotNetOpenAuth/Messaging/ErrorUtilities.cs3
-rw-r--r--src/DotNetOpenAuth/Messaging/Reflection/MessageDescriptionCollection.cs3
-rw-r--r--src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationRequest.cs7
-rw-r--r--src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingParty.cs13
-rw-r--r--src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdTextBox.cs1
6 files changed, 29 insertions, 3 deletions
diff --git a/src/DotNetOpenAuth/InfoCard/Token/Token.cs b/src/DotNetOpenAuth/InfoCard/Token/Token.cs
index f07c555..5c955ed 100644
--- a/src/DotNetOpenAuth/InfoCard/Token/Token.cs
+++ b/src/DotNetOpenAuth/InfoCard/Token/Token.cs
@@ -107,8 +107,9 @@ namespace DotNetOpenAuth.InfoCard {
public string SiteSpecificId {
get {
Contract.Requires(this.Claims.ContainsKey(ClaimTypes.PPID));
- ErrorUtilities.VerifyOperation(this.Claims.ContainsKey(ClaimTypes.PPID), InfoCardStrings.PpidClaimRequired);
- return TokenUtility.CalculateSiteSpecificID(this.Claims[ClaimTypes.PPID]);
+ string ppidValue;
+ ErrorUtilities.VerifyOperation(this.Claims.TryGetValue(ClaimTypes.PPID, out ppidValue) && ppidValue != null, InfoCardStrings.PpidClaimRequired);
+ return TokenUtility.CalculateSiteSpecificID(ppidValue);
}
}
diff --git a/src/DotNetOpenAuth/Messaging/ErrorUtilities.cs b/src/DotNetOpenAuth/Messaging/ErrorUtilities.cs
index 1c27d6c..d5b2040 100644
--- a/src/DotNetOpenAuth/Messaging/ErrorUtilities.cs
+++ b/src/DotNetOpenAuth/Messaging/ErrorUtilities.cs
@@ -379,7 +379,10 @@ namespace DotNetOpenAuth.Messaging {
[Pure]
internal static void VerifyHttpContext() {
Contract.Ensures(HttpContext.Current != null);
+ Contract.Ensures(HttpContext.Current.Request != null);
+
ErrorUtilities.VerifyOperation(HttpContext.Current != null, MessagingStrings.HttpContextRequired);
+ ErrorUtilities.VerifyOperation(HttpContext.Current.Request != null, MessagingStrings.HttpContextRequired);
}
}
}
diff --git a/src/DotNetOpenAuth/Messaging/Reflection/MessageDescriptionCollection.cs b/src/DotNetOpenAuth/Messaging/Reflection/MessageDescriptionCollection.cs
index 7ac21f2..3b2f7c5 100644
--- a/src/DotNetOpenAuth/Messaging/Reflection/MessageDescriptionCollection.cs
+++ b/src/DotNetOpenAuth/Messaging/Reflection/MessageDescriptionCollection.cs
@@ -45,11 +45,12 @@ namespace DotNetOpenAuth.Messaging.Reflection {
if (!this.reflectedMessageTypes.TryGetValue(key, out result)) {
lock (this.reflectedMessageTypes) {
if (!this.reflectedMessageTypes.TryGetValue(key, out result)) {
- this.reflectedMessageTypes[key] = result = new MessageDescription(key.Type, key.Version);
+ this.reflectedMessageTypes[key] = result = new MessageDescription(messageType, messageVersion);
}
}
}
+ Contract.Assume(result != null, "We should never assign null values to this dictionary.");
return result;
}
diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationRequest.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationRequest.cs
index b1b2a48..753425a 100644
--- a/src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationRequest.cs
+++ b/src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationRequest.cs
@@ -237,6 +237,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
Contract.Requires(userSuppliedIdentifier != null);
Contract.Requires(relyingParty != null);
Contract.Requires(realm != null);
+ Contract.Ensures(Contract.Result<IEnumerable<AuthenticationRequest>>() != null);
// We have a long data validation and preparation process
ErrorUtilities.VerifyArgumentNotNull(userSuppliedIdentifier, "userSuppliedIdentifier");
@@ -304,6 +305,12 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// before calling this method.
/// </remarks>
private static IEnumerable<AuthenticationRequest> CreateInternal(Identifier userSuppliedIdentifier, OpenIdRelyingParty relyingParty, Realm realm, Uri returnToUrl, IEnumerable<ServiceEndpoint> serviceEndpoints, bool createNewAssociationsAsNeeded) {
+ Contract.Requires(userSuppliedIdentifier != null);
+ Contract.Requires(relyingParty != null);
+ Contract.Requires(realm != null);
+ Contract.Requires(serviceEndpoints != null);
+ Contract.Ensures(Contract.Result<IEnumerable<AuthenticationRequest>>() != null);
+
Logger.Yadis.InfoFormat("Performing discovery on user-supplied identifier: {0}", userSuppliedIdentifier);
IEnumerable<ServiceEndpoint> endpoints = FilterAndSortEndpoints(serviceEndpoints, relyingParty);
diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingParty.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingParty.cs
index 7b9452e..042dfcd 100644
--- a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingParty.cs
+++ b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingParty.cs
@@ -9,6 +9,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
+ using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Web;
@@ -526,6 +527,18 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
return this.CreateRequests(userSuppliedIdentifier, new Realm(realmUrl.Uri));
}
+#if CONTRACTS_FULL
+ /// <summary>
+ /// Verifies conditions that should be true for any valid state of this object.
+ /// </summary>
+ [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Called by code contracts.")]
+ [ContractInvariantMethod]
+ private void ObjectInvariant() {
+ Contract.Invariant(this.SecuritySettings != null);
+ Contract.Invariant(this.Channel != null);
+ }
+#endif
+
/// <summary>
/// Releases unmanaged and - optionally - managed resources
/// </summary>
diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdTextBox.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdTextBox.cs
index a895649..2a49b5a 100644
--- a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdTextBox.cs
+++ b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdTextBox.cs
@@ -970,6 +970,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// <summary>
/// Enables a server control to perform final clean up before it is released from memory.
/// </summary>
+ [SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly", MessageId = "Base class doesn't implement virtual Dispose(bool), so we must call its Dispose() method.")]
public sealed override void Dispose() {
this.Dispose(true);
base.Dispose();