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.Mvc.Core; using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Internal; +using Microsoft.Net.Http.Headers; namespace Microsoft.AspNet.Mvc { @@ -73,7 +74,7 @@ protected override void OnFormatting([NotNull] ActionContext context) 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.Mvc.Core; using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Internal; +using Microsoft.Net.Http.Headers; namespace Microsoft.AspNet.Mvc { @@ -70,7 +71,7 @@ protected override void OnFormatting([NotNull] ActionContext context) 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 @@ public string Location /// 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 @@ public override Task ExecuteResultAsync([NotNull] ActionContext context) // 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..be65914c9a 100644 --- a/src/Microsoft.AspNet.Mvc.Core/HttpMethodConstraint.cs +++ b/src/Microsoft.AspNet.Mvc.Core/HttpMethodConstraint.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; +using Microsoft.AspNet.Primitives; using Microsoft.Framework.Internal; namespace Microsoft.AspNet.Mvc @@ -62,12 +63,12 @@ public bool Accept([NotNull] ActionConstraintContext context) 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 de3cbf4061..431cd1329b 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/FormCollectionModelBinder.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/FormCollectionModelBinder.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Internal; +using Microsoft.AspNet.Primitives; using Microsoft.Framework.Internal; namespace Microsoft.AspNet.Mvc.ModelBinding @@ -42,7 +43,7 @@ public async Task BindModelAsync([NotNull] ModelBindingConte } else { - model = new FormCollection(new Dictionary()); + model = new FormCollection(new Dictionary()); } var validationNode = diff --git a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/HeaderModelBinder.cs b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/HeaderModelBinder.cs index 2a253ece64..9061ad5848 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/HeaderModelBinder.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/HeaderModelBinder.cs @@ -7,6 +7,7 @@ using System.Reflection; #endif using System.Threading.Tasks; +using Microsoft.AspNet.Primitives; using Microsoft.Framework.Internal; namespace Microsoft.AspNet.Mvc.ModelBinding @@ -36,7 +37,7 @@ protected override Task BindModelCoreAsync([NotNull] ModelBi 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 +46,7 @@ protected override Task BindModelCoreAsync([NotNull] ModelBi else if (typeof(IEnumerable).IsAssignableFrom(bindingContext.ModelType)) { var values = request.Headers.GetCommaSeparatedValues(headerName); - if (values != null) + if (values.Count > 0) { model = ModelBindingHelper.ConvertValuesToCollectionType( bindingContext.ModelType, @@ -61,7 +62,7 @@ protected override Task BindModelCoreAsync([NotNull] ModelBi bindingContext.ModelMetadata, model); - var attemptedValue = (model as string) ?? request.Headers.Get(headerName); + var attemptedValue = (model as string) ?? request.Headers[headerName]; var valueProviderResult = new ValueProviderResult(model, attemptedValue, CultureInfo.InvariantCulture); bindingContext.ModelState.SetModelValue(bindingContext.ModelName, valueProviderResult); } diff --git a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/JQueryFormValueProvider.cs b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/JQueryFormValueProvider.cs index e1e319dd95..6ea03df260 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/JQueryFormValueProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/JQueryFormValueProvider.cs @@ -6,6 +6,7 @@ using System.Diagnostics; using System.Globalization; using System.Threading.Tasks; +using Microsoft.AspNet.Primitives; using Microsoft.Framework.Internal; namespace Microsoft.AspNet.Mvc.ModelBinding @@ -16,10 +17,10 @@ namespace Microsoft.AspNet.Mvc.ModelBinding /// public class JQueryFormValueProvider : BindingSourceValueProvider, IEnumerableValueProvider { - private readonly Func>> _valuesFactory; + private readonly Func>> _valuesFactory; private PrefixContainer _prefixContainer; - private IDictionary _values; + private IDictionary _values; /// /// Initializes a new instance of the class. @@ -29,7 +30,7 @@ public class JQueryFormValueProvider : BindingSourceValueProvider, IEnumerableVa /// The culture to return with ValueProviderResult instances. public JQueryFormValueProvider( [NotNull] BindingSource bindingSource, - [NotNull] Func>> valuesFactory, + [NotNull] Func>> valuesFactory, CultureInfo culture) : base(bindingSource) { @@ -40,7 +41,7 @@ public JQueryFormValueProvider( // Internal for testing. internal JQueryFormValueProvider( [NotNull] BindingSource bindingSource, - [NotNull] IDictionary values, + [NotNull] IDictionary values, CultureInfo culture) : base(bindingSource) { @@ -70,22 +71,26 @@ public override async Task GetValueAsync(string key) { var dictionary = await GetDictionary(); - string[] values; - if (dictionary.TryGetValue(key, out values) && values != null && values.Length > 0) + StringValues values; + if (dictionary.TryGetValue(key, out values) && values.Count > 0) { - // Success. - if (values.Length == 1) + if (values.Count == 1) { - return new ValueProviderResult(values[0], values[0], Culture); + var value = (string)values; + return new ValueProviderResult(value, value, Culture); + } + else + { + var rawValue = (string[])values; + var value = (string)values; + return new ValueProviderResult(rawValue, value, Culture); } - - return new ValueProviderResult(values, string.Join(",", values), Culture); } return null; } - private async Task> GetDictionary() + private async Task> GetDictionary() { if (_values == null) { diff --git a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/JQueryFormValueProviderFactory.cs b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/JQueryFormValueProviderFactory.cs index e40cd205c0..3b7052a636 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/JQueryFormValueProviderFactory.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/JQueryFormValueProviderFactory.cs @@ -8,6 +8,7 @@ using System.Threading.Tasks; using Microsoft.AspNet.Http; using Microsoft.AspNet.Mvc.Core; +using Microsoft.AspNet.Primitives; using Microsoft.Framework.Internal; namespace Microsoft.AspNet.Mvc.ModelBinding @@ -29,11 +30,11 @@ public IValueProvider GetValueProvider([NotNull] ValueProviderFactoryContext con 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 346617eea9..32a23dc639 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/ReadableStringCollectionValueProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/ReadableStringCollectionValueProvider.cs @@ -7,6 +7,7 @@ using System.Globalization; using System.Threading.Tasks; using Microsoft.AspNet.Http; +using Microsoft.AspNet.Primitives; using Microsoft.Framework.Internal; namespace Microsoft.AspNet.Mvc.ModelBinding @@ -80,21 +81,21 @@ public virtual async Task> GetKeysFromPrefixAsync([N public override async Task GetValueAsync([NotNull] string key) { var collection = await GetValueCollectionAsync(); - var values = collection.GetValues(key); + var values = collection[key]; ValueProviderResult result; - if (values == null) + if (values.Count == 0) { result = null; } else if (values.Count == 1) { - var value = (string)values[0]; + var value = (string)values; result = new ValueProviderResult(value, value, _culture); } else { - result = new ValueProviderResult(values, _values.Get(key), _culture); + result = new ValueProviderResult((string[])values, _values[key], _culture); } return result; diff --git a/src/Microsoft.AspNet.Mvc.Core/ResponseCacheFilter.cs b/src/Microsoft.AspNet.Mvc.Core/ResponseCacheFilter.cs index ebe249a72b..988b820c39 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ResponseCacheFilter.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ResponseCacheFilter.cs @@ -6,6 +6,7 @@ using System.Linq; using Microsoft.AspNet.Mvc.Core; using Microsoft.Framework.Internal; +using Microsoft.Net.Http.Headers; namespace Microsoft.AspNet.Mvc { @@ -94,24 +95,24 @@ public void OnActionExecuting([NotNull] ActionExecutingContext context) 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 +128,7 @@ public void OnActionExecuting([NotNull] ActionExecutingContext context) break; case ResponseCacheLocation.None: cacheControlValue = "no-cache"; - headers.Set("Pragma", "no-cache"); + headers[HeaderNames.Pragma] = "no-cache"; break; } @@ -140,7 +141,7 @@ public void OnActionExecuting([NotNull] ActionExecutingContext context) 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..e12b6268fb 100644 --- a/src/Microsoft.AspNet.Mvc.Cors/CorsAuthorizationFilter.cs +++ b/src/Microsoft.AspNet.Mvc.Cors/CorsAuthorizationFilter.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using Microsoft.AspNet.Cors.Core; using Microsoft.AspNet.Http; +using Microsoft.AspNet.Primitives; using Microsoft.Framework.Internal; namespace Microsoft.AspNet.Mvc @@ -63,12 +64,12 @@ public async Task OnAuthorizationAsync([NotNull] AuthorizationContext context) _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..2ec9d48f3c 100644 --- a/src/Microsoft.AspNet.Mvc.Cors/DisableCorsAuthorizationFilter.cs +++ b/src/Microsoft.AspNet.Mvc.Cors/DisableCorsAuthorizationFilter.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using Microsoft.AspNet.Cors.Core; using Microsoft.AspNet.Http; +using Microsoft.AspNet.Primitives; using Microsoft.Framework.Internal; namespace Microsoft.AspNet.Mvc @@ -27,12 +28,12 @@ public int Order 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..e09fa19669 100644 --- a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/Formatters/HttpResponseMessageOutputFormatter.cs +++ b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/Formatters/HttpResponseMessageOutputFormatter.cs @@ -53,7 +53,7 @@ public async Task WriteAsync(OutputFormatterContext context) 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 +67,7 @@ public async Task WriteAsync(OutputFormatterContext context) 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 @@ private static HttpRequestMessage CreateHttpRequestMessage(HttpContext httpConte { // 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.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 @@ private static HttpResponse GetMockedHttpResponseObject() 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 @@ public async Task CreatedResult_OverwritesLocationHeader() 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 @@ public void FormatFilter_ContextContainsFormat_InRouteAndQueryData() // 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 6537336403..40a1f7fa87 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.Globalization; #if DNX451 using System.Threading.Tasks; +using Microsoft.AspNet.Primitives; using Moq; using Xunit; #endif @@ -18,11 +19,11 @@ public class CompositeValueProviderTest : EnumerableValueProviderTest { 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 617bd67337..9ebc8c58fc 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.Linq; using System.Threading.Tasks; using Microsoft.AspNet.Http.Internal; +using Microsoft.AspNet.Primitives; using Moq; using Xunit; @@ -442,10 +443,10 @@ private static IValueProvider CreateEnumerableValueProvider( 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 9fdaf664f6..d816c9f39f 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.Globalization; using System.Linq; using System.Threading.Tasks; +using Microsoft.AspNet.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 async Task ContainsPrefixAsync_WithEmptyCollection_ReturnsFalseForEmptyPrefix() { // Arrange - var backingStore = new Dictionary(); + var backingStore = new Dictionary(); var valueProvider = GetEnumerableValueProvider(BindingSource.Query, backingStore, culture: null); // Act @@ -184,7 +185,7 @@ public async Task GetValueAsync_MultiValue() // Assert Assert.NotNull(result); - Assert.Equal(new[] { "someValue1", "someValue2" }, (IList)result.RawValue); + Assert.Equal(new[] { "someValue1", "someValue2" }, result.RawValue); Assert.Equal("someValue1,someValue2", result.AttemptedValue); Assert.Equal(culture, result.Culture); } @@ -209,7 +210,7 @@ public async Task GetValue_NullValue(string key) public async Task GetValueAsync_NullMultipleValue() { // Arrange - var backingStore = new Dictionary + var backingStore = new Dictionary { { "key", new string[] { null, null, "value" } }, }; @@ -278,7 +279,7 @@ public void FilterExclude() private IBindingSourceValueProvider GetBindingSourceValueProvider( BindingSource bindingSource, - IDictionary values, + IDictionary values, CultureInfo culture) { var provider = GetEnumerableValueProvider(bindingSource, values, culture) as IBindingSourceValueProvider; @@ -291,7 +292,7 @@ private IBindingSourceValueProvider GetBindingSourceValueProvider( 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 9e6216a9e1..124e5d2dc9 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.Tasks; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Internal; +using Microsoft.AspNet.Primitives; using Moq; using Xunit; @@ -20,10 +21,10 @@ public class FormCollectionModelBinderTest 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(FormCollection), httpContext); @@ -48,10 +49,10 @@ public async Task FormCollectionModelBinder_ValidType_BindSuccessful() 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); @@ -85,10 +86,10 @@ public async Task FormCollectionModelBinder_NoForm_BindSuccessful_ReturnsEmptyFo public async Task FormCollectionModelBinder_CustomFormCollection_BindSuccessful() { // Arrange - var formCollection = new MyFormCollection(new Dictionary + var formCollection = new MyFormCollection(new Dictionary { - { "field1", new string[] { "value1" } }, - { "field2", new string[] { "value2" } } + { "field1", "value1" }, + { "field2", "value2" } }); var httpContext = GetMockHttpContext(formCollection); var bindingContext = GetBindingContext(typeof(FormCollection), httpContext); @@ -134,11 +135,11 @@ private static ModelBindingContext GetBindingContext(Type modelType, HttpContext 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/JQueryFormValueProviderFactoryTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/JQueryFormValueProviderFactoryTest.cs index c95b2691d5..179f1bf956 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.Globalization; using System.Threading.Tasks; using Microsoft.AspNet.Http.Internal; +using Microsoft.AspNet.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" } }, @@ -118,7 +119,7 @@ public async Task GetValueProvider_ReturnsValueProvider_ContainingExpectedKeys(s private static ValueProviderFactoryContext CreateContext( string contentType, - IDictionary formValues) + IDictionary formValues) { var context = new DefaultHttpContext(); context.Request.ContentType = contentType; diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/JQueryFormValueProviderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/JQueryFormValueProviderTest.cs index 4fa1b91d66..1d2aef6e3f 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.AspNet.Primitives; namespace Microsoft.AspNet.Mvc.ModelBinding { @@ -10,7 +11,7 @@ public class JQueryFormValueProviderTest : EnumerableValueProviderTest { 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..7785496d70 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.AspNet.Primitives; namespace Microsoft.AspNet.Mvc.ModelBinding { @@ -11,7 +12,7 @@ public class ReadableStringCollectionValueProviderTest : EnumerableValueProvider { 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 @@ public void ResponseCacheFilter_DoesNotThrow_WhenNoStoreIsTrue() 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 @@ public void OnActionExecuting_CanSetCacheControlHeaders(ResponseCacheFilter cach 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 @@ public void OnActionExecuting_DoesNotSetLocationOrDuration_IfNoStoreIsSet( 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 @@ public void ResponseCacheCanSetVary(ResponseCacheFilter cache, string varyOutput 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 @@ public void SetsPragmaOnNoCache() 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 @@ public void FilterDurationProperty_OverridesCachePolicySetting() 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 @@ public void FilterLocationProperty_OverridesCachePolicySetting() 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 @@ public void FilterNoStoreProperty_OverridesCachePolicySetting() 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 @@ public void FilterVaryByProperty_OverridesCachePolicySetting() 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.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 @@ private ICorsService GetPassingEngine(bool supportsCredentials = false) .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.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 @@ private static HttpContext GetHttpContext(string contentType) { 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 @@ private static HttpContext GetHttpContext(string contentType) { 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.FunctionalTests/FiltersTest.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/FiltersTest.cs index b24c1e3949..f105f20cf7 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/FiltersTest.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/FiltersTest.cs @@ -68,12 +68,12 @@ public async Task ListAllFilters() 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 1037f03c09..bfecbf4c20 100644 --- a/test/Microsoft.AspNet.Mvc.IntegrationTests/CollectionModelBinderIntegrationTest.cs +++ b/test/Microsoft.AspNet.Mvc.IntegrationTests/CollectionModelBinderIntegrationTest.cs @@ -9,6 +9,7 @@ using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Internal; using Microsoft.AspNet.Mvc.ModelBinding; +using Microsoft.AspNet.Primitives; using Xunit; namespace Microsoft.AspNet.Mvc.IntegrationTests @@ -570,7 +571,7 @@ public async Task CollectionModelBinder_UsesCustomIndexes() 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" } }, @@ -629,7 +630,7 @@ public async Task CollectionModelBinder_UsesCustomIndexes_AddsErrorsWithCorrectK 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" } }, diff --git a/test/Microsoft.AspNet.Mvc.IntegrationTests/FormCollectionModelBindingIntegrationTest.cs b/test/Microsoft.AspNet.Mvc.IntegrationTests/FormCollectionModelBindingIntegrationTest.cs index b6d10783d1..9e28dadc88 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.Features.Internal; using Microsoft.AspNet.Http.Internal; using Microsoft.AspNet.Mvc.ModelBinding; +using Microsoft.AspNet.Primitives; using Xunit; namespace Microsoft.AspNet.Mvc.IntegrationTests @@ -163,7 +164,7 @@ public async Task BindParameter_NoData_BindsWithEmptyCollection() 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 89c21c0ed2..573d9f35c8 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.Features.Internal; using Microsoft.AspNet.Http.Internal; using Microsoft.AspNet.Mvc.ModelBinding; +using Microsoft.AspNet.Primitives; using Xunit; namespace Microsoft.AspNet.Mvc.IntegrationTests @@ -164,7 +165,7 @@ public async Task BindParameter_NoData_DoesNotGetBound() 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 d3f709ec4c..b5a5e3af5d 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.Features.Internal; using Microsoft.AspNet.Http.Internal; using Microsoft.AspNet.Mvc.ModelBinding; +using Microsoft.AspNet.Primitives; using Xunit; namespace Microsoft.AspNet.Mvc.IntegrationTests @@ -2127,7 +2128,7 @@ private static void SetJsonBodyContent(HttpRequest request, string content) 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/TypeConverterModelBinderIntegrationTest.cs b/test/Microsoft.AspNet.Mvc.IntegrationTests/TypeConverterModelBinderIntegrationTest.cs index 3b87dbbd12..8c1273a77a 100644 --- a/test/Microsoft.AspNet.Mvc.IntegrationTests/TypeConverterModelBinderIntegrationTest.cs +++ b/test/Microsoft.AspNet.Mvc.IntegrationTests/TypeConverterModelBinderIntegrationTest.cs @@ -9,6 +9,7 @@ using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Internal; using Microsoft.AspNet.Mvc.ModelBinding; +using Microsoft.AspNet.Primitives; using Xunit; namespace Microsoft.AspNet.Mvc.IntegrationTests @@ -328,19 +329,19 @@ public async Task BindParameter_NoData_DoesNotGetBound() 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" } }, @@ -352,7 +353,7 @@ public static TheoryData> PersonStoreData [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.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 @@ public async Task ExplicitlySet_MultipleEncodings_ChunkedNotIgnored() // 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 @@ public async Task ExplicitlySet_MultipleEncodingsUsingChunkedFlag_ChunkedNotIgno // 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 @@ public async Task RouteAsync(RouteContext context) 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/LoggingWebSite/Models/RequestInfoDto.cs b/test/WebSites/LoggingWebSite/Models/RequestInfoDto.cs index a51224ba03..79066880f8 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.AspNet.Primitives; namespace LoggingWebSite { @@ -22,10 +21,10 @@ public class RequestInfoDto 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 55c6418589..fd1520eaf4 100644 --- a/test/WebSites/ModelBindingWebSite/Controllers/ModelBinderAttribute_ProductController.cs +++ b/test/WebSites/ModelBindingWebSite/Controllers/ModelBinderAttribute_ProductController.cs @@ -73,7 +73,7 @@ public Task BindModelAsync(ModelBindingContext bindingContex // 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 7c8d5c0c3f..d42c767e0a 100644 --- a/test/WebSites/ModelBindingWebSite/Controllers/TryUpdateModelController.cs +++ b/test/WebSites/ModelBindingWebSite/Controllers/TryUpdateModelController.cs @@ -10,6 +10,7 @@ using Microsoft.AspNet.Http.Internal; using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc.ModelBinding; +using Microsoft.AspNet.Primitives; using ModelBindingWebSite.Models; namespace ModelBindingWebSite.Controllers @@ -107,7 +108,7 @@ public async Task GetUserAsync_WithChainedProperties(int id) 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 @@ await TryUpdateModelAsync( 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 @@ public IActionResult NoCacheAtAll() [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 @@ public VersionRangeValidator(int? minVersion, int? maxVersion) public static string GetVersion(HttpRequest request) { - return request.Query.Get("version"); + return request.Query["version"]; } public bool Accept(ActionConstraintContext context)