diff --git a/src/Microsoft.AspNet.Mvc.Abstractions/ModelBinding/ModelStateDictionary.cs b/src/Microsoft.AspNet.Mvc.Abstractions/ModelBinding/ModelStateDictionary.cs index e604b9d634..d2c6f3891c 100644 --- a/src/Microsoft.AspNet.Mvc.Abstractions/ModelBinding/ModelStateDictionary.cs +++ b/src/Microsoft.AspNet.Mvc.Abstractions/ModelBinding/ModelStateDictionary.cs @@ -385,26 +385,22 @@ namespace Microsoft.AspNet.Mvc.ModelBinding /// public void SetModelValue([NotNull] string key, ValueProviderResult valueProviderResult) { - // Avoid creating a new array for rawvalue if there's only one value. + // Avoid creating a new array for rawValue if there's only one value. object rawValue; if (valueProviderResult == ValueProviderResult.None) { rawValue = null; } - else if (valueProviderResult.Value != null) - { - rawValue = valueProviderResult.Value; - } else if (valueProviderResult.Length == 1) { rawValue = valueProviderResult.Values[0]; } else { - rawValue = valueProviderResult.Values; + rawValue = valueProviderResult.Values.ToArray(); } - SetModelValue(key, rawValue, (string)valueProviderResult); + SetModelValue(key, rawValue, valueProviderResult.ToString()); } /// diff --git a/src/Microsoft.AspNet.Mvc.Abstractions/ModelBinding/ValueProviderResult.cs b/src/Microsoft.AspNet.Mvc.Abstractions/ModelBinding/ValueProviderResult.cs index 0c3fcfe2b3..4392822f3d 100644 --- a/src/Microsoft.AspNet.Mvc.Abstractions/ModelBinding/ValueProviderResult.cs +++ b/src/Microsoft.AspNet.Mvc.Abstractions/ModelBinding/ValueProviderResult.cs @@ -4,9 +4,8 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Diagnostics; using System.Globalization; -using Microsoft.Framework.Internal; +using Microsoft.Framework.Primitives; namespace Microsoft.AspNet.Mvc.ModelBinding { @@ -38,9 +37,9 @@ namespace Microsoft.AspNet.Mvc.ModelBinding /// /// Creates a new using . /// - /// The submitted value. - public ValueProviderResult(string value) - : this(value, _invariantCulture) + /// The submitted values. + public ValueProviderResult(StringValues values) + : this(values, _invariantCulture) { } @@ -49,88 +48,36 @@ namespace Microsoft.AspNet.Mvc.ModelBinding /// /// The submitted value. /// The associated with this value. - public ValueProviderResult(string value, CultureInfo culture) + public ValueProviderResult(StringValues values, CultureInfo culture) { - if (value == null) - { - Value = null; - Values = None.Values; - } - else - { - Value = value; - Values = null; - } - + Values = values; Culture = culture ?? _invariantCulture; } - /// - /// Creates a new using . - /// - /// The submitted values. - public ValueProviderResult(string[] values) - : this(values, _invariantCulture) - { - } - - /// - /// Creates a new . - /// - /// The submitted values. - /// The associated with these values. - public ValueProviderResult(string[] values, CultureInfo culture) - { - if (values == null) - { - Value = null; - Values = None.Values; - } - else - { - Value = null; - Values = values; - } - - Culture = culture; - } - /// /// Gets or sets the associated with the values. /// public CultureInfo Culture { get; private set; } /// - /// Gets or sets a single value. Will be null if multiple values are present. + /// Gets or sets the values. /// - public string Value { get; private set; } - - /// - /// Gets or sets an array of values. Will be null if only a single value was provided. - /// - public string[] Values { get; private set; } + public StringValues Values { get; private set; } /// /// Gets the first value based on the order values were provided in the request. Use - /// to get a single value for processing regarless of whether a single or multiple values were provided + /// to get a single value for processing regardless of whether a single or multiple values were provided /// in the request. /// public string FirstValue { get { - if (Value != null) - { - return Value; - } - else if (Values != null && Values.Length > 0) - { - return Values[0]; - } - else + if (Values.Count == 0) { return null; } + return Values[0]; } } @@ -141,18 +88,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding { get { - if (Values != null) - { - return Values.Length; - } - else if (Value != null) - { - return 1; - } - else - { - return 0; - } + return Values.Count; } } @@ -172,9 +108,9 @@ namespace Microsoft.AspNet.Mvc.ModelBinding } else { - var x = (string[])this; - var y = (string[])other; - for (var i = 0; i < x.Length; i++) + var x = Values; + var y = other.Values; + for (var i = 0; i < x.Count; i++) { if (!string.Equals(x[i], y[i], StringComparison.Ordinal)) { @@ -188,28 +124,22 @@ namespace Microsoft.AspNet.Mvc.ModelBinding /// public override int GetHashCode() { - return ((string)this)?.GetHashCode() ?? 0; + return ToString().GetHashCode(); } /// public override string ToString() { - return (string)this; + return Values.ToString(); } /// - /// Gets an for this . + /// Gets an for this . /// - /// An . - public Enumerator GetEnumerator() + /// An . + public IEnumerator GetEnumerator() { - return new Enumerator(this); - } - - /// - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); + return ((IEnumerable)Values).GetEnumerator(); } /// @@ -225,22 +155,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding /// The . public static explicit operator string(ValueProviderResult result) { - if (result.Values == null) - { - return result.Value; - } - else if (result.Values.Length == 0) - { - return null; - } - else if (result.Values.Length == 1) - { - return result.Values[0]; - } - else - { - return string.Join(",", result.Values); - } + return result.Values; } /// @@ -250,18 +165,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding /// The . public static explicit operator string[](ValueProviderResult result) { - if (result.Values != null) - { - return result.Values; - } - else if (result.Value != null) - { - return new string[] { result.Value }; - } - else - { - return None.Values; - } + return result.Values; } /// @@ -285,71 +189,5 @@ namespace Microsoft.AspNet.Mvc.ModelBinding { return !x.Equals(y); } - - /// - /// An enumerator for . - /// - public struct Enumerator : IEnumerator - { - private readonly ValueProviderResult _result; - private readonly int _length; - private int _index; - - /// - /// Creates a new . - /// - /// The . - public Enumerator(ValueProviderResult result) - { - _result = result; - _index = -1; - _length = result.Length; - Current = null; - } - - /// - public string Current { get; private set; } - - /// - object IEnumerator.Current => Current; - - /// - public void Dispose() - { - } - - /// - public bool MoveNext() - { - ++_index; - if (_index < _length) - { - if (_result.Values != null) - { - Debug.Assert(_index < _result.Values.Length); - Current = _result.Values[_index]; - return true; - } - else if (_result.Value != null && _index == 0) - { - Current = _result.Value; - return true; - } - else - { - return false; - } - } - - Current = null; - return false; - } - - /// - public void Reset() - { - _index = -1; - } - } } } diff --git a/src/Microsoft.AspNet.Mvc.Core/CreatedAtActionResult.cs b/src/Microsoft.AspNet.Mvc.Core/CreatedAtActionResult.cs index 2e1c5c7aba..709d6b2558 100644 --- a/src/Microsoft.AspNet.Mvc.Core/CreatedAtActionResult.cs +++ b/src/Microsoft.AspNet.Mvc.Core/CreatedAtActionResult.cs @@ -7,6 +7,7 @@ using Microsoft.AspNet.Http; using Microsoft.AspNet.Mvc.Core; using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Internal; +using Microsoft.Net.Http.Headers; namespace Microsoft.AspNet.Mvc { @@ -73,7 +74,7 @@ namespace Microsoft.AspNet.Mvc throw new InvalidOperationException(Resources.NoRoutesMatched); } - context.HttpContext.Response.Headers.Set("Location", url); + context.HttpContext.Response.Headers[HeaderNames.Location] = url; } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.Core/CreatedAtRouteResult.cs b/src/Microsoft.AspNet.Mvc.Core/CreatedAtRouteResult.cs index 1767fed7bf..5131136bf1 100644 --- a/src/Microsoft.AspNet.Mvc.Core/CreatedAtRouteResult.cs +++ b/src/Microsoft.AspNet.Mvc.Core/CreatedAtRouteResult.cs @@ -7,6 +7,7 @@ using Microsoft.AspNet.Http; using Microsoft.AspNet.Mvc.Core; using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Internal; +using Microsoft.Net.Http.Headers; namespace Microsoft.AspNet.Mvc { @@ -70,7 +71,7 @@ namespace Microsoft.AspNet.Mvc throw new InvalidOperationException(Resources.NoRoutesMatched); } - context.HttpContext.Response.Headers.Set("Location", url); + context.HttpContext.Response.Headers[HeaderNames.Location] = url; } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.Core/CreatedResult.cs b/src/Microsoft.AspNet.Mvc.Core/CreatedResult.cs index 31801556ed..af7148657f 100644 --- a/src/Microsoft.AspNet.Mvc.Core/CreatedResult.cs +++ b/src/Microsoft.AspNet.Mvc.Core/CreatedResult.cs @@ -4,6 +4,7 @@ using System; using Microsoft.AspNet.Http; using Microsoft.Framework.Internal; +using Microsoft.Net.Http.Headers; namespace Microsoft.AspNet.Mvc { @@ -50,7 +51,7 @@ namespace Microsoft.AspNet.Mvc /// protected override void OnFormatting([NotNull] ActionContext context) { - context.HttpContext.Response.Headers.Set("Location", Location); + context.HttpContext.Response.Headers[HeaderNames.Location] = Location; } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.Core/FileResult.cs b/src/Microsoft.AspNet.Mvc.Core/FileResult.cs index 814be3e544..d33ce318c4 100644 --- a/src/Microsoft.AspNet.Mvc.Core/FileResult.cs +++ b/src/Microsoft.AspNet.Mvc.Core/FileResult.cs @@ -68,7 +68,7 @@ namespace Microsoft.AspNet.Mvc // basis for the actual filename, where possible. var cd = new ContentDispositionHeaderValue("attachment"); cd.SetHttpFileName(FileDownloadName); - context.HttpContext.Response.Headers.Set(HeaderNames.ContentDisposition, cd.ToString()); + context.HttpContext.Response.Headers[HeaderNames.ContentDisposition] = cd.ToString(); } // We aren't flowing the cancellation token appropriately, see diff --git a/src/Microsoft.AspNet.Mvc.Core/HttpMethodConstraint.cs b/src/Microsoft.AspNet.Mvc.Core/HttpMethodConstraint.cs index edabe282c8..9578de7981 100644 --- a/src/Microsoft.AspNet.Mvc.Core/HttpMethodConstraint.cs +++ b/src/Microsoft.AspNet.Mvc.Core/HttpMethodConstraint.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using Microsoft.Framework.Internal; +using Microsoft.Framework.Primitives; namespace Microsoft.AspNet.Mvc { @@ -62,12 +63,12 @@ namespace Microsoft.AspNet.Mvc if (request.Headers.ContainsKey(OriginHeader)) { // Update the http method if it is preflight request. - var accessControlRequestMethod = request.Headers.Get(AccessControlRequestMethod); + var accessControlRequestMethod = request.Headers[AccessControlRequestMethod]; if (string.Equals( request.Method, PreflightHttpMethod, StringComparison.Ordinal) && - accessControlRequestMethod != null) + !StringValues.IsNullOrEmpty(accessControlRequestMethod)) { method = accessControlRequestMethod; } diff --git a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/FormCollectionModelBinder.cs b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/FormCollectionModelBinder.cs index 274a081df3..7135bd52d2 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/FormCollectionModelBinder.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/FormCollectionModelBinder.cs @@ -8,6 +8,7 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.AspNet.Http; using Microsoft.Framework.Internal; +using Microsoft.Framework.Primitives; namespace Microsoft.AspNet.Mvc.ModelBinding { @@ -51,11 +52,11 @@ namespace Microsoft.AspNet.Mvc.ModelBinding private class EmptyFormCollection : IFormCollection { - public string this[string key] + public StringValues this[string key] { get { - return null; + return StringValues.Empty; } } @@ -93,12 +94,12 @@ namespace Microsoft.AspNet.Mvc.ModelBinding return null; } - public IEnumerator> GetEnumerator() + public IEnumerator> GetEnumerator() { - return Enumerable.Empty>().GetEnumerator(); + return Enumerable.Empty>().GetEnumerator(); } - public IList GetValues(string key) + public IList GetValues(string key) { return null; } diff --git a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/HeaderModelBinder.cs b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/HeaderModelBinder.cs index a7b5cbb1a9..addca0ccda 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/HeaderModelBinder.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/HeaderModelBinder.cs @@ -2,11 +2,11 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; -using System.Linq; #if DNXCORE50 using System.Reflection; #endif using System.Threading.Tasks; +using Microsoft.AspNet.Http; using Microsoft.Framework.Internal; namespace Microsoft.AspNet.Mvc.ModelBinding @@ -36,7 +36,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding object model = null; if (bindingContext.ModelType == typeof(string)) { - var value = request.Headers.Get(headerName); + string value = request.Headers[headerName]; if (value != null) { model = value; @@ -45,7 +45,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding else if (typeof(IEnumerable).IsAssignableFrom(bindingContext.ModelType)) { var values = request.Headers.GetCommaSeparatedValues(headerName); - if (values != null) + if (values.Length > 0) { model = ModelBindingHelper.ConvertValuesToCollectionType( bindingContext.ModelType, @@ -60,11 +60,11 @@ namespace Microsoft.AspNet.Mvc.ModelBinding bindingContext.ModelName, bindingContext.ModelMetadata, model); - + bindingContext.ModelState.SetModelValue( - bindingContext.ModelName, - request.Headers.GetCommaSeparatedValues(headerName).ToArray(), - request.Headers.Get(headerName)); + bindingContext.ModelName, + request.Headers.GetCommaSeparatedValues(headerName), + request.Headers[headerName]); } return Task.FromResult( diff --git a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/JQueryFormValueProvider.cs b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/JQueryFormValueProvider.cs index d72fbaa0e2..264011c196 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/JQueryFormValueProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/JQueryFormValueProvider.cs @@ -1,11 +1,12 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using System.Collections.Generic; -using System.Diagnostics; using System.Globalization; using System.Threading.Tasks; using Microsoft.Framework.Internal; +using Microsoft.Framework.Primitives; namespace Microsoft.AspNet.Mvc.ModelBinding { @@ -14,8 +15,8 @@ namespace Microsoft.AspNet.Mvc.ModelBinding /// public class JQueryFormValueProvider : BindingSourceValueProvider, IEnumerableValueProvider { + private readonly IDictionary _values; private PrefixContainer _prefixContainer; - private readonly IDictionary _values; /// /// Initializes a new instance of the class. @@ -25,7 +26,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding /// The culture to return with ValueProviderResult instances. public JQueryFormValueProvider( [NotNull] BindingSource bindingSource, - [NotNull] IDictionary values, + [NotNull] IDictionary values, CultureInfo culture) : base(bindingSource) { @@ -64,8 +65,8 @@ namespace Microsoft.AspNet.Mvc.ModelBinding /// public override ValueProviderResult GetValue(string key) { - string[] values; - if (_values.TryGetValue(key, out values) && values != null && values.Length > 0) + StringValues values; + if (_values.TryGetValue(key, out values) && values.Count > 0) { return new ValueProviderResult(values, Culture); } diff --git a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/JQueryFormValueProviderFactory.cs b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/JQueryFormValueProviderFactory.cs index c1d289cb62..c416364a48 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/JQueryFormValueProviderFactory.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/JQueryFormValueProviderFactory.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Microsoft.AspNet.Http; using Microsoft.AspNet.Mvc.Core; using Microsoft.Framework.Internal; +using Microsoft.Framework.Primitives; namespace Microsoft.AspNet.Mvc.ModelBinding { @@ -29,11 +30,11 @@ namespace Microsoft.AspNet.Mvc.ModelBinding return null; } - private static async Task> GetValueCollectionAsync(HttpRequest request) + private static async Task> GetValueCollectionAsync(HttpRequest request) { var formCollection = await request.ReadFormAsync(); - var dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase); + var dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase); foreach (var entry in formCollection) { var key = NormalizeJQueryToMvc(entry.Key); diff --git a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/ReadableStringCollectionValueProvider.cs b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/ReadableStringCollectionValueProvider.cs index 305c053cf2..5bb47fa870 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/ReadableStringCollectionValueProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/ReadableStringCollectionValueProvider.cs @@ -1,12 +1,8 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; using System.Collections.Generic; -using System.Diagnostics; using System.Globalization; -using System.Linq; -using System.Threading.Tasks; using Microsoft.AspNet.Http; using Microsoft.Framework.Internal; @@ -73,14 +69,14 @@ namespace Microsoft.AspNet.Mvc.ModelBinding /// public override ValueProviderResult GetValue([NotNull] string key) { - var values = _values.GetValues(key); - if (values == null) + var values = _values[key]; + if (values.Count == 0) { return ValueProviderResult.None; } else { - return new ValueProviderResult(values.ToArray(), _culture); + return new ValueProviderResult(values, _culture); } } } diff --git a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/ValueProviderResultExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/ValueProviderResultExtensions.cs index 0cee5ab03b..a5dc10f3fc 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/ValueProviderResultExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/ValueProviderResultExtensions.cs @@ -21,7 +21,15 @@ namespace Microsoft.AspNet.Mvc.ModelBinding /// public static T ConvertTo(this ValueProviderResult result) { - var valueToConvert = (object)result.Values ?? (object)result.Value; + object valueToConvert = null; + if (result.Values.Count == 1) + { + valueToConvert = result.Values[0]; + } + else if (result.Values.Count > 1) + { + valueToConvert = result.Values.ToArray(); + } return ModelBindingHelper.ConvertTo(valueToConvert, result.Culture); } @@ -35,7 +43,15 @@ namespace Microsoft.AspNet.Mvc.ModelBinding /// public static object ConvertTo(this ValueProviderResult result, [NotNull] Type type) { - var valueToConvert = (object)result.Values ?? (object)result.Value; + object valueToConvert = null; + if (result.Values.Count == 1) + { + valueToConvert = result.Values[0]; + } + else if (result.Values.Count > 1) + { + valueToConvert = result.Values.ToArray(); + } return ModelBindingHelper.ConvertTo(valueToConvert, type, result.Culture); } } diff --git a/src/Microsoft.AspNet.Mvc.Core/ResponseCacheFilter.cs b/src/Microsoft.AspNet.Mvc.Core/ResponseCacheFilter.cs index ebe249a72b..dd45ce54b0 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ResponseCacheFilter.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ResponseCacheFilter.cs @@ -4,8 +4,10 @@ using System; using System.Globalization; using System.Linq; +using Microsoft.AspNet.Http; using Microsoft.AspNet.Mvc.Core; using Microsoft.Framework.Internal; +using Microsoft.Net.Http.Headers; namespace Microsoft.AspNet.Mvc { @@ -94,24 +96,24 @@ namespace Microsoft.AspNet.Mvc var headers = context.HttpContext.Response.Headers; // Clear all headers - headers.Remove("Vary"); - headers.Remove("Cache-control"); - headers.Remove("Pragma"); + headers.Remove(HeaderNames.Vary); + headers.Remove(HeaderNames.CacheControl); + headers.Remove(HeaderNames.Pragma); if (!string.IsNullOrEmpty(VaryByHeader)) { - headers.Set("Vary", VaryByHeader); + headers[HeaderNames.Vary] = VaryByHeader; } if (NoStore) { - headers.Set("Cache-control", "no-store"); + headers[HeaderNames.CacheControl] = "no-store"; // Cache-control: no-store, no-cache is valid. if (Location == ResponseCacheLocation.None) { - headers.Append("Cache-control", "no-cache"); - headers.Set("Pragma", "no-cache"); + headers.AppendCommaSeparatedValues(HeaderNames.CacheControl, "no-cache"); + headers[HeaderNames.Pragma] = "no-cache"; } } else @@ -127,7 +129,7 @@ namespace Microsoft.AspNet.Mvc break; case ResponseCacheLocation.None: cacheControlValue = "no-cache"; - headers.Set("Pragma", "no-cache"); + headers[HeaderNames.Pragma] = "no-cache"; break; } @@ -140,7 +142,7 @@ namespace Microsoft.AspNet.Mvc if (cacheControlValue != null) { - headers.Set("Cache-control", cacheControlValue); + headers[HeaderNames.CacheControl] = cacheControlValue; } } } diff --git a/src/Microsoft.AspNet.Mvc.Cors/CorsAuthorizationFilter.cs b/src/Microsoft.AspNet.Mvc.Cors/CorsAuthorizationFilter.cs index bc07ef6373..65f3fb9720 100644 --- a/src/Microsoft.AspNet.Mvc.Cors/CorsAuthorizationFilter.cs +++ b/src/Microsoft.AspNet.Mvc.Cors/CorsAuthorizationFilter.cs @@ -8,6 +8,7 @@ using System.Threading.Tasks; using Microsoft.AspNet.Cors.Core; using Microsoft.AspNet.Http; using Microsoft.Framework.Internal; +using Microsoft.Framework.Primitives; namespace Microsoft.AspNet.Mvc { @@ -20,7 +21,7 @@ namespace Microsoft.AspNet.Mvc private ICorsPolicyProvider _corsPolicyProvider; /// - /// Creates a new instace of . + /// Creates a new instance of . /// /// The . /// The . @@ -63,12 +64,12 @@ namespace Microsoft.AspNet.Mvc _corsService.ApplyResult(result, context.HttpContext.Response); var accessControlRequestMethod = - httpContext.Request.Headers.Get(CorsConstants.AccessControlRequestMethod); + httpContext.Request.Headers[CorsConstants.AccessControlRequestMethod]; if (string.Equals( request.Method, CorsConstants.PreflightHttpMethod, StringComparison.Ordinal) && - accessControlRequestMethod != null) + !StringValues.IsNullOrEmpty(accessControlRequestMethod)) { // If this was a preflight, there is no need to run anything else. // Also the response is always 200 so that anyone after mvc can handle the pre flight request. diff --git a/src/Microsoft.AspNet.Mvc.Cors/DisableCorsAuthorizationFilter.cs b/src/Microsoft.AspNet.Mvc.Cors/DisableCorsAuthorizationFilter.cs index 4885d622f5..90b25b4057 100644 --- a/src/Microsoft.AspNet.Mvc.Cors/DisableCorsAuthorizationFilter.cs +++ b/src/Microsoft.AspNet.Mvc.Cors/DisableCorsAuthorizationFilter.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using Microsoft.AspNet.Cors.Core; using Microsoft.AspNet.Http; using Microsoft.Framework.Internal; +using Microsoft.Framework.Primitives; namespace Microsoft.AspNet.Mvc { @@ -27,12 +28,12 @@ namespace Microsoft.AspNet.Mvc public Task OnAuthorizationAsync([NotNull] AuthorizationContext context) { var accessControlRequestMethod = - context.HttpContext.Request.Headers.Get(CorsConstants.AccessControlRequestMethod); + context.HttpContext.Request.Headers[CorsConstants.AccessControlRequestMethod]; if (string.Equals( context.HttpContext.Request.Method, CorsConstants.PreflightHttpMethod, StringComparison.Ordinal) && - accessControlRequestMethod != null) + !StringValues.IsNullOrEmpty(accessControlRequestMethod)) { // Short circuit if the request is preflight as that should not result in action execution. context.Result = new HttpStatusCodeResult(StatusCodes.Status200OK); diff --git a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/Formatters/HttpResponseMessageOutputFormatter.cs b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/Formatters/HttpResponseMessageOutputFormatter.cs index ce6f977a51..161207ff5c 100644 --- a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/Formatters/HttpResponseMessageOutputFormatter.cs +++ b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/Formatters/HttpResponseMessageOutputFormatter.cs @@ -5,6 +5,7 @@ using System; using System.Linq; using System.Net.Http; using System.Threading.Tasks; +using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Features; using Microsoft.Net.Http.Headers; @@ -53,7 +54,7 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim foreach (var header in responseHeaders) { - response.Headers.AppendValues(header.Key, header.Value.ToArray()); + response.Headers.Append(header.Key, header.Value.ToArray()); } if (responseMessage.Content != null) @@ -67,7 +68,7 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim foreach (var header in contentHeaders) { - response.Headers.AppendValues(header.Key, header.Value.ToArray()); + response.Headers.Append(header.Key, header.Value.ToArray()); } await responseMessage.Content.CopyToAsync(response.Body); diff --git a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/HttpRequestMessage/HttpRequestMessageFeature.cs b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/HttpRequestMessage/HttpRequestMessageFeature.cs index a0c2ae056b..0af8ba7221 100644 --- a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/HttpRequestMessage/HttpRequestMessageFeature.cs +++ b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/HttpRequestMessage/HttpRequestMessageFeature.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System.Collections.Generic; using System.Diagnostics; using System.Net.Http; using Microsoft.AspNet.Http; @@ -58,9 +59,9 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim { // Every header should be able to fit into one of the two header collections. // Try message.Headers first since that accepts more of them. - if (!message.Headers.TryAddWithoutValidation(header.Key, header.Value)) + if (!message.Headers.TryAddWithoutValidation(header.Key, (IEnumerable)header.Value)) { - var added = message.Content.Headers.TryAddWithoutValidation(header.Key, header.Value); + var added = message.Content.Headers.TryAddWithoutValidation(header.Key, (IEnumerable)header.Value); Debug.Assert(added); } } diff --git a/test/Microsoft.AspNet.Mvc.Abstractions.Test/ModelBinding/ValueProviderResultTest.cs b/test/Microsoft.AspNet.Mvc.Abstractions.Test/ModelBinding/ValueProviderResultTest.cs index ea875a1ad1..062f296a19 100644 --- a/test/Microsoft.AspNet.Mvc.Abstractions.Test/ModelBinding/ValueProviderResultTest.cs +++ b/test/Microsoft.AspNet.Mvc.Abstractions.Test/ModelBinding/ValueProviderResultTest.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using Microsoft.Framework.Primitives; using Xunit; namespace Microsoft.AspNet.Mvc.ModelBinding @@ -15,12 +16,11 @@ namespace Microsoft.AspNet.Mvc.ModelBinding // Assert Assert.Equal(0, result.Length); - Assert.Null(result.Value); Assert.Empty(result.Values); Assert.Null(result.FirstValue); Assert.Equal(ValueProviderResult.None, result); Assert.Null((string)result); - Assert.Empty((string[])result); + Assert.Null((string[])result); } [Fact] @@ -31,12 +31,11 @@ namespace Microsoft.AspNet.Mvc.ModelBinding // Assert Assert.Equal(0, result.Length); - Assert.Null(result.Value); Assert.Empty(result.Values); Assert.Null(result.FirstValue); Assert.Equal(ValueProviderResult.None, result); Assert.Null((string)result); - Assert.Empty((string[])result); + Assert.Null((string[])result); } [Fact] @@ -47,10 +46,10 @@ namespace Microsoft.AspNet.Mvc.ModelBinding // Assert Assert.Equal(0, result.Length); - Assert.Null(result.Value); Assert.Empty(result.Values); Assert.Null(result.FirstValue); Assert.Equal(ValueProviderResult.None, result); + Assert.Equal(ValueProviderResult.None, new ValueProviderResult(new StringValues())); Assert.Null((string)result); Assert.Empty((string[])result); } @@ -63,8 +62,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding // Assert Assert.Equal(1, result.Length); - Assert.Equal("Hi There", result.Value); - Assert.Null(result.Values); + Assert.Equal("Hi There", result.Values); Assert.Equal("Hi There", result.FirstValue); Assert.NotEqual(ValueProviderResult.None, result); Assert.Equal("Hi There", (string)result); @@ -79,7 +77,6 @@ namespace Microsoft.AspNet.Mvc.ModelBinding // Assert Assert.Equal(2, result.Length); - Assert.Null(result.Value); Assert.Equal(new string[] { "Hi", "There" }, result.Values); Assert.Equal("Hi", result.FirstValue); Assert.NotEqual(ValueProviderResult.None, result); diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/CreatedAtActionResultTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/CreatedAtActionResultTests.cs index 5d2da109ac..4c3736a536 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/CreatedAtActionResultTests.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/CreatedAtActionResultTests.cs @@ -70,7 +70,7 @@ namespace Microsoft.AspNet.Mvc var httpResponse = new Mock(); httpResponse.SetupProperty(o => o.StatusCode); httpResponse.Setup(o => o.Headers).Returns( - new HeaderDictionary(new Dictionary())); + new HeaderDictionary()); httpResponse.SetupGet(o => o.Body).Returns(stream); return httpResponse.Object; } diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/CreatedResultTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/CreatedResultTests.cs index 7b556a8838..49d31674eb 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/CreatedResultTests.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/CreatedResultTests.cs @@ -53,7 +53,7 @@ namespace Microsoft.AspNet.Mvc var location = "/test/"; var httpContext = GetHttpContext(); var actionContext = GetActionContext(httpContext); - httpContext.Response.Headers.Set("Location", "/different/location/"); + httpContext.Response.Headers["Location"] = "/different/location/"; var result = new CreatedResult(location, "testInput"); // Act diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/FormatFilterTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/FormatFilterTest.cs index 5f855d6c3a..0ade1df1b3 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/FormatFilterTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/FormatFilterTest.cs @@ -72,7 +72,7 @@ namespace Microsoft.AspNet.Mvc // Query contains xml httpContext.Setup(c => c.Request.Query.ContainsKey("format")).Returns(true); - httpContext.Setup(c => c.Request.Query.Get("format")).Returns("xml"); + httpContext.Setup(c => c.Request.Query["format"]).Returns("xml"); // Routedata contains json var data = new RouteData(); diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/CompositeValueProviderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/CompositeValueProviderTest.cs index 6a0896429c..6af1e67834 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/CompositeValueProviderTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/CompositeValueProviderTest.cs @@ -8,6 +8,7 @@ using System.Collections.Generic; using System.Globalization; #if DNX451 using System.Threading.Tasks; +using Microsoft.Framework.Primitives; using Moq; using Xunit; #endif @@ -18,11 +19,11 @@ namespace Microsoft.AspNet.Mvc.ModelBinding { protected override IEnumerableValueProvider GetEnumerableValueProvider( BindingSource bindingSource, - IDictionary values, + IDictionary values, CultureInfo culture) { var emptyValueProvider = - new JQueryFormValueProvider(bindingSource, new Dictionary(), culture); + new JQueryFormValueProvider(bindingSource, new Dictionary(), culture); var valueProvider = new JQueryFormValueProvider(bindingSource, values, culture); return new CompositeValueProvider(new[] { emptyValueProvider, valueProvider }); diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/DictionaryModelBinderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/DictionaryModelBinderTest.cs index 15f71c2eb9..14afbb6e9f 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/DictionaryModelBinderTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/DictionaryModelBinderTest.cs @@ -8,6 +8,7 @@ using System.Globalization; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNet.Http.Internal; +using Microsoft.Framework.Primitives; using Moq; using Xunit; @@ -453,10 +454,10 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Test string keyFormat, IDictionary dictionary) { - // Convert to an IDictionary then wrap it up. + // Convert to an IDictionary then wrap it up. var backingStore = dictionary.ToDictionary( kvp => string.Format(keyFormat, kvp.Key), - kvp => new[] { kvp.Value }); + kvp => (StringValues)kvp.Value); var stringCollection = new ReadableStringCollection(backingStore); return new ReadableStringCollectionValueProvider( diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/EnumerableValueProviderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/EnumerableValueProviderTest.cs index 9eef0f2438..118a4d71a3 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/EnumerableValueProviderTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/EnumerableValueProviderTest.cs @@ -5,34 +5,35 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Threading.Tasks; +using Microsoft.Framework.Primitives; using Xunit; namespace Microsoft.AspNet.Mvc.ModelBinding { public abstract class EnumerableValueProviderTest { - private static readonly IDictionary _backingStore = new Dictionary + private static readonly IDictionary _backingStore = new Dictionary { { "some", new[] { "someValue1", "someValue2" } }, - { "null_value", null }, + { "null_value", StringValues.Empty }, { "prefix.name", new[] { "someOtherValue" } }, - { "prefix.null_value", null }, - { "prefix.property1.property", null }, - { "prefix.property2[index]", null }, - { "prefix[index1]", null }, - { "prefix[index1].property1", null }, - { "prefix[index1].property2", null }, - { "prefix[index2].property", null }, - { "[index]", null }, - { "[index].property", null }, - { "[index][anotherIndex]", null }, + { "prefix.null_value", StringValues.Empty }, + { "prefix.property1.property", StringValues.Empty }, + { "prefix.property2[index]", StringValues.Empty }, + { "prefix[index1]", StringValues.Empty }, + { "prefix[index1].property1", StringValues.Empty }, + { "prefix[index1].property2", StringValues.Empty }, + { "prefix[index2].property", StringValues.Empty }, + { "[index]", StringValues.Empty }, + { "[index].property", StringValues.Empty }, + { "[index][anotherIndex]", StringValues.Empty }, }; [Fact] public void ContainsPrefix_WithEmptyCollection_ReturnsFalseForEmptyPrefix() { // Arrange - var backingStore = new Dictionary(); + var backingStore = new Dictionary(); var valueProvider = GetEnumerableValueProvider(BindingSource.Query, backingStore, culture: null); // Act @@ -209,7 +210,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding public void GetValue_NullMultipleValue() { // Arrange - var backingStore = new Dictionary + var backingStore = new Dictionary { { "key", new string[] { null, null, "value" } }, }; @@ -278,7 +279,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding private IBindingSourceValueProvider GetBindingSourceValueProvider( BindingSource bindingSource, - IDictionary values, + IDictionary values, CultureInfo culture) { var provider = GetEnumerableValueProvider(bindingSource, values, culture) as IBindingSourceValueProvider; @@ -291,7 +292,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding protected abstract IEnumerableValueProvider GetEnumerableValueProvider( BindingSource bindingSource, - IDictionary values, + IDictionary values, CultureInfo culture); } } diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/FormCollectionModelBinderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/FormCollectionModelBinderTest.cs index b7ec8e7a30..bae7867255 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/FormCollectionModelBinderTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/FormCollectionModelBinderTest.cs @@ -9,6 +9,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Internal; +using Microsoft.Framework.Primitives; using Moq; using Xunit; @@ -20,10 +21,10 @@ namespace Microsoft.AspNet.Mvc.ModelBinding public async Task FormCollectionModelBinder_ValidType_BindSuccessful() { // Arrange - var formCollection = new FormCollection(new Dictionary + var formCollection = new FormCollection(new Dictionary { - { "field1", new string[] { "value1" } }, - { "field2", new string[] { "value2" } } + { "field1", "value1" }, + { "field2", "value2" } }); var httpContext = GetMockHttpContext(formCollection); var bindingContext = GetBindingContext(typeof(IFormCollection), httpContext); @@ -48,10 +49,10 @@ namespace Microsoft.AspNet.Mvc.ModelBinding public async Task FormCollectionModelBinder_InvalidType_BindFails() { // Arrange - var formCollection = new FormCollection(new Dictionary + var formCollection = new FormCollection(new Dictionary { - { "field1", new string[] { "value1" } }, - { "field2", new string[] { "value2" } } + { "field1", "value1" }, + { "field2", "value2" } }); var httpContext = GetMockHttpContext(formCollection); var bindingContext = GetBindingContext(typeof(string), httpContext); @@ -69,9 +70,9 @@ namespace Microsoft.AspNet.Mvc.ModelBinding public async Task FormCollectionModelBinder_FormCollectionConcreteType_BindFails() { // Arrange - var formCollection = new FormCollection(new Dictionary + var formCollection = new FormCollection(new Dictionary { - { "field1", new string[] { "value1" } }, + { "field1", "value1" }, { "field2", new string[] { "value2" } } }); var httpContext = GetMockHttpContext(formCollection); @@ -131,11 +132,11 @@ namespace Microsoft.AspNet.Mvc.ModelBinding private class MyFormCollection : ReadableStringCollection, IFormCollection { - public MyFormCollection(IDictionary store) : this(store, new FormFileCollection()) + public MyFormCollection(IDictionary store) : this(store, new FormFileCollection()) { } - public MyFormCollection(IDictionary store, IFormFileCollection files) : base(store) + public MyFormCollection(IDictionary store, IFormFileCollection files) : base(store) { Files = files; } diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/FormValueProviderFactoryTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/FormValueProviderFactoryTest.cs index dffcf21cb4..73db5084ad 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/FormValueProviderFactoryTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/FormValueProviderFactoryTest.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Globalization; using System.Threading.Tasks; using Microsoft.AspNet.Http.Internal; +using Microsoft.Framework.Primitives; using Xunit; namespace Microsoft.AspNet.Mvc.ModelBinding.Test @@ -52,7 +53,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Test if (context.Request.HasFormContentType) { - context.Request.Form = new FormCollection(new Dictionary()); + context.Request.Form = new FormCollection(new Dictionary()); } return new ValueProviderFactoryContext( diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/JQueryFormValueProviderFactoryTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/JQueryFormValueProviderFactoryTest.cs index 76fdd6f600..c46be451cc 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/JQueryFormValueProviderFactoryTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/JQueryFormValueProviderFactoryTest.cs @@ -6,13 +6,14 @@ using System.Collections.Generic; using System.Globalization; using System.Threading.Tasks; using Microsoft.AspNet.Http.Internal; +using Microsoft.Framework.Primitives; using Xunit; namespace Microsoft.AspNet.Mvc.ModelBinding.Test { public class JQueryFormValueProviderFactoryTest { - private static readonly IDictionary _backingStore = new Dictionary + private static readonly IDictionary _backingStore = new Dictionary { { "[]", new[] { "found" } }, { "[]property1", new[] { "found" } }, @@ -115,14 +116,14 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Test private static ValueProviderFactoryContext CreateContext( string contentType, - IDictionary formValues) + IDictionary formValues) { var context = new DefaultHttpContext(); context.Request.ContentType = contentType; if (context.Request.HasFormContentType) { - context.Request.Form = new FormCollection(formValues ?? new Dictionary()); + context.Request.Form = new FormCollection(formValues ?? new Dictionary()); } return new ValueProviderFactoryContext( diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/JQueryFormValueProviderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/JQueryFormValueProviderTest.cs index 4fa1b91d66..bd31ea857e 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/JQueryFormValueProviderTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/JQueryFormValueProviderTest.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Globalization; +using Microsoft.Framework.Primitives; namespace Microsoft.AspNet.Mvc.ModelBinding { @@ -10,7 +11,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding { protected override IEnumerableValueProvider GetEnumerableValueProvider( BindingSource bindingSource, - IDictionary values, + IDictionary values, CultureInfo culture) { return new JQueryFormValueProvider(bindingSource, values, culture); diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/ReadableStringCollectionValueProviderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/ReadableStringCollectionValueProviderTest.cs index 9a3cd94490..a31e476a27 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/ReadableStringCollectionValueProviderTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/ReadableStringCollectionValueProviderTest.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Globalization; using Microsoft.AspNet.Http.Internal; +using Microsoft.Framework.Primitives; namespace Microsoft.AspNet.Mvc.ModelBinding { @@ -11,7 +12,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding { protected override IEnumerableValueProvider GetEnumerableValueProvider( BindingSource bindingSource, - IDictionary values, + IDictionary values, CultureInfo culture) { var backingStore = new ReadableStringCollection(values); diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ResponseCacheFilterTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ResponseCacheFilterTest.cs index 347ada991b..6e758e98a4 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ResponseCacheFilterTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ResponseCacheFilterTest.cs @@ -27,7 +27,7 @@ namespace Microsoft.AspNet.Mvc cache.OnActionExecuting(context); // Assert - Assert.Equal("no-store", context.HttpContext.Response.Headers.Get("Cache-control")); + Assert.Equal("no-store", context.HttpContext.Response.Headers["Cache-control"]); } [Fact] @@ -157,7 +157,7 @@ namespace Microsoft.AspNet.Mvc cache.OnActionExecuting(context); // Assert - Assert.Equal(output, context.HttpContext.Response.Headers.Get("Cache-control")); + Assert.Equal(output, context.HttpContext.Response.Headers["Cache-control"]); } public static IEnumerable NoStoreData @@ -205,7 +205,7 @@ namespace Microsoft.AspNet.Mvc cache.OnActionExecuting(context); // Assert - Assert.Equal(output, context.HttpContext.Response.Headers.Get("Cache-control")); + Assert.Equal(output, context.HttpContext.Response.Headers["Cache-control"]); } public static IEnumerable VaryData @@ -275,8 +275,8 @@ namespace Microsoft.AspNet.Mvc cache.OnActionExecuting(context); // Assert - Assert.Equal(varyOutput, context.HttpContext.Response.Headers.Get("Vary")); - Assert.Equal(cacheControlOutput, context.HttpContext.Response.Headers.Get("Cache-control")); + Assert.Equal(varyOutput, context.HttpContext.Response.Headers["Vary"]); + Assert.Equal(cacheControlOutput, context.HttpContext.Response.Headers["Cache-control"]); } [Fact] @@ -294,8 +294,8 @@ namespace Microsoft.AspNet.Mvc cache.OnActionExecuting(context); // Assert - Assert.Equal("no-store,no-cache", context.HttpContext.Response.Headers.Get("Cache-control")); - Assert.Equal("no-cache", context.HttpContext.Response.Headers.Get("Pragma")); + Assert.Equal("no-store,no-cache", context.HttpContext.Response.Headers["Cache-control"]); + Assert.Equal("no-cache", context.HttpContext.Response.Headers["Pragma"]); } [Fact] @@ -339,7 +339,7 @@ namespace Microsoft.AspNet.Mvc cache.OnActionExecuting(context); // Assert - Assert.Equal("public,max-age=20", context.HttpContext.Response.Headers.Get("Cache-control")); + Assert.Equal("public,max-age=20", context.HttpContext.Response.Headers["Cache-control"]); } [Fact] @@ -359,7 +359,7 @@ namespace Microsoft.AspNet.Mvc cache.OnActionExecuting(context); // Assert - Assert.Equal("private,max-age=10", context.HttpContext.Response.Headers.Get("Cache-control")); + Assert.Equal("private,max-age=10", context.HttpContext.Response.Headers["Cache-control"]); } [Fact] @@ -379,7 +379,7 @@ namespace Microsoft.AspNet.Mvc cache.OnActionExecuting(context); // Assert - Assert.Equal("public,max-age=10", context.HttpContext.Response.Headers.Get("Cache-control")); + Assert.Equal("public,max-age=10", context.HttpContext.Response.Headers["Cache-control"]); } [Fact] @@ -399,7 +399,7 @@ namespace Microsoft.AspNet.Mvc cache.OnActionExecuting(context); // Assert - Assert.Equal("Test", context.HttpContext.Response.Headers.Get("Vary")); + Assert.Equal("Test", context.HttpContext.Response.Headers["Vary"]); } private ActionExecutingContext GetActionExecutingContext(List filters = null) diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/project.json b/test/Microsoft.AspNet.Mvc.Core.Test/project.json index 0dcf9ad00c..8b0d755873 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/project.json +++ b/test/Microsoft.AspNet.Mvc.Core.Test/project.json @@ -3,6 +3,7 @@ "warningsAsErrors": "true" }, "dependencies": { + "Microsoft.AspNet.Http": "1.0.0-*", "Microsoft.AspNet.Mvc": "6.0.0-*", "Microsoft.AspNet.Mvc.TestCommon": { "version": "6.0.0-*", diff --git a/test/Microsoft.AspNet.Mvc.Cors.Test/CorsAuthorizationFilterTest.cs b/test/Microsoft.AspNet.Mvc.Cors.Test/CorsAuthorizationFilterTest.cs index 1fbadf4168..34fae4fec6 100644 --- a/test/Microsoft.AspNet.Mvc.Cors.Test/CorsAuthorizationFilterTest.cs +++ b/test/Microsoft.AspNet.Mvc.Cors.Test/CorsAuthorizationFilterTest.cs @@ -186,10 +186,9 @@ namespace Microsoft.AspNet.Mvc.Test .Callback((result1, response1) => { var headers = response1.Headers; - headers.Set( - CorsConstants.AccessControlMaxAge, - result1.PreflightMaxAge.Value.TotalSeconds.ToString()); - headers.Add(CorsConstants.AccessControlAllowOrigin, new[] { result1.AllowedOrigin }); + headers[CorsConstants.AccessControlMaxAge] = + result1.PreflightMaxAge.Value.TotalSeconds.ToString(); + headers[CorsConstants.AccessControlAllowOrigin] = result1.AllowedOrigin; if (result1.SupportsCredentials) { headers.Add(CorsConstants.AccessControlAllowCredentials, new[] { "true" }); diff --git a/test/Microsoft.AspNet.Mvc.Cors.Test/project.json b/test/Microsoft.AspNet.Mvc.Cors.Test/project.json index 111358249f..03af602622 100644 --- a/test/Microsoft.AspNet.Mvc.Cors.Test/project.json +++ b/test/Microsoft.AspNet.Mvc.Cors.Test/project.json @@ -3,6 +3,7 @@ "warningsAsErrors": "true" }, "dependencies": { + "Microsoft.AspNet.Http": "1.0.0-*", "Microsoft.AspNet.Mvc": "6.0.0-*", "Microsoft.AspNet.Mvc.Formatters.Xml" : "6.0.0-*", "Microsoft.AspNet.Mvc.TestCommon": { "version": "6.0.0-*", "type": "build" }, diff --git a/test/Microsoft.AspNet.Mvc.Formatters.Json.Test/project.json b/test/Microsoft.AspNet.Mvc.Formatters.Json.Test/project.json index 6a11856c08..0cb982595a 100644 --- a/test/Microsoft.AspNet.Mvc.Formatters.Json.Test/project.json +++ b/test/Microsoft.AspNet.Mvc.Formatters.Json.Test/project.json @@ -3,6 +3,7 @@ "warningsAsErrors": "true" }, "dependencies": { + "Microsoft.AspNet.Http": "1.0.0-*", "Microsoft.AspNet.Mvc": "6.0.0-*", "Microsoft.AspNet.Mvc.Formatters.Xml": "6.0.0-*", "Microsoft.AspNet.Mvc.TestCommon": { "version": "6.0.0-*", "type": "build" }, diff --git a/test/Microsoft.AspNet.Mvc.Formatters.Xml.Test/XmlDataContractSerializerOutputFormatterTest.cs b/test/Microsoft.AspNet.Mvc.Formatters.Xml.Test/XmlDataContractSerializerOutputFormatterTest.cs index 9a4dff1ce6..cca8b2273e 100644 --- a/test/Microsoft.AspNet.Mvc.Formatters.Xml.Test/XmlDataContractSerializerOutputFormatterTest.cs +++ b/test/Microsoft.AspNet.Mvc.Formatters.Xml.Test/XmlDataContractSerializerOutputFormatterTest.cs @@ -621,7 +621,7 @@ namespace Microsoft.AspNet.Mvc.Formatters.Xml { var request = new Mock(); - var headers = new HeaderDictionary(new Dictionary(StringComparer.OrdinalIgnoreCase)); + var headers = new HeaderDictionary(); headers["Accept-Charset"] = MediaTypeHeaderValue.Parse(contentType).Charset; request.Setup(r => r.ContentType).Returns(contentType); request.SetupGet(r => r.Headers).Returns(headers); diff --git a/test/Microsoft.AspNet.Mvc.Formatters.Xml.Test/XmlSerializerOutputFormatterTest.cs b/test/Microsoft.AspNet.Mvc.Formatters.Xml.Test/XmlSerializerOutputFormatterTest.cs index 873ad1da0a..cb4e3e9304 100644 --- a/test/Microsoft.AspNet.Mvc.Formatters.Xml.Test/XmlSerializerOutputFormatterTest.cs +++ b/test/Microsoft.AspNet.Mvc.Formatters.Xml.Test/XmlSerializerOutputFormatterTest.cs @@ -375,7 +375,7 @@ namespace Microsoft.AspNet.Mvc.Formatters.Xml { var request = new Mock(); - var headers = new HeaderDictionary(new Dictionary(StringComparer.OrdinalIgnoreCase)); + var headers = new HeaderDictionary(); headers["Accept-Charset"] = MediaTypeHeaderValue.Parse(contentType).Charset; request.Setup(r => r.ContentType).Returns(contentType); request.SetupGet(r => r.Headers).Returns(headers); diff --git a/test/Microsoft.AspNet.Mvc.Formatters.Xml.Test/project.json b/test/Microsoft.AspNet.Mvc.Formatters.Xml.Test/project.json index 59224daa4b..435062493f 100644 --- a/test/Microsoft.AspNet.Mvc.Formatters.Xml.Test/project.json +++ b/test/Microsoft.AspNet.Mvc.Formatters.Xml.Test/project.json @@ -3,6 +3,7 @@ "warningsAsErrors": "true" }, "dependencies": { + "Microsoft.AspNet.Http": "1.0.0-*", "Microsoft.AspNet.Mvc" : "6.0.0-*", "Microsoft.AspNet.Mvc.Formatters.Xml" : "6.0.0-*", "Microsoft.AspNet.Testing": "1.0.0-*", diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/FiltersTest.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/FiltersTest.cs index a31b1e3c47..a61a847dac 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/FiltersTest.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/FiltersTest.cs @@ -68,12 +68,12 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests var body = await response.Content.ReadAsStringAsync(); - var filters = response.Headers.GetValues("filters").Single().Split(','); + var filters = response.Headers.GetValues("filters").ToArray(); var i = 0; foreach (var filter in filters) { - Assert.Equal(filter, expected[i++]); + Assert.Equal(expected[i++], filter); } Assert.Equal(expected.Length, filters.Length); diff --git a/test/Microsoft.AspNet.Mvc.IntegrationTests/CollectionModelBinderIntegrationTest.cs b/test/Microsoft.AspNet.Mvc.IntegrationTests/CollectionModelBinderIntegrationTest.cs index 67bf5482db..011324e375 100644 --- a/test/Microsoft.AspNet.Mvc.IntegrationTests/CollectionModelBinderIntegrationTest.cs +++ b/test/Microsoft.AspNet.Mvc.IntegrationTests/CollectionModelBinderIntegrationTest.cs @@ -10,6 +10,7 @@ using System.Threading.Tasks; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Internal; using Microsoft.AspNet.Mvc.ModelBinding; +using Microsoft.Framework.Primitives; using Xunit; namespace Microsoft.AspNet.Mvc.IntegrationTests @@ -604,7 +605,7 @@ namespace Microsoft.AspNet.Mvc.IntegrationTests var operationContext = ModelBindingTestHelper.GetOperationBindingContext(request => { - var formCollection = new FormCollection(new Dictionary() + var formCollection = new FormCollection(new Dictionary() { { "Addresses.index", new [] { "Key1", "Key2" } }, { "Addresses[Key1].Street", new [] { "Street1" } }, @@ -663,7 +664,7 @@ namespace Microsoft.AspNet.Mvc.IntegrationTests var operationContext = ModelBindingTestHelper.GetOperationBindingContext(request => { - var formCollection = new FormCollection(new Dictionary() + var formCollection = new FormCollection(new Dictionary() { { "Addresses.index", new [] { "Key1" } }, { "Addresses[Key1].Street", new [] { "Street1" } }, @@ -733,15 +734,15 @@ namespace Microsoft.AspNet.Mvc.IntegrationTests } // parameter type, form content, expected type - public static TheoryData, Type> CollectionTypeData + public static TheoryData, Type> CollectionTypeData { get { - return new TheoryData, Type> + return new TheoryData, Type> { { typeof(IEnumerable), - new Dictionary + new Dictionary { { "[0]", new[] { "hello" } }, { "[1]", new[] { "world" } }, @@ -750,7 +751,7 @@ namespace Microsoft.AspNet.Mvc.IntegrationTests }, { typeof(ICollection), - new Dictionary + new Dictionary { { "index", new[] { "low", "high" } }, { "[low]", new[] { "hello" } }, @@ -760,7 +761,7 @@ namespace Microsoft.AspNet.Mvc.IntegrationTests }, { typeof(IList), - new Dictionary + new Dictionary { { "[0]", new[] { "hello" } }, { "[1]", new[] { "world" } }, @@ -769,7 +770,7 @@ namespace Microsoft.AspNet.Mvc.IntegrationTests }, { typeof(List), - new Dictionary + new Dictionary { { "index", new[] { "low", "high" } }, { "[low]", new[] { "hello" } }, @@ -779,7 +780,7 @@ namespace Microsoft.AspNet.Mvc.IntegrationTests }, { typeof(ClosedGenericCollection), - new Dictionary + new Dictionary { { "[0]", new[] { "hello" } }, { "[1]", new[] { "world" } }, @@ -788,7 +789,7 @@ namespace Microsoft.AspNet.Mvc.IntegrationTests }, { typeof(ClosedGenericList), - new Dictionary + new Dictionary { { "index", new[] { "low", "high" } }, { "[low]", new[] { "hello" } }, @@ -798,7 +799,7 @@ namespace Microsoft.AspNet.Mvc.IntegrationTests }, { typeof(ExplicitClosedGenericCollection), - new Dictionary + new Dictionary { { "[0]", new[] { "hello" } }, { "[1]", new[] { "world" } }, @@ -807,7 +808,7 @@ namespace Microsoft.AspNet.Mvc.IntegrationTests }, { typeof(ExplicitClosedGenericList), - new Dictionary + new Dictionary { { "index", new[] { "low", "high" } }, { "[low]", new[] { "hello" } }, @@ -817,7 +818,7 @@ namespace Microsoft.AspNet.Mvc.IntegrationTests }, { typeof(ExplicitCollection), - new Dictionary + new Dictionary { { "[0]", new[] { "hello" } }, { "[1]", new[] { "world" } }, @@ -826,7 +827,7 @@ namespace Microsoft.AspNet.Mvc.IntegrationTests }, { typeof(ExplicitList), - new Dictionary + new Dictionary { { "index", new[] { "low", "high" } }, { "[low]", new[] { "hello" } }, @@ -836,7 +837,7 @@ namespace Microsoft.AspNet.Mvc.IntegrationTests }, { typeof(IEnumerable), - new Dictionary + new Dictionary { { string.Empty, new[] { "hello", "world" } }, }, @@ -844,7 +845,7 @@ namespace Microsoft.AspNet.Mvc.IntegrationTests }, { typeof(ICollection), - new Dictionary + new Dictionary { { "[]", new[] { "hello", "world" } }, }, @@ -852,7 +853,7 @@ namespace Microsoft.AspNet.Mvc.IntegrationTests }, { typeof(IList), - new Dictionary + new Dictionary { { string.Empty, new[] { "hello", "world" } }, }, @@ -860,7 +861,7 @@ namespace Microsoft.AspNet.Mvc.IntegrationTests }, { typeof(List), - new Dictionary + new Dictionary { { "[]", new[] { "hello", "world" } }, }, @@ -868,7 +869,7 @@ namespace Microsoft.AspNet.Mvc.IntegrationTests }, { typeof(ClosedGenericCollection), - new Dictionary + new Dictionary { { string.Empty, new[] { "hello", "world" } }, }, @@ -876,7 +877,7 @@ namespace Microsoft.AspNet.Mvc.IntegrationTests }, { typeof(ClosedGenericList), - new Dictionary + new Dictionary { { "[]", new[] { "hello", "world" } }, }, @@ -884,7 +885,7 @@ namespace Microsoft.AspNet.Mvc.IntegrationTests }, { typeof(ExplicitClosedGenericCollection), - new Dictionary + new Dictionary { { string.Empty, new[] { "hello", "world" } }, }, @@ -892,7 +893,7 @@ namespace Microsoft.AspNet.Mvc.IntegrationTests }, { typeof(ExplicitClosedGenericList), - new Dictionary + new Dictionary { { "[]", new[] { "hello", "world" } }, }, @@ -900,7 +901,7 @@ namespace Microsoft.AspNet.Mvc.IntegrationTests }, { typeof(ExplicitCollection), - new Dictionary + new Dictionary { { string.Empty, new[] { "hello", "world" } }, }, @@ -908,7 +909,7 @@ namespace Microsoft.AspNet.Mvc.IntegrationTests }, { typeof(ExplicitList), - new Dictionary + new Dictionary { { "[]", new[] { "hello", "world" } }, }, @@ -922,7 +923,7 @@ namespace Microsoft.AspNet.Mvc.IntegrationTests [MemberData(nameof(CollectionTypeData))] public async Task CollectionModelBinder_BindsParameterToExpectedType( Type parameterType, - IDictionary formContent, + IDictionary formContent, Type expectedType) { // Arrange diff --git a/test/Microsoft.AspNet.Mvc.IntegrationTests/FormCollectionModelBindingIntegrationTest.cs b/test/Microsoft.AspNet.Mvc.IntegrationTests/FormCollectionModelBindingIntegrationTest.cs index 77dc3956d2..df75eeb275 100644 --- a/test/Microsoft.AspNet.Mvc.IntegrationTests/FormCollectionModelBindingIntegrationTest.cs +++ b/test/Microsoft.AspNet.Mvc.IntegrationTests/FormCollectionModelBindingIntegrationTest.cs @@ -9,6 +9,7 @@ using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Features.Internal; using Microsoft.AspNet.Http.Internal; using Microsoft.AspNet.Mvc.ModelBinding; +using Microsoft.Framework.Primitives; using Xunit; namespace Microsoft.AspNet.Mvc.IntegrationTests @@ -163,7 +164,7 @@ namespace Microsoft.AspNet.Mvc.IntegrationTests private void UpdateRequest(HttpRequest request, string data, string name) { var fileCollection = new FormFileCollection(); - var formCollection = new FormCollection(new Dictionary(), fileCollection); + var formCollection = new FormCollection(new Dictionary(), fileCollection); var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(data)); request.Form = formCollection; diff --git a/test/Microsoft.AspNet.Mvc.IntegrationTests/FormFileModelBindingIntegrationTest.cs b/test/Microsoft.AspNet.Mvc.IntegrationTests/FormFileModelBindingIntegrationTest.cs index 378240d674..3b4a9860af 100644 --- a/test/Microsoft.AspNet.Mvc.IntegrationTests/FormFileModelBindingIntegrationTest.cs +++ b/test/Microsoft.AspNet.Mvc.IntegrationTests/FormFileModelBindingIntegrationTest.cs @@ -9,6 +9,7 @@ using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Features.Internal; using Microsoft.AspNet.Http.Internal; using Microsoft.AspNet.Mvc.ModelBinding; +using Microsoft.Framework.Primitives; using Xunit; namespace Microsoft.AspNet.Mvc.IntegrationTests @@ -164,7 +165,7 @@ namespace Microsoft.AspNet.Mvc.IntegrationTests private void UpdateRequest(HttpRequest request, string data, string name) { var fileCollection = new FormFileCollection(); - var formCollection = new FormCollection(new Dictionary(), fileCollection); + var formCollection = new FormCollection(new Dictionary(), fileCollection); request.Form = formCollection; request.ContentType = "multipart/form-data; boundary=----WebKitFormBoundarymx2fSWqWSd0OxQqq"; diff --git a/test/Microsoft.AspNet.Mvc.IntegrationTests/MutableObjectModelBinderIntegrationTest.cs b/test/Microsoft.AspNet.Mvc.IntegrationTests/MutableObjectModelBinderIntegrationTest.cs index 7dd3d4be18..eb2d7a40a9 100644 --- a/test/Microsoft.AspNet.Mvc.IntegrationTests/MutableObjectModelBinderIntegrationTest.cs +++ b/test/Microsoft.AspNet.Mvc.IntegrationTests/MutableObjectModelBinderIntegrationTest.cs @@ -10,6 +10,7 @@ using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Features.Internal; using Microsoft.AspNet.Http.Internal; using Microsoft.AspNet.Mvc.ModelBinding; +using Microsoft.Framework.Primitives; using Xunit; namespace Microsoft.AspNet.Mvc.IntegrationTests @@ -2129,7 +2130,7 @@ namespace Microsoft.AspNet.Mvc.IntegrationTests private static void SetFormFileBodyContent(HttpRequest request, string content, string name) { var fileCollection = new FormFileCollection(); - var formCollection = new FormCollection(new Dictionary(), fileCollection); + var formCollection = new FormCollection(new Dictionary(), fileCollection); var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(content)); request.Form = formCollection; diff --git a/test/Microsoft.AspNet.Mvc.IntegrationTests/SimpleTypeModelBinderIntegrationTest.cs b/test/Microsoft.AspNet.Mvc.IntegrationTests/SimpleTypeModelBinderIntegrationTest.cs index 80618136dc..4c1adf8696 100644 --- a/test/Microsoft.AspNet.Mvc.IntegrationTests/SimpleTypeModelBinderIntegrationTest.cs +++ b/test/Microsoft.AspNet.Mvc.IntegrationTests/SimpleTypeModelBinderIntegrationTest.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Internal; using Microsoft.AspNet.Mvc.ModelBinding; +using Microsoft.Framework.Primitives; using Xunit; namespace Microsoft.AspNet.Mvc.IntegrationTests @@ -366,19 +367,19 @@ namespace Microsoft.AspNet.Mvc.IntegrationTests Assert.Empty(modelState.Keys); } - public static TheoryData> PersonStoreData + public static TheoryData> PersonStoreData { get { - return new TheoryData> + return new TheoryData> { - new Dictionary + new Dictionary { { "name", new[] { "Fred" } }, { "address.zip", new[] { "98052" } }, { "address.lines", new[] { "line 1", "line 2" } }, }, - new Dictionary + new Dictionary { { "address.lines[]", new[] { "line 1", "line 2" } }, { "address[].zip", new[] { "98052" } }, @@ -390,7 +391,7 @@ namespace Microsoft.AspNet.Mvc.IntegrationTests [Theory] [MemberData(nameof(PersonStoreData))] - public async Task BindParameter_FromFormData_BindsCorrectly(IDictionary personStore) + public async Task BindParameter_FromFormData_BindsCorrectly(IDictionary personStore) { // Arrange var argumentBinder = ModelBindingTestHelper.GetArgumentBinder(); diff --git a/test/Microsoft.AspNet.Mvc.IntegrationTests/project.json b/test/Microsoft.AspNet.Mvc.IntegrationTests/project.json index d33da2216d..442e20ef22 100644 --- a/test/Microsoft.AspNet.Mvc.IntegrationTests/project.json +++ b/test/Microsoft.AspNet.Mvc.IntegrationTests/project.json @@ -3,6 +3,7 @@ "warningsAsErrors": "true" }, "dependencies": { + "Microsoft.AspNet.Http": "1.0.0-*", "Microsoft.AspNet.Mvc": "6.0.0-*", "Microsoft.AspNet.Mvc.Formatters.Xml": "6.0.0-*", "Microsoft.AspNet.Mvc.TestCommon": { diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/project.json b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/project.json index 4fdc0e3ff2..326593e2ef 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/project.json +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/project.json @@ -3,6 +3,7 @@ "warningsAsErrors": "true" }, "dependencies": { + "Microsoft.AspNet.Http": "1.0.0-*", "Microsoft.AspNet.Mvc": "6.0.0-*", "Microsoft.AspNet.Mvc.Formatters.Xml": "6.0.0-*", "Microsoft.AspNet.Mvc.TestCommon": { "version": "6.0.0-*", "type": "build" }, diff --git a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpResponseMessageOutputFormatterTests.cs b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpResponseMessageOutputFormatterTests.cs index eafd06a84a..2a7a6b712e 100644 --- a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpResponseMessageOutputFormatterTests.cs +++ b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpResponseMessageOutputFormatterTests.cs @@ -113,7 +113,7 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShimTest // Assert Assert.True(httpContext.Response.Headers.ContainsKey(transferEncodingHeaderKey)); Assert.Equal(new string[] { "identity", "chunked" }, - httpContext.Response.Headers.GetValues(transferEncodingHeaderKey)); + httpContext.Response.Headers[transferEncodingHeaderKey]); Assert.NotNull(httpContext.Response.ContentLength); } @@ -141,7 +141,7 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShimTest // Assert Assert.True(httpContext.Response.Headers.ContainsKey(transferEncodingHeaderKey)); Assert.Equal(new string[] { "identity", "chunked" }, - httpContext.Response.Headers.GetValues(transferEncodingHeaderKey)); + httpContext.Response.Headers[transferEncodingHeaderKey]); Assert.NotNull(httpContext.Response.ContentLength); } diff --git a/test/WebSites/CustomRouteWebSite/LocalizedRoute.cs b/test/WebSites/CustomRouteWebSite/LocalizedRoute.cs index 443742ceab..82eba00ccc 100644 --- a/test/WebSites/CustomRouteWebSite/LocalizedRoute.cs +++ b/test/WebSites/CustomRouteWebSite/LocalizedRoute.cs @@ -63,7 +63,7 @@ namespace CustomRouteWebSite private string GetLocale(HttpContext context) { string locale; - _users.TryGetValue(context.Request.Headers.Get("User"), out locale); + _users.TryGetValue(context.Request.Headers["User"], out locale); return locale; } } diff --git a/test/WebSites/FiltersWebSite/Controllers/ProductsController.cs b/test/WebSites/FiltersWebSite/Controllers/ProductsController.cs index a261473d31..f7a28e18db 100644 --- a/test/WebSites/FiltersWebSite/Controllers/ProductsController.cs +++ b/test/WebSites/FiltersWebSite/Controllers/ProductsController.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using Microsoft.AspNet.Http; using Microsoft.AspNet.Mvc; namespace FiltersWebSite diff --git a/test/WebSites/FiltersWebSite/Filters/AuthorizeUserAttribute.cs b/test/WebSites/FiltersWebSite/Filters/AuthorizeUserAttribute.cs index 255098bfe5..764d54f5d3 100644 --- a/test/WebSites/FiltersWebSite/Filters/AuthorizeUserAttribute.cs +++ b/test/WebSites/FiltersWebSite/Filters/AuthorizeUserAttribute.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Security.Claims; +using Microsoft.AspNet.Http; using Microsoft.AspNet.Mvc; namespace FiltersWebSite diff --git a/test/WebSites/FiltersWebSite/Filters/ControllerActionFilter.cs b/test/WebSites/FiltersWebSite/Filters/ControllerActionFilter.cs index 24b3cd59c7..4d74e4b0e7 100644 --- a/test/WebSites/FiltersWebSite/Filters/ControllerActionFilter.cs +++ b/test/WebSites/FiltersWebSite/Filters/ControllerActionFilter.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; +using Microsoft.AspNet.Http; using Microsoft.AspNet.Mvc; namespace FiltersWebSite diff --git a/test/WebSites/FiltersWebSite/Filters/ControllerAuthorizationFilter.cs b/test/WebSites/FiltersWebSite/Filters/ControllerAuthorizationFilter.cs index 47120499cb..cd5fbd9757 100644 --- a/test/WebSites/FiltersWebSite/Filters/ControllerAuthorizationFilter.cs +++ b/test/WebSites/FiltersWebSite/Filters/ControllerAuthorizationFilter.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using Microsoft.AspNet.Http; using Microsoft.AspNet.Mvc; namespace FiltersWebSite diff --git a/test/WebSites/FiltersWebSite/Filters/ControllerResultFilter.cs b/test/WebSites/FiltersWebSite/Filters/ControllerResultFilter.cs index 93e2b096d0..2316c6dadf 100644 --- a/test/WebSites/FiltersWebSite/Filters/ControllerResultFilter.cs +++ b/test/WebSites/FiltersWebSite/Filters/ControllerResultFilter.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using Microsoft.AspNet.Http; using Microsoft.AspNet.Mvc; namespace FiltersWebSite diff --git a/test/WebSites/FiltersWebSite/Filters/GlobalActionFilter.cs b/test/WebSites/FiltersWebSite/Filters/GlobalActionFilter.cs index 2bef9a5a45..9ea56b7261 100644 --- a/test/WebSites/FiltersWebSite/Filters/GlobalActionFilter.cs +++ b/test/WebSites/FiltersWebSite/Filters/GlobalActionFilter.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; +using Microsoft.AspNet.Http; using Microsoft.AspNet.Mvc; namespace FiltersWebSite diff --git a/test/WebSites/FiltersWebSite/Filters/GlobalAuthorizationFilter.cs b/test/WebSites/FiltersWebSite/Filters/GlobalAuthorizationFilter.cs index 868c9e549b..70bc463db9 100644 --- a/test/WebSites/FiltersWebSite/Filters/GlobalAuthorizationFilter.cs +++ b/test/WebSites/FiltersWebSite/Filters/GlobalAuthorizationFilter.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using Microsoft.AspNet.Http; using Microsoft.AspNet.Mvc; namespace FiltersWebSite diff --git a/test/WebSites/FiltersWebSite/Filters/GlobalResultFilter.cs b/test/WebSites/FiltersWebSite/Filters/GlobalResultFilter.cs index 3e632f9981..09c7aabb6a 100644 --- a/test/WebSites/FiltersWebSite/Filters/GlobalResultFilter.cs +++ b/test/WebSites/FiltersWebSite/Filters/GlobalResultFilter.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using Microsoft.AspNet.Http; using Microsoft.AspNet.Mvc; namespace FiltersWebSite diff --git a/test/WebSites/FiltersWebSite/Filters/PassThroughActionFilter.cs b/test/WebSites/FiltersWebSite/Filters/PassThroughActionFilter.cs index 019039cdfc..9f62ef9a9d 100644 --- a/test/WebSites/FiltersWebSite/Filters/PassThroughActionFilter.cs +++ b/test/WebSites/FiltersWebSite/Filters/PassThroughActionFilter.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using Microsoft.AspNet.Http; using Microsoft.AspNet.Mvc; namespace FiltersWebSite diff --git a/test/WebSites/FiltersWebSite/Filters/PassThroughResultFilter.cs b/test/WebSites/FiltersWebSite/Filters/PassThroughResultFilter.cs index 707b92bd2a..6499f65f37 100644 --- a/test/WebSites/FiltersWebSite/Filters/PassThroughResultFilter.cs +++ b/test/WebSites/FiltersWebSite/Filters/PassThroughResultFilter.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using Microsoft.AspNet.Http; using Microsoft.AspNet.Mvc; namespace FiltersWebSite diff --git a/test/WebSites/FiltersWebSite/Filters/TracingResourceFilter.cs b/test/WebSites/FiltersWebSite/Filters/TracingResourceFilter.cs index c17b363858..97175e00ef 100644 --- a/test/WebSites/FiltersWebSite/Filters/TracingResourceFilter.cs +++ b/test/WebSites/FiltersWebSite/Filters/TracingResourceFilter.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNet.Http; using Microsoft.AspNet.Mvc; namespace FiltersWebSite diff --git a/test/WebSites/LoggingWebSite/Models/RequestInfoDto.cs b/test/WebSites/LoggingWebSite/Models/RequestInfoDto.cs index a51224ba03..cadc7a842c 100644 --- a/test/WebSites/LoggingWebSite/Models/RequestInfoDto.cs +++ b/test/WebSites/LoggingWebSite/Models/RequestInfoDto.cs @@ -1,6 +1,5 @@ -using System; -using System.Collections.Generic; -using Microsoft.AspNet.Http; +using System.Collections.Generic; +using Microsoft.Framework.Primitives; namespace LoggingWebSite { @@ -22,10 +21,10 @@ namespace LoggingWebSite public string Protocol { get; set; } - public IEnumerable> Headers { get; set; } + public IEnumerable> Headers { get; set; } public string Query { get; set; } - public IEnumerable> Cookies { get; set; } + public IEnumerable> Cookies { get; set; } } } \ No newline at end of file diff --git a/test/WebSites/ModelBindingWebSite/Controllers/ModelBinderAttribute_ProductController.cs b/test/WebSites/ModelBindingWebSite/Controllers/ModelBinderAttribute_ProductController.cs index 1dce9b2a7d..8acdbdcbee 100644 --- a/test/WebSites/ModelBindingWebSite/Controllers/ModelBinderAttribute_ProductController.cs +++ b/test/WebSites/ModelBindingWebSite/Controllers/ModelBinderAttribute_ProductController.cs @@ -73,7 +73,7 @@ namespace ModelBindingWebSite.Controllers // Doing something slightly different here to make sure we don't get accidentally bound // by the type converter binder. OrderStatus model; - var isModelSet = Enum.TryParse("Status" + request.Query.Get("status"), out model); + var isModelSet = Enum.TryParse("Status" + request.Query["status"], out model); var validationNode = new ModelValidationNode(bindingContext.ModelName, bindingContext.ModelMetadata, model); return Task.FromResult(new ModelBindingResult(model, "status", isModelSet, validationNode)); diff --git a/test/WebSites/ModelBindingWebSite/Controllers/TryUpdateModelController.cs b/test/WebSites/ModelBindingWebSite/Controllers/TryUpdateModelController.cs index 6ea38ecbe9..65f9687f62 100644 --- a/test/WebSites/ModelBindingWebSite/Controllers/TryUpdateModelController.cs +++ b/test/WebSites/ModelBindingWebSite/Controllers/TryUpdateModelController.cs @@ -10,6 +10,7 @@ using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Internal; using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc.ModelBinding; +using Microsoft.Framework.Primitives; using ModelBindingWebSite.Models; namespace ModelBindingWebSite.Controllers @@ -107,7 +108,7 @@ namespace ModelBindingWebSite.Controllers public async Task GetEmployeeAsync_BindToBaseDeclaredType() { var backingStore = new ReadableStringCollection( - new Dictionary + new Dictionary { { "Parent.Name", new[] { "fatherName"} }, { "Parent.Parent.Name", new[] {"grandFatherName" } }, @@ -131,7 +132,7 @@ namespace ModelBindingWebSite.Controllers public async Task GetUserAsync_ModelType_IncludeAll(int id) { var backingStore = new ReadableStringCollection( - new Dictionary + new Dictionary { { "Key", new[] { "123"} }, { "RegisterationMonth", new[] {"March" } }, diff --git a/test/WebSites/ResponseCacheWebSite/Controllers/CacheHeadersController.cs b/test/WebSites/ResponseCacheWebSite/Controllers/CacheHeadersController.cs index d7fb644928..87b8267da5 100644 --- a/test/WebSites/ResponseCacheWebSite/Controllers/CacheHeadersController.cs +++ b/test/WebSites/ResponseCacheWebSite/Controllers/CacheHeadersController.cs @@ -46,7 +46,7 @@ namespace ResponseCacheWebSite [ResponseCache(Duration = 40)] public IActionResult SetHeadersInAction() { - Response.Headers.Set("Cache-control", "max-age=10"); + Response.Headers["Cache-control"] = "max-age=10"; return Content("Hello World!"); } diff --git a/test/WebSites/VersioningWebSite/VersionRangeValidator.cs b/test/WebSites/VersioningWebSite/VersionRangeValidator.cs index fef545c84b..7d6c01e1bf 100644 --- a/test/WebSites/VersioningWebSite/VersionRangeValidator.cs +++ b/test/WebSites/VersioningWebSite/VersionRangeValidator.cs @@ -21,7 +21,7 @@ namespace VersioningWebSite public static string GetVersion(HttpRequest request) { - return request.Query.Get("version"); + return request.Query["version"]; } public bool Accept(ActionConstraintContext context)