diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2013-04-13 22:27:54 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2013-04-13 22:27:54 -0700 |
commit | fd3084dd35f7f6ae546d7b1e63ce5a960811fdd0 (patch) | |
tree | e42fb8ce017afd905a5e373c13ae0214372bf513 | |
parent | 1be87916ca66b4b847c86ae38f07637847fc01bd (diff) | |
download | DotNetOpenAuth-origin/DNOA.Messaging.Portable.zip DotNetOpenAuth-origin/DNOA.Messaging.Portable.tar.gz DotNetOpenAuth-origin/DNOA.Messaging.Portable.tar.bz2 |
Compiler warning fixes.origin/DNOA.Messaging.Portable
11 files changed, 103 insertions, 47 deletions
diff --git a/src/DotNetOpenAuth.Core.Portable/Messaging/Bindings/INonceStore.cs b/src/DotNetOpenAuth.Core.Portable/Messaging/Bindings/INonceStore.cs index 3ce521d..ed3d145 100644 --- a/src/DotNetOpenAuth.Core.Portable/Messaging/Bindings/INonceStore.cs +++ b/src/DotNetOpenAuth.Core.Portable/Messaging/Bindings/INonceStore.cs @@ -30,8 +30,7 @@ namespace DotNetOpenAuth.Messaging.Bindings { /// The nonce must be stored for no less than the maximum time window a message may /// be processed within before being discarded as an expired message. /// This maximum message age can be looked up via the - /// <see cref="DotNetOpenAuth.Configuration.MessagingElement.MaximumMessageLifetime"/> - /// property, accessible via the <see cref="DotNetOpenAuth.Configuration.MessagingElement.Configuration"/> + /// <see cref="ChannelBase.MaximumMessageLifetime"/> /// property. /// </remarks> bool StoreNonce(string context, string nonce, DateTime timestampUtc); diff --git a/src/DotNetOpenAuth.Core.Portable/Messaging/Bindings/MemoryCryptoKeyAndNonceStore.cs b/src/DotNetOpenAuth.Core.Portable/Messaging/Bindings/MemoryCryptoKeyAndNonceStore.cs index f486c72..d2c1889 100644 --- a/src/DotNetOpenAuth.Core.Portable/Messaging/Bindings/MemoryCryptoKeyAndNonceStore.cs +++ b/src/DotNetOpenAuth.Core.Portable/Messaging/Bindings/MemoryCryptoKeyAndNonceStore.cs @@ -66,7 +66,7 @@ namespace DotNetOpenAuth.Messaging.Bindings { /// be processed within before being discarded as an expired message. /// If the binding element is applicable to your channel, this expiration window /// is retrieved or set using the - /// <see cref="StandardExpirationBindingElement.MaximumMessageAge"/> property. + /// <see cref="ChannelBase.MaximumMessageLifetime"/> property. /// </remarks> public bool StoreNonce(string context, string nonce, DateTime timestampUtc) { return this.nonceStore.StoreNonce(context, nonce, timestampUtc); diff --git a/src/DotNetOpenAuth.Core.Portable/Messaging/Bindings/MemoryNonceStore.cs b/src/DotNetOpenAuth.Core.Portable/Messaging/Bindings/MemoryNonceStore.cs index c1d5fb8..3faffc9 100644 --- a/src/DotNetOpenAuth.Core.Portable/Messaging/Bindings/MemoryNonceStore.cs +++ b/src/DotNetOpenAuth.Core.Portable/Messaging/Bindings/MemoryNonceStore.cs @@ -68,7 +68,7 @@ namespace DotNetOpenAuth.Messaging.Bindings { /// be processed within before being discarded as an expired message. /// If the binding element is applicable to your channel, this expiration window /// is retrieved or set using the - /// <see cref="StandardExpirationBindingElement.MaximumMessageAge"/> property. + /// <see cref="ChannelBase.MaximumMessageLifetime"/> property. /// </remarks> public bool StoreNonce(string context, string nonce, DateTime timestamp) { if (timestamp.ToUniversalTimeSafe() + this.MaximumMessageAge < DateTime.UtcNow) { diff --git a/src/DotNetOpenAuth.Core.Portable/Messaging/ChannelBase.cs b/src/DotNetOpenAuth.Core.Portable/Messaging/ChannelBase.cs index fcc27dd..c33cfbf 100644 --- a/src/DotNetOpenAuth.Core.Portable/Messaging/ChannelBase.cs +++ b/src/DotNetOpenAuth.Core.Portable/Messaging/ChannelBase.cs @@ -1,5 +1,5 @@ //----------------------------------------------------------------------- -// <copyright file="Channel.cs" company="Outercurve Foundation"> +// <copyright file="ChannelBase.cs" company="Outercurve Foundation"> // Copyright (c) Outercurve Foundation. All rights reserved. // </copyright> //----------------------------------------------------------------------- @@ -131,7 +131,7 @@ namespace DotNetOpenAuth.Messaging { private int maximumIndirectMessageUrlLength; /// <summary> - /// Initializes a new instance of the <see cref="Channel" /> class. + /// Initializes a new instance of the <see cref="ChannelBase" /> class. /// </summary> /// <param name="messageTypeProvider">A class prepared to analyze incoming messages and indicate what concrete /// message types can deserialize from it.</param> @@ -185,6 +185,12 @@ namespace DotNetOpenAuth.Messaging { } } + /// <summary> + /// Gets or sets the maximum clock skew allowed. + /// </summary> + /// <value> + /// The maximum clock skew. + /// </value> public TimeSpan MaximumClockSkew { get; set; } /// <summary> @@ -197,6 +203,12 @@ namespace DotNetOpenAuth.Messaging { get { return this.MaximumMessageLifetimeNoSkew + this.MaximumClockSkew; } } + /// <summary> + /// Gets or sets the maximum message lifetime without taking clock skew into account. + /// </summary> + /// <value> + /// The maximum message lifetime no skew. + /// </value> public TimeSpan MaximumMessageLifetimeNoSkew { get; set; } /// <summary> @@ -349,7 +361,6 @@ namespace DotNetOpenAuth.Messaging { /// <returns> /// True if the expected message was recognized and deserialized. False otherwise. /// </returns> - /// <exception cref="InvalidOperationException">Thrown when <see cref="HttpContext.Current" /> is null.</exception> /// <exception cref="ProtocolException">Thrown when a request message of an unexpected type is received.</exception> public async Task<TRequest> TryReadFromRequestAsync<TRequest>(HttpRequestMessage httpRequest, CancellationToken cancellationToken) where TRequest : class, IProtocolMessage { @@ -906,7 +917,7 @@ namespace DotNetOpenAuth.Messaging { /// <param name="request">The message to send.</param> /// <returns>The <see cref="HttpWebRequest"/> prepared to send the request.</returns> /// <remarks> - /// This method must be overridden by a derived class, unless the <see cref="Channel.RequestCoreAsync"/> method + /// This method must be overridden by a derived class, unless the <see cref="RequestCoreAsync"/> method /// is overridden and does not require this method. /// </remarks> protected virtual HttpRequestMessage CreateHttpRequest(IDirectedProtocolMessage request) { @@ -1308,10 +1319,31 @@ namespace DotNetOpenAuth.Messaging { /// Puts binding elements in their correct outgoing message processing order. /// </summary> private class BindingElementOutgoingMessageApplicationOrder : IComparer<MessageProtections> { - private BindingElementOutgoingMessageApplicationOrder() { } - + /// <summary> + /// Gets the singleton instance. + /// </summary> internal static readonly IComparer<MessageProtections> Default = new BindingElementOutgoingMessageApplicationOrder(); + /// <summary> + /// Prevents a default instance of the <see cref="BindingElementOutgoingMessageApplicationOrder"/> class from being created. + /// </summary> + private BindingElementOutgoingMessageApplicationOrder() { } + + /// <summary> + /// Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other. + /// </summary> + /// <param name="x">The first object to compare.</param> + /// <param name="y">The second object to compare.</param> + /// <returns> + /// Value + /// Condition + /// Less than zero + /// <paramref name="x" /> is less than <paramref name="y" />. + /// Zero + /// <paramref name="x" /> equals <paramref name="y" />. + /// Greater than zero + /// <paramref name="x" /> is greater than <paramref name="y" />. + /// </returns> public int Compare(MessageProtections x, MessageProtections y) { ErrorUtilities.VerifyInternal(x != MessageProtections.None || y != MessageProtections.None, "This comparison function should only be used to compare protection binding elements. Otherwise we change the order of user-defined message transformations."); diff --git a/src/DotNetOpenAuth.Core.Portable/Messaging/IMessageWithEvents.cs b/src/DotNetOpenAuth.Core.Portable/Messaging/IMessageWithEvents.cs index 965b074..59c5cfa 100644 --- a/src/DotNetOpenAuth.Core.Portable/Messaging/IMessageWithEvents.cs +++ b/src/DotNetOpenAuth.Core.Portable/Messaging/IMessageWithEvents.cs @@ -7,7 +7,7 @@ namespace DotNetOpenAuth.Messaging { /// <summary> /// An interface that messages wishing to perform custom serialization/deserialization - /// may implement to be notified of <see cref="Channel"/> events. + /// may implement to be notified of <see cref="ChannelBase"/> events. /// </summary> internal interface IMessageWithEvents : IMessage { /// <summary> diff --git a/src/DotNetOpenAuth.Core.Portable/PortableUtilities.cs b/src/DotNetOpenAuth.Core.Portable/PortableUtilities.cs index c9350ab..97e0007 100644 --- a/src/DotNetOpenAuth.Core.Portable/PortableUtilities.cs +++ b/src/DotNetOpenAuth.Core.Portable/PortableUtilities.cs @@ -266,6 +266,12 @@ namespace DotNetOpenAuth { } } + /// <summary> + /// Returns a read only instance of the specified list. + /// </summary> + /// <typeparam name="T">The type of elements in the list.</typeparam> + /// <param name="list">The list.</param> + /// <returns>The readonly list.</returns> internal static IReadOnlyList<T> AsReadOnly<T>(this IList<T> list) { Requires.NotNull(list, "list"); return list as IReadOnlyList<T> ?? new ReadOnlyCollection<T>(list); @@ -353,6 +359,8 @@ namespace DotNetOpenAuth { /// <summary> /// Provides equivalent behavior to Uri.HexEscape, which is missing from portable libraries. /// </summary> + /// <param name="value">The character to convert.</param> + /// <returns>A 3-character sequence beginning with the % sign, followed by two hexadecimal characters.</returns> internal static string HexEscape(char value) { return string.Format(CultureInfo.InvariantCulture, "%{0:X2}", (int)value); } @@ -381,11 +389,18 @@ namespace DotNetOpenAuth { sb.Append(EscapeUriDataStringRfc3986(pair.Value)); sb.Append('&'); } + sb.Length--; // remove trailing & return sb.ToString(); } + /// <summary> + /// Initializes a new dictionary based on the contents of the specified key=value sequence. + /// Entries with null keys are dropped. Duplicate keys are handled with last-one-wins policy. + /// </summary> + /// <param name="value">The sequence of key=value pairs..</param> + /// <returns>The new dictionary.</returns> internal static Dictionary<string, string> ToDictionaryDropNullKeys(this IEnumerable<KeyValuePair<string, string>> value) { var dictionary = new Dictionary<string, string>(); @@ -605,6 +620,37 @@ namespace DotNetOpenAuth { } /// <summary> + /// A thread-safe, non-crypto random number generator. + /// </summary> + private static class ThreadSafeRandom { + /// <summary> + /// The initializer of all new <see cref="Random"/> instances. + /// </summary> + private static readonly Random threadRandomInitializer = new Random(); + + /// <summary> + /// A thread-local instance of <see cref="Random"/> + /// </summary> + [ThreadStatic] + private static Random threadRandom; + + /// <summary> + /// Gets a random number generator for use on the current thread only. + /// </summary> + public static Random RandomNumberGenerator { + get { + if (threadRandom == null) { + lock (threadRandomInitializer) { + threadRandom = new Random(threadRandomInitializer.Next()); + } + } + + return threadRandom; + } + } + } + + /// <summary> /// Manages an individual deferred ToString call. /// </summary> /// <typeparam name="T">The type of object to be serialized as a string.</typeparam> @@ -641,36 +687,5 @@ namespace DotNetOpenAuth { return this.toString(this.obj) ?? string.Empty; } } - - /// <summary> - /// A thread-safe, non-crypto random number generator. - /// </summary> - private static class ThreadSafeRandom { - /// <summary> - /// The initializer of all new <see cref="Random"/> instances. - /// </summary> - private static readonly Random threadRandomInitializer = new Random(); - - /// <summary> - /// A thread-local instance of <see cref="Random"/> - /// </summary> - [ThreadStatic] - private static Random threadRandom; - - /// <summary> - /// Gets a random number generator for use on the current thread only. - /// </summary> - public static Random RandomNumberGenerator { - get { - if (threadRandom == null) { - lock (threadRandomInitializer) { - threadRandom = new Random(threadRandomInitializer.Next()); - } - } - - return threadRandom; - } - } - } } } diff --git a/src/DotNetOpenAuth.Core/Configuration/MessagingElement.cs b/src/DotNetOpenAuth.Core/Configuration/MessagingElement.cs index 64dfba3..cc7b088 100644 --- a/src/DotNetOpenAuth.Core/Configuration/MessagingElement.cs +++ b/src/DotNetOpenAuth.Core/Configuration/MessagingElement.cs @@ -168,7 +168,7 @@ namespace DotNetOpenAuth.Configuration { } /// <summary> - /// Gets or sets the configuration for the <see cref="UntrustedWebRequestHandler"/> class. + /// Gets or sets the configuration for the UntrustedWebRequestHandler class. /// </summary> /// <value>The untrusted web request.</value> [ConfigurationProperty(UntrustedWebRequestElementName)] diff --git a/src/DotNetOpenAuth.Core/Messaging/Channel.cs b/src/DotNetOpenAuth.Core/Messaging/Channel.cs index b1f47cd..713c0ea 100644 --- a/src/DotNetOpenAuth.Core/Messaging/Channel.cs +++ b/src/DotNetOpenAuth.Core/Messaging/Channel.cs @@ -1,4 +1,10 @@ -namespace DotNetOpenAuth.Messaging { +//----------------------------------------------------------------------- +// <copyright file="Channel.cs" company="Andrew Arnott"> +// Copyright (c) Andrew Arnott. All rights reserved. +// </copyright> +//----------------------------------------------------------------------- + +namespace DotNetOpenAuth.Messaging { using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -11,6 +17,9 @@ using DotNetOpenAuth.Configuration; using Validation; + /// <summary> + /// Derivation of ChannelBase that adds desktop-specific behavior. + /// </summary> public abstract class Channel : ChannelBase { /// <summary> /// A default set of XML dictionary reader quotas that are relatively safe from causing unbounded memory consumption. @@ -21,7 +30,7 @@ MaxBytesPerRead = 8 * 1024, MaxStringContentLength = 16 * 1024, }; - + /// <summary> /// Initializes a new instance of the <see cref="Channel"/> class. /// </summary> diff --git a/src/DotNetOpenAuth.Core/Util.cs b/src/DotNetOpenAuth.Core/Util.cs index c2b1d7c..afe98dc 100644 --- a/src/DotNetOpenAuth.Core/Util.cs +++ b/src/DotNetOpenAuth.Core/Util.cs @@ -83,6 +83,7 @@ namespace DotNetOpenAuth { string.Join(", ", new string[] { typeof(Page).FullName, typeof(IEmbeddedResourceRetrieval).FullName }))); } } + /// <summary> /// Validates that a URL will be resolvable at runtime. /// </summary> diff --git a/src/DotNetOpenAuth.OAuth.Common/OAuth/DefaultOAuthHostFactories.cs b/src/DotNetOpenAuth.OAuth.Common/OAuth/DefaultOAuthHostFactories.cs index f6d3a85..2266804 100644 --- a/src/DotNetOpenAuth.OAuth.Common/OAuth/DefaultOAuthHostFactories.cs +++ b/src/DotNetOpenAuth.OAuth.Common/OAuth/DefaultOAuthHostFactories.cs @@ -18,7 +18,7 @@ namespace DotNetOpenAuth.OAuth { /// </summary> /// <returns>An instance of <see cref="HttpMessageHandler"/>.</returns> /// <remarks> - /// An instance of <see cref="WebRequestHandler" /> is recommended where available; + /// An instance of WebRequestHandler is recommended where available; /// otherwise an instance of <see cref="HttpClientHandler" /> is recommended. /// </remarks> public virtual HttpMessageHandler CreateHttpMessageHandler() { diff --git a/src/DotNetOpenAuth.OAuth2.Client/OAuth2/ChannelElements/OAuth2ClientChannel.cs b/src/DotNetOpenAuth.OAuth2.Client/OAuth2/ChannelElements/OAuth2ClientChannel.cs index 9a560c2..fdec216 100644 --- a/src/DotNetOpenAuth.OAuth2.Client/OAuth2/ChannelElements/OAuth2ClientChannel.cs +++ b/src/DotNetOpenAuth.OAuth2.Client/OAuth2/ChannelElements/OAuth2ClientChannel.cs @@ -69,7 +69,7 @@ namespace DotNetOpenAuth.OAuth2.ChannelElements { /// The <see cref="HttpWebRequest"/> prepared to send the request. /// </returns> /// <remarks> - /// This method must be overridden by a derived class, unless the <see cref="Channel.RequestCoreAsync"/> method + /// This method must be overridden by a derived class, unless the <see cref="ChannelBase.RequestCoreAsync"/> method /// is overridden and does not require this method. /// </remarks> protected override HttpRequestMessage CreateHttpRequest(IDirectedProtocolMessage request) { |