diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2012-12-26 20:22:14 -0800 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2012-12-26 20:22:14 -0800 |
commit | 391397a341282d0c088bc9e9901ced9b19a62e5a (patch) | |
tree | bc1cc264acba9edc486eefbbfbb5fd4822111fb1 /src/DotNetOpenAuth.Core/Configuration | |
parent | 8f48e3f1daedb77e451f9fe8ac497741c6bb06f9 (diff) | |
parent | 3475fab579db0f6a1454ebc83d2e8a9c271e4c18 (diff) | |
download | DotNetOpenAuth-391397a341282d0c088bc9e9901ced9b19a62e5a.zip DotNetOpenAuth-391397a341282d0c088bc9e9901ced9b19a62e5a.tar.gz DotNetOpenAuth-391397a341282d0c088bc9e9901ced9b19a62e5a.tar.bz2 |
Merge branch 'retargeting-contracts'
Diffstat (limited to 'src/DotNetOpenAuth.Core/Configuration')
9 files changed, 5 insertions, 24 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 f009ce5..8f537c3 100644 --- a/src/DotNetOpenAuth.Core/Configuration/HostNameOrRegexCollection.cs +++ b/src/DotNetOpenAuth.Core/Configuration/HostNameOrRegexCollection.cs @@ -7,13 +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. @@ -63,7 +62,7 @@ namespace DotNetOpenAuth.Configuration { /// An <see cref="T:System.Object"/> that acts as the key for the specified <see cref="T:System.Configuration.ConfigurationElement"/>. /// </returns> protected override object GetElementKey(ConfigurationElement element) { - Contract.Assume(element != null); // this should be Contract.Requires in base class. + Requires.NotNull(element, "element"); return ((HostNameElement)element).Name ?? string.Empty; } } 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 <messaging> element in the host's .config file. /// </summary> - [ContractVerification(true)] public class MessagingElement : ConfigurationSection { /// <summary> /// The name of the <webResourceUrlProvider> 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 96f60bf..de70f64 100644 --- a/src/DotNetOpenAuth.Core/Configuration/TrustedProviderConfigurationCollection.cs +++ b/src/DotNetOpenAuth.Core/Configuration/TrustedProviderConfigurationCollection.cs @@ -9,7 +9,7 @@ namespace DotNetOpenAuth.Configuration { using System.Collections.Generic; using System.Configuration; using System.Diagnostics.CodeAnalysis; - using System.Diagnostics.Contracts; + using Validation; /// <summary> /// A configuration collection of trusted OP Endpoints. diff --git a/src/DotNetOpenAuth.Core/Configuration/TypeConfigurationCollection.cs b/src/DotNetOpenAuth.Core/Configuration/TypeConfigurationCollection.cs index 3e72722..08bd2a1 100644 --- a/src/DotNetOpenAuth.Core/Configuration/TypeConfigurationCollection.cs +++ b/src/DotNetOpenAuth.Core/Configuration/TypeConfigurationCollection.cs @@ -8,16 +8,15 @@ 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; + using Validation; /// <summary> /// A collection of <see cref="TypeConfigurationElement<T>"/>. /// </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> @@ -44,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); @@ -68,7 +66,7 @@ namespace DotNetOpenAuth.Configuration { /// An <see cref="T:System.Object"/> that acts as the key for the specified <see cref="T:System.Configuration.ConfigurationElement"/>. /// </returns> protected override object GetElementKey(ConfigurationElement element) { - Contract.Assume(element != null); // this should be Contract.Requires in base class. + Requires.NotNull(element, "element"); TypeConfigurationElement<T> typedElement = (TypeConfigurationElement<T>)element; return (!string.IsNullOrEmpty(typedElement.TypeName) ? typedElement.TypeName : typedElement.XamlSource) ?? string.Empty; } 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 |