summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2009-03-10 12:51:36 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2009-04-22 10:09:30 -0700
commit05002eda38c0bf1b82b8bb44d893d9f2cee53d53 (patch)
tree197f4fd117da7c21e990e8bc636550018e4b239c /src
parent8f173adba793c6ef4efccb4ee21c17e24a442783 (diff)
downloadDotNetOpenAuth-05002eda38c0bf1b82b8bb44d893d9f2cee53d53.zip
DotNetOpenAuth-05002eda38c0bf1b82b8bb44d893d9f2cee53d53.tar.gz
DotNetOpenAuth-05002eda38c0bf1b82b8bb44d893d9f2cee53d53.tar.bz2
Changed Requires -> RequiresAlways for precondition checks.
Diffstat (limited to 'src')
-rw-r--r--src/DotNetOpenAuth/ContractRuntimeFailureMethods.cs57
-rw-r--r--src/DotNetOpenAuth/DotNetOpenAuth.csproj12
-rw-r--r--src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingParty.cs2
3 files changed, 64 insertions, 7 deletions
diff --git a/src/DotNetOpenAuth/ContractRuntimeFailureMethods.cs b/src/DotNetOpenAuth/ContractRuntimeFailureMethods.cs
new file mode 100644
index 0000000..dc239fd
--- /dev/null
+++ b/src/DotNetOpenAuth/ContractRuntimeFailureMethods.cs
@@ -0,0 +1,57 @@
+// <auto-generated/> // disable StyleCop on this file
+//-----------------------------------------------------------------------
+// <copyright file="ContractInternal.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth {
+ using System;
+ using System.Diagnostics;
+ using DotNetOpenAuth.Messaging;
+
+ /// <summary>
+ /// An internal equivalent to <see cref="Microsoft.Contracts.Contract"/> in order to
+ /// avoid a runtime dependency on Microsoft.Contracts.dll.
+ /// </summary>
+ /// <remarks>
+ /// The Code Contracts assembly rewriter (ccrewrite) tool causes all calls to Contract.*()
+ /// to redirect to this class.
+ /// </remarks>
+ internal static class ContractRuntimeFailureMethods {
+ [DebuggerStepThrough]
+ public static void Requires(bool condition, string userMessage, string conditionText) {
+ if (!condition) {
+ throw new ArgumentException(userMessage ?? conditionText);
+ }
+ }
+
+ [DebuggerStepThrough]
+ public static void Ensures(bool condition, string userMessage, string conditionText) {
+ if (!condition) {
+ throw new InternalErrorException(userMessage ?? conditionText);
+ }
+ }
+
+ [DebuggerStepThrough]
+ public static void Assert(bool condition, string userMessage, string conditionText) {
+ if (!condition) {
+ throw new InternalErrorException(userMessage ?? conditionText);
+ }
+ }
+
+ [DebuggerStepThrough]
+ public static void Assume(bool condition, string userMessage, string conditionText) {
+ if (!condition) {
+ throw new InternalErrorException(userMessage ?? conditionText);
+ }
+ }
+
+ [DebuggerStepThrough]
+ public static void Invariant(bool condition, string userMessage, string conditionText) {
+ if (!condition) {
+ throw new InternalErrorException(userMessage ?? conditionText);
+ }
+ }
+ }
+}
diff --git a/src/DotNetOpenAuth/DotNetOpenAuth.csproj b/src/DotNetOpenAuth/DotNetOpenAuth.csproj
index 2c30aaf..859b0c6 100644
--- a/src/DotNetOpenAuth/DotNetOpenAuth.csproj
+++ b/src/DotNetOpenAuth/DotNetOpenAuth.csproj
@@ -59,12 +59,10 @@
<DocumentationFile>..\..\bin\Release\DotNetOpenAuth.xml</DocumentationFile>
<RunCodeAnalysis>true</RunCodeAnalysis>
<CodeAnalysisRules>-Microsoft.Design#CA1054;-Microsoft.Design#CA1056;-Microsoft.Design#CA1055</CodeAnalysisRules>
- <CodeContractsEnableRuntimeChecking>False</CodeContractsEnableRuntimeChecking>
- <CodeContractsCustomRewriterAssembly>
- </CodeContractsCustomRewriterAssembly>
- <CodeContractsCustomRewriterClass>
- </CodeContractsCustomRewriterClass>
- <CodeContractsRuntimeCheckingLevel>Full</CodeContractsRuntimeCheckingLevel>
+ <CodeContractsEnableRuntimeChecking>True</CodeContractsEnableRuntimeChecking>
+ <CodeContractsCustomRewriterAssembly>DotNetOpenAuth</CodeContractsCustomRewriterAssembly>
+ <CodeContractsCustomRewriterClass>DotNetOpenAuth.ContractRuntimeFailureMethods</CodeContractsCustomRewriterClass>
+ <CodeContractsRuntimeCheckingLevel>RequiresAlways</CodeContractsRuntimeCheckingLevel>
<CodeContractsRunCodeAnalysis>False</CodeContractsRunCodeAnalysis>
<CodeContractsBuildReferenceAssembly>True</CodeContractsBuildReferenceAssembly>
<CodeContractsNonNullObligations>False</CodeContractsNonNullObligations>
@@ -80,6 +78,7 @@
<CodeContractsUseBaseLine>False</CodeContractsUseBaseLine>
<CodeContractsRunInBackground>True</CodeContractsRunInBackground>
<CodeContractsShowSquigglies>False</CodeContractsShowSquigglies>
+ <CodeContractsArithmeticObligations>False</CodeContractsArithmeticObligations>
</PropertyGroup>
<PropertyGroup Condition=" '$(Sign)' == 'true' ">
<SignAssembly>true</SignAssembly>
@@ -186,6 +185,7 @@
<Compile Include="Configuration\UntrustedWebRequestElement.cs" />
<Compile Include="Configuration\HostNameOrRegexCollection.cs" />
<Compile Include="Configuration\HostNameElement.cs" />
+ <Compile Include="ContractRuntimeFailureMethods.cs" />
<Compile Include="InfoCard\ClaimType.cs" />
<Compile Include="InfoCard\ReceivingTokenEventArgs.cs" />
<Compile Include="InfoCard\TokenProcessingErrorEventArgs.cs" />
diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingParty.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingParty.cs
index 4bcaf10..3a4a92a 100644
--- a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingParty.cs
+++ b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingParty.cs
@@ -144,7 +144,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
}
set {
- Contract.Requires(value != null);
+ Contract.RequiresAlways(value != null);
ErrorUtilities.VerifyArgumentNotNull(value, "value");
this.channel = value;
this.AssociationManager.Channel = value;