summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/DotNetOpenAuth.Messaging/Assumes.cs6
-rw-r--r--src/DotNetOpenAuth.Messaging/Requires.cs24
2 files changed, 16 insertions, 14 deletions
diff --git a/src/DotNetOpenAuth.Messaging/Assumes.cs b/src/DotNetOpenAuth.Messaging/Assumes.cs
index 43de627..67205a2 100644
--- a/src/DotNetOpenAuth.Messaging/Assumes.cs
+++ b/src/DotNetOpenAuth.Messaging/Assumes.cs
@@ -8,6 +8,7 @@ namespace DotNetOpenAuth {
using System;
using System.Collections.Generic;
using System.Diagnostics;
+ using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
@@ -20,7 +21,7 @@ namespace DotNetOpenAuth {
/// </summary>
/// <param name="condition">The expression that must evaluate to true to avoid an internal error exception.</param>
/// <param name="message">The message to include with the exception.</param>
- [DebuggerStepThrough]
+ [Pure, DebuggerStepThrough]
internal static void True(bool condition, string message = null) {
if (!condition) {
Fail(message);
@@ -33,7 +34,7 @@ namespace DotNetOpenAuth {
/// <param name="condition">The expression that must evaluate to true to avoid an internal error exception.</param>
/// <param name="unformattedMessage">The unformatted message.</param>
/// <param name="args">Formatting arguments.</param>
- [DebuggerStepThrough]
+ [Pure, DebuggerStepThrough]
internal static void True(bool condition, string unformattedMessage, params object[] args) {
if (!condition) {
Fail(String.Format(unformattedMessage, args));
@@ -44,6 +45,7 @@ namespace DotNetOpenAuth {
/// Throws an internal error exception.
/// </summary>
/// <param name="message">The message.</param>
+ [Pure, DebuggerStepThrough]
internal static void Fail(string message = null) {
if (message != null) {
throw new InternalErrorException(message);
diff --git a/src/DotNetOpenAuth.Messaging/Requires.cs b/src/DotNetOpenAuth.Messaging/Requires.cs
index c7b641a..e322da7 100644
--- a/src/DotNetOpenAuth.Messaging/Requires.cs
+++ b/src/DotNetOpenAuth.Messaging/Requires.cs
@@ -24,7 +24,7 @@ namespace DotNetOpenAuth {
/// <typeparam name="T">The type of the parameter</typeparam>
/// <param name="value">The value.</param>
/// <param name="parameterName">Name of the parameter.</param>
- [ContractArgumentValidator, DebuggerStepThrough]
+ [Pure, ContractArgumentValidator, DebuggerStepThrough]
internal static void NotNull<T>(T value, string parameterName) where T : class {
if (value == null) {
throw new ArgumentNullException(parameterName);
@@ -38,7 +38,7 @@ namespace DotNetOpenAuth {
/// </summary>
/// <param name="value">The value.</param>
/// <param name="parameterName">Name of the parameter.</param>
- [ContractArgumentValidator, DebuggerStepThrough]
+ [Pure, ContractArgumentValidator, DebuggerStepThrough]
internal static void NotNullOrEmpty(string value, string parameterName) {
NotNull(value, parameterName);
True(value.Length > 0, parameterName, Strings.EmptyStringNotAllowed);
@@ -51,7 +51,7 @@ namespace DotNetOpenAuth {
/// <typeparam name="T">The type of elements in the sequence.</typeparam>
/// <param name="sequence">The sequence.</param>
/// <param name="parameterName">Name of the parameter.</param>
- [ContractArgumentValidator, DebuggerStepThrough]
+ [Pure, ContractArgumentValidator, DebuggerStepThrough]
internal static void NullOrWithNoNullElements<T>(IEnumerable<T> sequence, string parameterName) where T : class {
if (sequence != null) {
if (sequence.Any(e => e == null)) {
@@ -66,7 +66,7 @@ namespace DotNetOpenAuth {
/// <param name="condition">The expression that must evaluate to true to avoid an <see cref="ArgumentOutOfRangeException"/>.</param>
/// <param name="parameterName">Name of the parameter.</param>
/// <param name="message">The message to include with the exception.</param>
- [ContractArgumentValidator, DebuggerStepThrough]
+ [Pure, ContractArgumentValidator, DebuggerStepThrough]
internal static void InRange(bool condition, string parameterName, string message = null) {
if (!condition) {
throw new ArgumentOutOfRangeException(parameterName, message);
@@ -81,7 +81,7 @@ namespace DotNetOpenAuth {
/// <param name="condition">The expression that must evaluate to true to avoid an <see cref="ArgumentException"/>.</param>
/// <param name="parameterName">Name of the parameter.</param>
/// <param name="message">The message to include with the exception.</param>
- [ContractArgumentValidator, DebuggerStepThrough]
+ [Pure, ContractArgumentValidator, DebuggerStepThrough]
internal static void True(bool condition, string parameterName, string message = null) {
if (!condition) {
throw new ArgumentException(message ?? Strings.InvalidArgument, parameterName);
@@ -97,7 +97,7 @@ namespace DotNetOpenAuth {
/// <param name="parameterName">Name of the parameter.</param>
/// <param name="unformattedMessage">The unformatted message.</param>
/// <param name="args">Formatting arguments.</param>
- [ContractArgumentValidator, DebuggerStepThrough]
+ [Pure, ContractArgumentValidator, DebuggerStepThrough]
internal static void True(bool condition, string parameterName, string unformattedMessage, params object[] args) {
if (!condition) {
throw new ArgumentException(String.Format(unformattedMessage, args), parameterName);
@@ -110,7 +110,7 @@ namespace DotNetOpenAuth {
/// Validates some expression describing the acceptable condition for an argument evaluates to true.
/// </summary>
/// <param name="condition">The expression that must evaluate to true to avoid an <see cref="InvalidOperationException"/>.</param>
- [ContractArgumentValidator, DebuggerStepThrough]
+ [Pure, ContractArgumentValidator, DebuggerStepThrough]
internal static void ValidState(bool condition) {
if (!condition) {
throw new InvalidOperationException();
@@ -124,7 +124,7 @@ namespace DotNetOpenAuth {
/// </summary>
/// <param name="condition">The expression that must evaluate to true to avoid an <see cref="InvalidOperationException"/>.</param>
/// <param name="message">The message to include with the exception.</param>
- [ContractArgumentValidator, DebuggerStepThrough]
+ [Pure, ContractArgumentValidator, DebuggerStepThrough]
internal static void ValidState(bool condition, string message) {
if (!condition) {
throw new InvalidOperationException(message);
@@ -139,7 +139,7 @@ namespace DotNetOpenAuth {
/// <param name="condition">The expression that must evaluate to true to avoid an <see cref="InvalidOperationException"/>.</param>
/// <param name="unformattedMessage">The unformatted message.</param>
/// <param name="args">Formatting arguments.</param>
- [ContractArgumentValidator, DebuggerStepThrough]
+ [Pure, ContractArgumentValidator, DebuggerStepThrough]
internal static void ValidState(bool condition, string unformattedMessage, params object[] args) {
if (!condition) {
throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, unformattedMessage, args));
@@ -154,7 +154,7 @@ namespace DotNetOpenAuth {
/// <typeparam name="T">The type that the argument must be or derive from.</typeparam>
/// <param name="type">The type given in the argument.</param>
/// <param name="parameterName">Name of the parameter.</param>
- [ContractArgumentValidator, DebuggerStepThrough]
+ [Pure, ContractArgumentValidator, DebuggerStepThrough]
internal static void NotNullSubtype<T>(Type type, string parameterName) {
NotNull(type, parameterName);
True(typeof(T).IsAssignableFrom(type), parameterName, MessagingStrings.UnexpectedType, typeof(T).FullName, type.FullName);
@@ -167,7 +167,7 @@ namespace DotNetOpenAuth {
/// </summary>
/// <param name="condition">The expression that must evaluate to true to avoid an <see cref="NotSupportedException"/>.</param>
/// <param name="message">The message.</param>
- [DebuggerStepThrough]
+ [Pure, DebuggerStepThrough]
internal static void Support(bool condition, string message) {
if (!condition) {
throw new NotSupportedException(message);
@@ -179,7 +179,7 @@ namespace DotNetOpenAuth {
/// </summary>
/// <param name="parameterName">Name of the parameter.</param>
/// <param name="message">The message.</param>
- [DebuggerStepThrough]
+ [Pure, DebuggerStepThrough]
internal static void Fail(string parameterName, string message) {
throw new ArgumentException(message, parameterName);
}