diff --git a/src/Microsoft.AspNet.Mvc.Common/PropertyHelper.cs b/src/Microsoft.AspNet.Mvc.Common/PropertyHelper.cs index 2f2c9c9a4f..0cbf72779c 100644 --- a/src/Microsoft.AspNet.Mvc.Common/PropertyHelper.cs +++ b/src/Microsoft.AspNet.Mvc.Common/PropertyHelper.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Concurrent; -using System.Diagnostics.Contracts; +using System.Diagnostics; using System.Linq; using System.Reflection; @@ -84,12 +84,12 @@ namespace Microsoft.AspNet.Mvc /// public static Func MakeFastPropertyGetter(PropertyInfo propertyInfo) { - Contract.Assert(propertyInfo != null); + Debug.Assert(propertyInfo != null); var getMethod = propertyInfo.GetMethod; - Contract.Assert(getMethod != null); - Contract.Assert(!getMethod.IsStatic); - Contract.Assert(getMethod.GetParameters().Length == 0); + Debug.Assert(getMethod != null); + Debug.Assert(!getMethod.IsStatic); + Debug.Assert(getMethod.GetParameters().Length == 0); // Instance methods in the CLR can be turned into static methods where the first parameter // is open over "target". This parameter is always passed by reference, so we have a code @@ -135,15 +135,15 @@ namespace Microsoft.AspNet.Mvc /// public static Action MakeFastPropertySetter(PropertyInfo propertyInfo) { - Contract.Assert(propertyInfo != null); - Contract.Assert(!propertyInfo.DeclaringType.GetTypeInfo().IsValueType); + Debug.Assert(propertyInfo != null); + Debug.Assert(!propertyInfo.DeclaringType.GetTypeInfo().IsValueType); var setMethod = propertyInfo.SetMethod; - Contract.Assert(setMethod != null); - Contract.Assert(!setMethod.IsStatic); - Contract.Assert(setMethod.ReturnType == typeof(void)); + Debug.Assert(setMethod != null); + Debug.Assert(!setMethod.IsStatic); + Debug.Assert(setMethod.ReturnType == typeof(void)); var parameters = setMethod.GetParameters(); - Contract.Assert(parameters.Length == 1); + Debug.Assert(parameters.Length == 1); // Instance methods in the CLR can be turned into static methods where the first parameter // is open over "target". This parameter is always passed by reference, so we have a code diff --git a/src/Microsoft.AspNet.Mvc.Core/AntiForgery/AntiForgeryTokenStore.cs b/src/Microsoft.AspNet.Mvc.Core/AntiForgery/AntiForgeryTokenStore.cs index 224d99544c..c8c5330578 100644 --- a/src/Microsoft.AspNet.Mvc.Core/AntiForgery/AntiForgeryTokenStore.cs +++ b/src/Microsoft.AspNet.Mvc.Core/AntiForgery/AntiForgeryTokenStore.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Diagnostics.Contracts; +using System.Diagnostics; using System.Threading.Tasks; using Microsoft.AspNet.Http; using Microsoft.Framework.DependencyInjection; @@ -58,7 +58,7 @@ namespace Microsoft.AspNet.Mvc // Add the cookie to the request based context. // This is useful if the cookie needs to be reloaded in the context of the same request. var contextAccessor = httpContext.RequestServices.GetRequiredService>(); - Contract.Assert(contextAccessor.Value == null, "AntiForgeryContext should be set only once per request."); + Debug.Assert(contextAccessor.Value == null, "AntiForgeryContext should be set only once per request."); contextAccessor.SetValue(new AntiForgeryContext() { CookieToken = token }); var serializedToken = _serializer.Serialize(token); diff --git a/src/Microsoft.AspNet.Mvc.Core/AntiForgery/AntiForgeryWorker.cs b/src/Microsoft.AspNet.Mvc.Core/AntiForgery/AntiForgeryWorker.cs index 34c22385ff..3f0cec6d79 100644 --- a/src/Microsoft.AspNet.Mvc.Core/AntiForgery/AntiForgeryWorker.cs +++ b/src/Microsoft.AspNet.Mvc.Core/AntiForgery/AntiForgeryWorker.cs @@ -2,8 +2,8 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Diagnostics; using System.Diagnostics.CodeAnalysis; -using System.Diagnostics.Contracts; using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNet.Http; @@ -152,7 +152,7 @@ namespace Microsoft.AspNet.Mvc oldCookieToken = newCookieToken = _generator.GenerateCookieToken(); } - Contract.Assert(_validator.IsCookieTokenValid(oldCookieToken)); + Debug.Assert(_validator.IsCookieTokenValid(oldCookieToken)); var formToken = _generator.GenerateFormToken( httpContext, diff --git a/src/Microsoft.AspNet.Mvc.Core/AntiForgery/BinaryBlob.cs b/src/Microsoft.AspNet.Mvc.Core/AntiForgery/BinaryBlob.cs index 2e960d9c37..2bc8c9859c 100644 --- a/src/Microsoft.AspNet.Mvc.Core/AntiForgery/BinaryBlob.cs +++ b/src/Microsoft.AspNet.Mvc.Core/AntiForgery/BinaryBlob.cs @@ -4,7 +4,6 @@ using System; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; -using System.Diagnostics.Contracts; using System.Globalization; using System.Runtime.CompilerServices; using System.Security.Cryptography; @@ -75,7 +74,7 @@ namespace Microsoft.AspNet.Mvc return false; } - Contract.Assert(this._data.Length == other._data.Length); + Debug.Assert(this._data.Length == other._data.Length); return AreByteArraysEqual(this._data, other._data); } @@ -88,7 +87,7 @@ namespace Microsoft.AspNet.Mvc { // Since data should contain uniformly-distributed entropy, the // first 32 bits can serve as the hash code. - Contract.Assert(_data != null && _data.Length >= (32 / 8)); + Debug.Assert(_data != null && _data.Length >= (32 / 8)); return BitConverter.ToInt32(_data, 0); } diff --git a/src/Microsoft.AspNet.Mvc.Core/AntiForgery/TokenProvider.cs b/src/Microsoft.AspNet.Mvc.Core/AntiForgery/TokenProvider.cs index f179dae5f1..f1198e9b33 100644 --- a/src/Microsoft.AspNet.Mvc.Core/AntiForgery/TokenProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Core/AntiForgery/TokenProvider.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Diagnostics.Contracts; +using System.Diagnostics; using System.Security.Claims; using Microsoft.AspNet.Http; using Microsoft.AspNet.Mvc.Core; @@ -37,7 +37,7 @@ namespace Microsoft.AspNet.Mvc ClaimsIdentity identity, AntiForgeryToken cookieToken) { - Contract.Assert(IsCookieTokenValid(cookieToken)); + Debug.Assert(IsCookieTokenValid(cookieToken)); var formToken = new AntiForgeryToken() { diff --git a/src/Microsoft.AspNet.Mvc.Core/Description/DefaultApiDescriptionProvider.cs b/src/Microsoft.AspNet.Mvc.Core/Description/DefaultApiDescriptionProvider.cs index 28e176e850..b293985f75 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Description/DefaultApiDescriptionProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Description/DefaultApiDescriptionProvider.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; -using System.Diagnostics.Contracts; +using System.Diagnostics; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNet.Mvc.HeaderValueAbstractions; @@ -246,7 +246,7 @@ namespace Microsoft.AspNet.Mvc.Description else { // We will never call this method with templateParameter == null && parameterDescriptor == null - Contract.Assert(parameterDescriptor != null); + Debug.Assert(parameterDescriptor != null); } if (parameterDescription.Type != null) diff --git a/src/Microsoft.AspNet.Mvc.Core/Extensions/IEnumerableExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/Extensions/IEnumerableExtensions.cs index 13dec4f567..93e5642c30 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Extensions/IEnumerableExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Extensions/IEnumerableExtensions.cs @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System.Diagnostics.Contracts; +using System.Diagnostics; using System.Linq; namespace System.Collections.Generic @@ -10,7 +10,7 @@ namespace System.Collections.Generic { public static T[] AsArray(this IEnumerable values) { - Contract.Assert(values != null); + Debug.Assert(values != null); var array = values as T[]; if (array == null) diff --git a/src/Microsoft.AspNet.Mvc.Core/FilterActionInvoker.cs b/src/Microsoft.AspNet.Mvc.Core/FilterActionInvoker.cs index 6353c5d622..6c4732fc50 100644 --- a/src/Microsoft.AspNet.Mvc.Core/FilterActionInvoker.cs +++ b/src/Microsoft.AspNet.Mvc.Core/FilterActionInvoker.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; -using System.Diagnostics.Contracts; +using System.Diagnostics; using System.Linq; using System.Runtime.ExceptionServices; using System.Threading.Tasks; @@ -110,7 +110,7 @@ namespace Microsoft.AspNet.Mvc // pipeline. await InvokeExceptionFilter(); - Contract.Assert(_exceptionContext != null); + Debug.Assert(_exceptionContext != null); if (_exceptionContext.Exception != null) { // Exception filters only run when there's an exception - unsetting it will short-circuit @@ -124,7 +124,7 @@ namespace Microsoft.AspNet.Mvc // pipeline. await InvokeExceptionFilter(); - Contract.Assert(_exceptionContext != null); + Debug.Assert(_exceptionContext != null); if (_exceptionContext.Exception != null) { // Exception filters only run when there's an exception - unsetting it will short-circuit @@ -139,21 +139,21 @@ namespace Microsoft.AspNet.Mvc // // 1) Call the filter (if we have an exception) // 2) No-op (if we don't have an exception) - Contract.Assert(_exceptionContext == null); + Debug.Assert(_exceptionContext == null); _exceptionContext = new ExceptionContext(ActionContext, _filters); try { await InvokeActionAuthorizationFilters(); - Contract.Assert(_authorizationContext != null); + Debug.Assert(_authorizationContext != null); if (_authorizationContext.Result == null) { // Authorization passed, run authorization filters and the action await InvokeActionMethodWithFilters(); // Action filters might 'return' an unahndled exception instead of throwing - Contract.Assert(_actionExecutedContext != null); + Debug.Assert(_actionExecutedContext != null); if (_actionExecutedContext.Exception != null && !_actionExecutedContext.ExceptionHandled) { _exceptionContext.Exception = _actionExecutedContext.Exception; @@ -182,8 +182,8 @@ namespace Microsoft.AspNet.Mvc private async Task InvokeAuthorizationFilter() { // We should never get here if we already have a result. - Contract.Assert(_authorizationContext != null); - Contract.Assert(_authorizationContext.Result == null); + Debug.Assert(_authorizationContext != null); + Debug.Assert(_authorizationContext.Result == null); var current = _cursor.GetNextFilter(); if (current.FilterAsync != null) @@ -223,7 +223,7 @@ namespace Microsoft.AspNet.Mvc private async Task InvokeActionMethodFilter() { - Contract.Assert(_actionExecutingContext != null); + Debug.Assert(_actionExecutingContext != null); if (_actionExecutingContext.Result != null) { // If we get here, it means that an async filter set a result AND called next(). This is forbidden. @@ -298,7 +298,7 @@ namespace Microsoft.AspNet.Mvc _resultExecutingContext = new ResultExecutingContext(ActionContext, _filters, result); await InvokeActionResultFilter(); - Contract.Assert(_resultExecutingContext != null); + Debug.Assert(_resultExecutingContext != null); if (_resultExecutedContext.Exception != null && !_resultExecutedContext.ExceptionHandled) { // There's an unhandled exception in filters @@ -315,7 +315,7 @@ namespace Microsoft.AspNet.Mvc private async Task InvokeActionResultFilter() { - Contract.Assert(_resultExecutingContext != null); + Debug.Assert(_resultExecutingContext != null); if (_resultExecutingContext.Cancel == true) { // If we get here, it means that an async filter set cancel == true AND called next(). @@ -383,7 +383,7 @@ namespace Microsoft.AspNet.Mvc { await InvokeActionResult(); - Contract.Assert(_resultExecutedContext == null); + Debug.Assert(_resultExecutedContext == null); _resultExecutedContext = new ResultExecutedContext( _resultExecutingContext, _filters, diff --git a/src/Microsoft.AspNet.Mvc.Core/Filters/DefaultFilterProvider.cs b/src/Microsoft.AspNet.Mvc.Core/Filters/DefaultFilterProvider.cs index 69a7b2e42d..ab1b7f4d85 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Filters/DefaultFilterProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Filters/DefaultFilterProvider.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Diagnostics.Contracts; +using System.Diagnostics; using Microsoft.AspNet.Mvc.Core; using Microsoft.Framework.DependencyInjection; @@ -97,8 +97,8 @@ namespace Microsoft.AspNet.Mvc.Filters private void ApplyFilterToContainer(object actualFilter, IFilter filterMetadata) { - Contract.Assert(actualFilter != null, "actualFilter should not be null"); - Contract.Assert(filterMetadata != null, "filterMetadata should not be null"); + Debug.Assert(actualFilter != null, "actualFilter should not be null"); + Debug.Assert(filterMetadata != null, "filterMetadata should not be null"); var container = actualFilter as IFilterContainer; diff --git a/src/Microsoft.AspNet.Mvc.Core/MvcRouteHandler.cs b/src/Microsoft.AspNet.Mvc.Core/MvcRouteHandler.cs index e432d4736d..6c3cfdd8d9 100644 --- a/src/Microsoft.AspNet.Mvc.Core/MvcRouteHandler.cs +++ b/src/Microsoft.AspNet.Mvc.Core/MvcRouteHandler.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Diagnostics.Contracts; +using System.Diagnostics; using System.Threading.Tasks; using Microsoft.AspNet.Http; using Microsoft.AspNet.Mvc.Core; @@ -36,7 +36,7 @@ namespace Microsoft.AspNet.Mvc // users understand they should call the per request scoped middleware // or set HttpContext.Services manually var services = context.HttpContext.RequestServices; - Contract.Assert(services != null); + Debug.Assert(services != null); // Verify if AddMvc was done before calling UseMvc // We use the MvcMarkerService to make sure if all the services were added. @@ -92,7 +92,7 @@ namespace Microsoft.AspNet.Mvc private async Task InvokeActionAsync(RouteContext context, ActionDescriptor actionDescriptor) { var services = context.HttpContext.RequestServices; - Contract.Assert(services != null); + Debug.Assert(services != null); var actionContext = new ActionContext(context.HttpContext, context.RouteData, actionDescriptor); diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/DefaultHtmlGenerator.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/DefaultHtmlGenerator.cs index 7a46c84174..a5f6efd435 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/DefaultHtmlGenerator.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/DefaultHtmlGenerator.cs @@ -4,7 +4,7 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Diagnostics.Contracts; +using System.Diagnostics; using System.Globalization; using System.Linq; using System.Net; @@ -96,7 +96,7 @@ namespace Microsoft.AspNet.Mvc.Rendering if (metadata != null) { // CheckBoxFor() case. That API does not support passing isChecked directly. - Contract.Assert(!isChecked.HasValue); + Debug.Assert(!isChecked.HasValue); if (metadata.Model != null) { @@ -312,10 +312,10 @@ namespace Microsoft.AspNet.Mvc.Rendering else { // RadioButtonFor() case. That API does not support passing isChecked directly. - Contract.Assert(!isChecked.HasValue); + Debug.Assert(!isChecked.HasValue); // Need a value to determine isChecked. - Contract.Assert(value != null); + Debug.Assert(value != null); var model = metadata.Model; var valueString = Convert.ToString(value, CultureInfo.CurrentCulture); diff --git a/src/Microsoft.AspNet.Mvc.Core/Routing/ActionSelectorDecisionTree.cs b/src/Microsoft.AspNet.Mvc.Core/Routing/ActionSelectorDecisionTree.cs index 0b360bfd6c..cdfe78488c 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Routing/ActionSelectorDecisionTree.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Routing/ActionSelectorDecisionTree.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; -using System.Diagnostics.Contracts; +using System.Diagnostics; using Microsoft.AspNet.Mvc.Internal.DecisionTree; namespace Microsoft.AspNet.Mvc.Routing @@ -73,7 +73,7 @@ namespace Microsoft.AspNet.Mvc.Routing } else if (hasNonCatchAll) { - Contract.Assert(filtered != null); + Debug.Assert(filtered != null); filtered.Add(action); } else diff --git a/src/Microsoft.AspNet.Mvc.Core/Routing/AttributeRoutePrecedence.cs b/src/Microsoft.AspNet.Mvc.Core/Routing/AttributeRoutePrecedence.cs index 1f7b7e49d5..b8b09bf041 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Routing/AttributeRoutePrecedence.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Routing/AttributeRoutePrecedence.cs @@ -3,7 +3,6 @@ using System; using System.Diagnostics; -using System.Diagnostics.Contracts; using System.Linq; using Microsoft.AspNet.Routing.Template; @@ -25,7 +24,7 @@ namespace Microsoft.AspNet.Mvc.Routing var segment = template.Segments[i]; var digit = ComputeDigit(segment); - Contract.Assert(digit >= 0 && digit < 10); + Debug.Assert(digit >= 0 && digit < 10); precedence += Decimal.Divide(digit, (decimal)Math.Pow(10, i)); } diff --git a/src/Microsoft.AspNet.Mvc.Core/UrlHelper.cs b/src/Microsoft.AspNet.Mvc.Core/UrlHelper.cs index 34c045a6dd..15308bfb22 100644 --- a/src/Microsoft.AspNet.Mvc.Core/UrlHelper.cs +++ b/src/Microsoft.AspNet.Mvc.Core/UrlHelper.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; -using System.Diagnostics.Contracts; +using System.Diagnostics; using System.Linq; using Microsoft.AspNet.Http; using Microsoft.AspNet.Routing; @@ -153,7 +153,7 @@ namespace Microsoft.AspNet.Mvc private string GenerateUrl(string protocol, string host, string path, string fragment) { // We should have a robust and centrallized version of this code. See HttpAbstractions#28 - Contract.Assert(path != null); + Debug.Assert(path != null); var url = path; if (!string.IsNullOrEmpty(fragment)) diff --git a/src/Microsoft.AspNet.Mvc.Core/ViewComponents/DefaultViewComponentSelector.cs b/src/Microsoft.AspNet.Mvc.Core/ViewComponents/DefaultViewComponentSelector.cs index c19c868d2d..c3b71029bb 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ViewComponents/DefaultViewComponentSelector.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ViewComponents/DefaultViewComponentSelector.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; -using System.Diagnostics.Contracts; +using System.Diagnostics; using System.Linq; using System.Reflection; using Microsoft.AspNet.Mvc.Core; @@ -81,7 +81,7 @@ namespace Microsoft.AspNet.Mvc Type = typeInfo.AsType(), }; - Contract.Assert(!string.IsNullOrEmpty(candidate.FullName)); + Debug.Assert(!string.IsNullOrEmpty(candidate.FullName)); var separatorIndex = candidate.FullName.LastIndexOf("."); if (separatorIndex >= 0) { diff --git a/src/Microsoft.AspNet.Mvc.ModelBinding/Binders/GenericModelBinder.cs b/src/Microsoft.AspNet.Mvc.ModelBinding/Binders/GenericModelBinder.cs index 851f9c3de8..0c53344599 100644 --- a/src/Microsoft.AspNet.Mvc.ModelBinding/Binders/GenericModelBinder.cs +++ b/src/Microsoft.AspNet.Mvc.ModelBinding/Binders/GenericModelBinder.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; -using System.Diagnostics.Contracts; +using System.Diagnostics; using System.Reflection; using System.Threading.Tasks; using Microsoft.AspNet.Mvc.ModelBinding.Internal; @@ -90,9 +90,9 @@ namespace Microsoft.AspNet.Mvc.ModelBinding Type openBinderType, Type modelType) { - Contract.Assert(supportedInterfaceType != null); - Contract.Assert(openBinderType != null); - Contract.Assert(modelType != null); + Debug.Assert(supportedInterfaceType != null); + Debug.Assert(openBinderType != null); + Debug.Assert(modelType != null); var modelTypeArguments = GetGenericBinderTypeArgs(supportedInterfaceType, modelType); diff --git a/src/Microsoft.AspNet.Mvc.ModelBinding/Internal/CollectionExtensions.cs b/src/Microsoft.AspNet.Mvc.ModelBinding/Internal/CollectionExtensions.cs index 652a0fe41d..5b269ef75e 100644 --- a/src/Microsoft.AspNet.Mvc.ModelBinding/Internal/CollectionExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.ModelBinding/Internal/CollectionExtensions.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; -using System.Diagnostics.Contracts; +using System.Diagnostics; namespace Microsoft.AspNet.Mvc.ModelBinding.Internal { @@ -15,7 +15,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Internal /// public static T[] ToArrayWithoutNulls(this ICollection collection) where T : class { - Contract.Assert(collection != null); + Debug.Assert(collection != null); var result = new T[collection.Count]; var count = 0; diff --git a/src/Microsoft.AspNet.Mvc.ModelBinding/Validation/DefaultBodyModelValidator.cs b/src/Microsoft.AspNet.Mvc.ModelBinding/Validation/DefaultBodyModelValidator.cs index 41cf7fe32a..c0e576a23e 100644 --- a/src/Microsoft.AspNet.Mvc.ModelBinding/Validation/DefaultBodyModelValidator.cs +++ b/src/Microsoft.AspNet.Mvc.ModelBinding/Validation/DefaultBodyModelValidator.cs @@ -4,7 +4,7 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Diagnostics.Contracts; +using System.Diagnostics; using System.Linq; using System.Runtime.CompilerServices; using Microsoft.AspNet.Mvc.ModelBinding.Internal; @@ -210,7 +210,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding private static Type GetElementType(Type type) { - Contract.Assert(typeof(IEnumerable).IsAssignableFrom(type)); + Debug.Assert(typeof(IEnumerable).IsAssignableFrom(type)); if (type.IsArray) { return type.GetElementType(); diff --git a/src/Microsoft.AspNet.Mvc.ModelBinding/ValueProviders/ReadableStringCollectionValueProvider.cs b/src/Microsoft.AspNet.Mvc.ModelBinding/ValueProviders/ReadableStringCollectionValueProvider.cs index 18dcba91f3..0ce9ff5d3b 100644 --- a/src/Microsoft.AspNet.Mvc.ModelBinding/ValueProviders/ReadableStringCollectionValueProvider.cs +++ b/src/Microsoft.AspNet.Mvc.ModelBinding/ValueProviders/ReadableStringCollectionValueProvider.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; -using System.Diagnostics.Contracts; +using System.Diagnostics; using System.Globalization; using System.Threading.Tasks; using Microsoft.AspNet.Http; @@ -85,7 +85,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding { if (_values == null) { - Contract.Assert(_valuesFactory != null); + Debug.Assert(_valuesFactory != null); _values = await _valuesFactory(); } diff --git a/src/Microsoft.AspNet.Mvc.ModelBinding/project.json b/src/Microsoft.AspNet.Mvc.ModelBinding/project.json index 74ee5165a6..91093fac9c 100644 --- a/src/Microsoft.AspNet.Mvc.ModelBinding/project.json +++ b/src/Microsoft.AspNet.Mvc.ModelBinding/project.json @@ -23,7 +23,6 @@ "dependencies": { "System.Collections.Concurrent": "4.0.10-beta-*", "System.ComponentModel.TypeConverter": "4.0.0-beta-*", - "System.Diagnostics.Contracts": "4.0.0-beta-*", "System.Reflection.TypeExtensions": "4.0.0-beta-*", "System.Runtime.Serialization.Primitives": "4.0.0-beta-*", "System.Runtime.Serialization.Xml": "4.0.10-beta-*", diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/project.json b/src/Microsoft.AspNet.Mvc.Razor.Host/project.json index 99b616113a..0b7ef3cc78 100644 --- a/src/Microsoft.AspNet.Mvc.Razor.Host/project.json +++ b/src/Microsoft.AspNet.Mvc.Razor.Host/project.json @@ -19,7 +19,6 @@ "aspnetcore50": { "dependencies": { "System.Collections.Concurrent": "4.0.10-beta-*", - "System.Diagnostics.Contracts": "4.0.0-beta-*", "Microsoft.Framework.Runtime.Interfaces": { "version": "1.0.0-*", "type": "build" } } } diff --git a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ContentNegotiator/CollectionExtensions.cs b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ContentNegotiator/CollectionExtensions.cs index c8d80c0048..f9d718e47f 100644 --- a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ContentNegotiator/CollectionExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ContentNegotiator/CollectionExtensions.cs @@ -4,7 +4,7 @@ #if ASPNETCORE50 using System.Collections.ObjectModel; -using System.Diagnostics.Contracts; +using System.Diagnostics; using System.Linq; namespace System.Collections.Generic @@ -19,7 +19,7 @@ namespace System.Collections.Generic /// public static T[] AppendAndReallocate(this T[] array, T value) { - Contract.Assert(array != null); + Debug.Assert(array != null); int originalLength = array.Length; T[] newArray = new T[originalLength + 1]; @@ -34,7 +34,7 @@ namespace System.Collections.Generic /// public static T[] AsArray(this IEnumerable values) { - Contract.Assert(values != null); + Debug.Assert(values != null); T[] array = values as T[]; if (array == null) @@ -50,7 +50,7 @@ namespace System.Collections.Generic /// public static Collection AsCollection(this IEnumerable enumerable) { - Contract.Assert(enumerable != null); + Debug.Assert(enumerable != null); Collection collection = enumerable as Collection; if (collection != null) @@ -71,7 +71,7 @@ namespace System.Collections.Generic /// public static IList AsIList(this IEnumerable enumerable) { - Contract.Assert(enumerable != null); + Debug.Assert(enumerable != null); IList list = enumerable as IList; if (list != null) @@ -87,7 +87,7 @@ namespace System.Collections.Generic /// public static List AsList(this IEnumerable enumerable) { - Contract.Assert(enumerable != null); + Debug.Assert(enumerable != null); List list = enumerable as List; if (list != null) @@ -107,8 +107,8 @@ namespace System.Collections.Generic /// public static void RemoveFrom(this List list, int start) { - Contract.Assert(list != null); - Contract.Assert(start >= 0 && start <= list.Count); + Debug.Assert(list != null); + Debug.Assert(start >= 0 && start <= list.Count); list.RemoveRange(start, list.Count - start); } @@ -118,8 +118,8 @@ namespace System.Collections.Generic /// public static T SingleDefaultOrError(this IList list, Action errorAction, TArg1 errorArg1) { - Contract.Assert(list != null); - Contract.Assert(errorAction != null); + Debug.Assert(list != null); + Debug.Assert(errorAction != null); switch (list.Count) { @@ -142,8 +142,8 @@ namespace System.Collections.Generic /// public static TMatch SingleOfTypeDefaultOrError(this IList list, Action errorAction, TArg1 errorArg1) where TMatch : class { - Contract.Assert(list != null); - Contract.Assert(errorAction != null); + Debug.Assert(list != null); + Debug.Assert(errorAction != null); TMatch result = null; for (int i = 0; i < list.Count; i++) @@ -170,7 +170,7 @@ namespace System.Collections.Generic /// public static T[] ToArrayWithoutNulls(this ICollection collection) where T : class { - Contract.Assert(collection != null); + Debug.Assert(collection != null); T[] result = new T[collection.Count]; int count = 0; @@ -199,8 +199,8 @@ namespace System.Collections.Generic /// public static Dictionary ToDictionaryFast(this TValue[] array, Func keySelector, IEqualityComparer comparer) { - Contract.Assert(array != null); - Contract.Assert(keySelector != null); + Debug.Assert(array != null); + Debug.Assert(keySelector != null); Dictionary dictionary = new Dictionary(array.Length, comparer); for (int i = 0; i < array.Length; i++) @@ -216,8 +216,8 @@ namespace System.Collections.Generic /// public static Dictionary ToDictionaryFast(this IList list, Func keySelector, IEqualityComparer comparer) { - Contract.Assert(list != null); - Contract.Assert(keySelector != null); + Debug.Assert(list != null); + Debug.Assert(keySelector != null); TValue[] array = list as TValue[]; if (array != null) @@ -232,8 +232,8 @@ namespace System.Collections.Generic /// public static Dictionary ToDictionaryFast(this IEnumerable enumerable, Func keySelector, IEqualityComparer comparer) { - Contract.Assert(enumerable != null); - Contract.Assert(keySelector != null); + Debug.Assert(enumerable != null); + Debug.Assert(keySelector != null); TValue[] array = enumerable as TValue[]; if (array != null) @@ -258,8 +258,8 @@ namespace System.Collections.Generic /// private static Dictionary ToDictionaryFastNoCheck(IList list, Func keySelector, IEqualityComparer comparer) { - Contract.Assert(list != null); - Contract.Assert(keySelector != null); + Debug.Assert(list != null); + Debug.Assert(keySelector != null); int listCount = list.Count; Dictionary dictionary = new Dictionary(listCount, comparer); diff --git a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ContentNegotiator/DefaultContentNegotiator.cs b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ContentNegotiator/DefaultContentNegotiator.cs index d8d8c5e1cd..6e85b923c4 100644 --- a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ContentNegotiator/DefaultContentNegotiator.cs +++ b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ContentNegotiator/DefaultContentNegotiator.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Diagnostics.Contracts; +using System.Diagnostics; using System.Linq; using System.Net.Http.Headers; using System.Text; @@ -451,7 +451,7 @@ namespace System.Net.Http.Formatting private static MediaTypeFormatter[] GetWritingFormatters(IEnumerable formatters) { - Contract.Assert(formatters != null); + Debug.Assert(formatters != null); MediaTypeFormatterCollection formatterCollection = formatters as MediaTypeFormatterCollection; return formatters.AsArray(); } diff --git a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ContentNegotiator/MediaTypeHeaderValueExtensions.cs b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ContentNegotiator/MediaTypeHeaderValueExtensions.cs index beb2b7a6cf..5cf91922bf 100644 --- a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ContentNegotiator/MediaTypeHeaderValueExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ContentNegotiator/MediaTypeHeaderValueExtensions.cs @@ -6,7 +6,7 @@ using Microsoft.AspNet.Mvc; using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Diagnostics.Contracts; +using System.Diagnostics; using System.Linq; using System.Net.Http.Headers; @@ -49,7 +49,7 @@ namespace System.Net.Http.Formatting public static bool IsSubsetOf(this MediaTypeHeaderValue mediaType1, MediaTypeHeaderValue mediaType2, out MediaTypeHeaderValueRange mediaType2Range) { // Performance-sensitive - Contract.Assert(mediaType1 != null); + Debug.Assert(mediaType1 != null); if (mediaType2 == null) { diff --git a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ContentNegotiator/MediaTypeWithQualityHeaderComparer.cs b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ContentNegotiator/MediaTypeWithQualityHeaderComparer.cs index 8ac2c8d48b..944a422dbd 100644 --- a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ContentNegotiator/MediaTypeWithQualityHeaderComparer.cs +++ b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ContentNegotiator/MediaTypeWithQualityHeaderComparer.cs @@ -4,7 +4,7 @@ #if ASPNETCORE50 using System.Collections.Generic; -using System.Diagnostics.Contracts; +using System.Diagnostics; using System.Net.Http.Headers; namespace System.Net.Http.Formatting @@ -38,8 +38,8 @@ namespace System.Net.Http.Formatting /// public int Compare(MediaTypeWithQualityHeaderValue mediaType1, MediaTypeWithQualityHeaderValue mediaType2) { - Contract.Assert(mediaType1 != null, "The 'mediaType1' parameter should not be null."); - Contract.Assert(mediaType2 != null, "The 'mediaType2' parameter should not be null."); + Debug.Assert(mediaType1 != null, "The 'mediaType1' parameter should not be null."); + Debug.Assert(mediaType2 != null, "The 'mediaType2' parameter should not be null."); if (Object.ReferenceEquals(mediaType1, mediaType2)) { @@ -90,8 +90,8 @@ namespace System.Net.Http.Formatting private static int CompareBasedOnQualityFactor(MediaTypeWithQualityHeaderValue mediaType1, MediaTypeWithQualityHeaderValue mediaType2) { - Contract.Assert(mediaType1 != null); - Contract.Assert(mediaType2 != null); + Debug.Assert(mediaType1 != null); + Debug.Assert(mediaType2 != null); double mediaType1Quality = mediaType1.Quality ?? FormattingUtilities.Match; double mediaType2Quality = mediaType2.Quality ?? FormattingUtilities.Match; diff --git a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ContentNegotiator/ParsedMediaTypeHeaderValue.cs b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ContentNegotiator/ParsedMediaTypeHeaderValue.cs index d0b966789b..6e3f4c2214 100644 --- a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ContentNegotiator/ParsedMediaTypeHeaderValue.cs +++ b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ContentNegotiator/ParsedMediaTypeHeaderValue.cs @@ -3,7 +3,7 @@ #if ASPNETCORE50 -using System.Diagnostics.Contracts; +using System.Diagnostics; using System.Net.Http.Headers; namespace System.Net.Http.Formatting @@ -21,10 +21,10 @@ namespace System.Net.Http.Formatting public ParsedMediaTypeHeaderValue(MediaTypeHeaderValue mediaTypeHeaderValue) { - Contract.Assert(mediaTypeHeaderValue != null); + Debug.Assert(mediaTypeHeaderValue != null); string mediaType = _mediaType = mediaTypeHeaderValue.MediaType; _delimiterIndex = mediaType.IndexOf(MediaTypeSubtypeDelimiter); - Contract.Assert(_delimiterIndex > 0, "The constructor of the MediaTypeHeaderValue would have failed if there wasn't a type and subtype."); + Debug.Assert(_delimiterIndex > 0, "The constructor of the MediaTypeHeaderValue would have failed if there wasn't a type and subtype."); _isAllMediaRange = false; _isSubtypeMediaRange = false; diff --git a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ContentNegotiator/StringWithQualityHeaderValueComparer.cs b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ContentNegotiator/StringWithQualityHeaderValueComparer.cs index 89a84a3a0e..a2c88fd244 100644 --- a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ContentNegotiator/StringWithQualityHeaderValueComparer.cs +++ b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ContentNegotiator/StringWithQualityHeaderValueComparer.cs @@ -4,7 +4,7 @@ #if ASPNETCORE50 using System.Collections.Generic; -using System.Diagnostics.Contracts; +using System.Diagnostics; using System.Net.Http.Headers; namespace System.Net.Http.Formatting @@ -43,8 +43,8 @@ namespace System.Net.Http.Formatting public int Compare(StringWithQualityHeaderValue stringWithQuality1, StringWithQualityHeaderValue stringWithQuality2) { - Contract.Assert(stringWithQuality1 != null); - Contract.Assert(stringWithQuality2 != null); + Debug.Assert(stringWithQuality1 != null); + Debug.Assert(stringWithQuality2 != null); double quality1 = stringWithQuality1.Quality ?? FormattingUtilities.Match; double quality2 = stringWithQuality2.Quality ?? FormattingUtilities.Match; diff --git a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/HttpRequestMessage/HttpRequestMessageFeature.cs b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/HttpRequestMessage/HttpRequestMessageFeature.cs index 19f7d90591..90781a1909 100644 --- a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/HttpRequestMessage/HttpRequestMessageFeature.cs +++ b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/HttpRequestMessage/HttpRequestMessageFeature.cs @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System.Diagnostics.Contracts; +using System.Diagnostics; using System.Net.Http; using Microsoft.AspNet.Http; @@ -60,7 +60,7 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim if (!message.Headers.TryAddWithoutValidation(header.Key, header.Value)) { var added = message.Content.Headers.TryAddWithoutValidation(header.Key, header.Value); - Contract.Assert(added); + Debug.Assert(added); } }