From bcbbc585158dfa93b1bab1e903c091e7601ab2cf Mon Sep 17 00:00:00 2001 From: Yishai Galatzer Date: Mon, 16 Feb 2015 17:33:23 -0800 Subject: [PATCH] Api cleanup (remove List and Dictionary in favor of IList and IDictionary) from the public surface copy header values on registration. Make a copy of the mediatypeheader value in FormatterMappings so it's really immutable. --- .../ActionDescriptor.cs | 12 +++---- .../ActionDescriptorProviderContext.cs | 2 +- .../ApplicationModelConventionExtensions.cs | 4 +-- .../ControllerActionDescriptorBuilder.cs | 2 +- .../ControllerActionDescriptorProvider.cs | 6 +++- ...aultActionDescriptorsCollectionProvider.cs | 4 ++- .../Description/ApiDescription.cs | 2 +- .../ApiDescriptionProviderContext.cs | 2 +- .../DefaultApiDescriptionProvider.cs | 6 +++- .../Filters/FilterProviderContext.cs | 4 +-- .../FormatterMappings.cs | 10 +++--- .../Internal/DecisionTree/DecisionTreeNode.cs | 4 +-- .../Routing/LinkGenerationDecisionTree.cs | 2 +- .../Logging/ActionDescriptorValues.cs | 14 ++++----- .../Logging/ControllerModelValues.cs | 12 +++---- .../Logging/FilterValues.cs | 2 +- src/Microsoft.AspNet.Mvc.Core/MvcOptions.cs | 31 +++++++++---------- .../InjectChunkVisitor.cs | 9 ++---- src/Microsoft.AspNet.Mvc.Razor/IRazorPage.cs | 4 +-- src/Microsoft.AspNet.Mvc.Razor/RazorPage.cs | 4 +-- .../ControllerActionInvokerTest.cs | 10 ++++-- .../DefaultApiDescriptionProviderTest.cs | 3 +- ...tion.cs => ControllerLicenseConvention.cs} | 2 +- .../ApplicationModelWebSite/Startup.cs | 2 +- 24 files changed, 83 insertions(+), 70 deletions(-) rename test/WebSites/ApplicationModelWebSite/Conventions/{ControllerLisenceConvention.cs => ControllerLicenseConvention.cs} (90%) diff --git a/src/Microsoft.AspNet.Mvc.Core/ActionDescriptor.cs b/src/Microsoft.AspNet.Mvc.Core/ActionDescriptor.cs index b920cc2ee6..5a90af5a35 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ActionDescriptor.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ActionDescriptor.cs @@ -17,20 +17,20 @@ namespace Microsoft.AspNet.Mvc public virtual string Name { get; set; } - public List RouteConstraints { get; set; } + public IList RouteConstraints { get; set; } public AttributeRouteInfo AttributeRouteInfo { get; set; } - public Dictionary RouteValueDefaults { get; private set; } + public IDictionary RouteValueDefaults { get; } /// /// The set of constraints for this action. Must all be satisfied for the action to be selected. /// - public List ActionConstraints { get; set; } + public IList ActionConstraints { get; set; } - public List Parameters { get; set; } + public IList Parameters { get; set; } - public List FilterDescriptors { get; set; } + public IList FilterDescriptors { get; set; } /// /// A friendly name for this action. @@ -40,6 +40,6 @@ namespace Microsoft.AspNet.Mvc /// /// Stores arbitrary metadata properties associated with the . /// - public IDictionary Properties { get; private set; } + public IDictionary Properties { get; } } } diff --git a/src/Microsoft.AspNet.Mvc.Core/ActionDescriptorProviderContext.cs b/src/Microsoft.AspNet.Mvc.Core/ActionDescriptorProviderContext.cs index d105b131be..76e18bd09b 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ActionDescriptorProviderContext.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ActionDescriptorProviderContext.cs @@ -12,6 +12,6 @@ namespace Microsoft.AspNet.Mvc Results = new List(); } - public List Results { get; private set; } + public IList Results { get; } } } diff --git a/src/Microsoft.AspNet.Mvc.Core/ApplicationModelConventionExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/ApplicationModelConventionExtensions.cs index ed838c8958..98f4254d91 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ApplicationModelConventionExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ApplicationModelConventionExtensions.cs @@ -19,7 +19,7 @@ namespace Microsoft.AspNet.Mvc /// The which needs to be /// added. public static void Add( - [NotNull] this List conventions, + [NotNull] this IList conventions, [NotNull] IControllerModelConvention controllerModelConvention) { conventions.Add(new ControllerApplicationModelConvention(controllerModelConvention)); @@ -33,7 +33,7 @@ namespace Microsoft.AspNet.Mvc /// The which needs to be /// added. public static void Add( - this List conventions, + this IList conventions, IActionModelConvention actionModelConvention) { conventions.Add(new ActionApplicationModelConvention(actionModelConvention)); diff --git a/src/Microsoft.AspNet.Mvc.Core/ControllerActionDescriptorBuilder.cs b/src/Microsoft.AspNet.Mvc.Core/ControllerActionDescriptorBuilder.cs index b8a358c146..ce157a260f 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ControllerActionDescriptorBuilder.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ControllerActionDescriptorBuilder.cs @@ -495,7 +495,7 @@ namespace Microsoft.AspNet.Mvc } } - private static bool HasConstraint(List constraints, string routeKey) + private static bool HasConstraint(IList constraints, string routeKey) { return constraints.Any( rc => string.Equals(rc.RouteKey, routeKey, StringComparison.OrdinalIgnoreCase)); diff --git a/src/Microsoft.AspNet.Mvc.Core/ControllerActionDescriptorProvider.cs b/src/Microsoft.AspNet.Mvc.Core/ControllerActionDescriptorProvider.cs index 75aade5bf6..88adeb08f5 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ControllerActionDescriptorProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ControllerActionDescriptorProvider.cs @@ -39,7 +39,11 @@ namespace Microsoft.AspNet.Mvc public void Invoke(ActionDescriptorProviderContext context, Action callNext) { - context.Results.AddRange(GetDescriptors()); + foreach (var descriptor in GetDescriptors()) + { + context.Results.Add(descriptor); + } + callNext(); } diff --git a/src/Microsoft.AspNet.Mvc.Core/DefaultActionDescriptorsCollectionProvider.cs b/src/Microsoft.AspNet.Mvc.Core/DefaultActionDescriptorsCollectionProvider.cs index 0ab1a13760..d4429a809f 100644 --- a/src/Microsoft.AspNet.Mvc.Core/DefaultActionDescriptorsCollectionProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Core/DefaultActionDescriptorsCollectionProvider.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 System.Collections.ObjectModel; using Microsoft.AspNet.Mvc.Logging; using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Logging; @@ -60,7 +61,8 @@ namespace Microsoft.AspNet.Mvc } } - return new ActionDescriptorsCollection(actionDescriptorProviderContext.Results, 0); + return new ActionDescriptorsCollection( + new ReadOnlyCollection(actionDescriptorProviderContext.Results), 0); } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.Core/Description/ApiDescription.cs b/src/Microsoft.AspNet.Mvc.Core/Description/ApiDescription.cs index ff3d97bc8b..052b311876 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Description/ApiDescription.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Description/ApiDescription.cs @@ -40,7 +40,7 @@ namespace Microsoft.AspNet.Mvc.Description /// /// The list of for this api. /// - public List ParameterDescriptions { get; private set; } + public IList ParameterDescriptions { get; private set; } /// /// Stores arbitrary metadata properties associated with the . diff --git a/src/Microsoft.AspNet.Mvc.Core/Description/ApiDescriptionProviderContext.cs b/src/Microsoft.AspNet.Mvc.Core/Description/ApiDescriptionProviderContext.cs index e4a0bfb14b..b7cba59438 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Description/ApiDescriptionProviderContext.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Description/ApiDescriptionProviderContext.cs @@ -29,6 +29,6 @@ namespace Microsoft.AspNet.Mvc.Description /// /// The list of resulting . /// - public List Results { get; private set; } + public IList Results { get; private set; } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.Core/Description/DefaultApiDescriptionProvider.cs b/src/Microsoft.AspNet.Mvc.Core/Description/DefaultApiDescriptionProvider.cs index 6f60cfb80f..a351017d10 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Description/DefaultApiDescriptionProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Description/DefaultApiDescriptionProvider.cs @@ -81,7 +81,11 @@ namespace Microsoft.AspNet.Mvc.Description var templateParameters = parsedTemplate?.Parameters?.ToList() ?? new List(); var parameterContext = new ApiParameterContext(_modelMetadataProvider, action, templateParameters); - apiDescription.ParameterDescriptions.AddRange(GetParameters(parameterContext)); + + foreach (var parameter in GetParameters(parameterContext)) + { + apiDescription.ParameterDescriptions.Add(parameter); + } var responseMetadataAttributes = GetResponseMetadataAttributes(action); diff --git a/src/Microsoft.AspNet.Mvc.Core/Filters/FilterProviderContext.cs b/src/Microsoft.AspNet.Mvc.Core/Filters/FilterProviderContext.cs index 7b0fca1514..aac7ded0e2 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Filters/FilterProviderContext.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Filters/FilterProviderContext.cs @@ -7,7 +7,7 @@ namespace Microsoft.AspNet.Mvc { public class FilterProviderContext { - public FilterProviderContext([NotNull] ActionContext actionContext, [NotNull] List items) + public FilterProviderContext([NotNull] ActionContext actionContext, [NotNull] IList items) { ActionContext = actionContext; Results = items; @@ -17,6 +17,6 @@ namespace Microsoft.AspNet.Mvc public ActionContext ActionContext { get; set; } // Results - public List Results { get; set; } + public IList Results { get; set; } } } diff --git a/src/Microsoft.AspNet.Mvc.Core/FormatterMappings.cs b/src/Microsoft.AspNet.Mvc.Core/FormatterMappings.cs index b1f18673e1..aa3754ed95 100644 --- a/src/Microsoft.AspNet.Mvc.Core/FormatterMappings.cs +++ b/src/Microsoft.AspNet.Mvc.Core/FormatterMappings.cs @@ -26,7 +26,7 @@ namespace Microsoft.AspNet.Mvc { ValidateContentType(contentType); format = RemovePeriodIfPresent(format); - _map[format] = contentType; + _map[format] = MediaTypeHeaderValue.Parse(contentType.ToString()); } /// @@ -40,7 +40,7 @@ namespace Microsoft.AspNet.Mvc MediaTypeHeaderValue value = null; _map.TryGetValue(format, out value); - + return value; } @@ -77,10 +77,10 @@ namespace Microsoft.AspNet.Mvc throw new ArgumentException(string.Format(Resources.Format_NotValid, format)); } - format = format.Substring(1); - } + format = format.Substring(1); + } return format; - } + } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.Core/Internal/DecisionTree/DecisionTreeNode.cs b/src/Microsoft.AspNet.Mvc.Core/Internal/DecisionTree/DecisionTreeNode.cs index 3f49b8eff4..c314474aff 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Internal/DecisionTree/DecisionTreeNode.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Internal/DecisionTree/DecisionTreeNode.cs @@ -11,10 +11,10 @@ namespace Microsoft.AspNet.Mvc.Internal.DecisionTree { // The list of matches for the current node. This represents a set of items that have had all // of their criteria matched if control gets to this point in the tree. - public List Matches { get; set; } + public IList Matches { get; set; } // Additional criteria that further branch out from this node. Walk these to fine more items // matching the input data. - public List> Criteria { get; set; } + public IList> Criteria { get; set; } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.Core/Internal/Routing/LinkGenerationDecisionTree.cs b/src/Microsoft.AspNet.Mvc.Core/Internal/Routing/LinkGenerationDecisionTree.cs index 22d9b20281..a7e1f7b0f9 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Internal/Routing/LinkGenerationDecisionTree.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Internal/Routing/LinkGenerationDecisionTree.cs @@ -21,7 +21,7 @@ namespace Microsoft.AspNet.Mvc.Internal.Routing new AttributeRouteLinkGenerationEntryClassifier()); } - public List GetMatches(VirtualPathContext context) + public IList GetMatches(VirtualPathContext context) { var results = new List(); Walk(results, context, _root, isFallbackPath: false); diff --git a/src/Microsoft.AspNet.Mvc.Core/Logging/ActionDescriptorValues.cs b/src/Microsoft.AspNet.Mvc.Core/Logging/ActionDescriptorValues.cs index 8dc5de8420..df29d3f5ea 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Logging/ActionDescriptorValues.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Logging/ActionDescriptorValues.cs @@ -51,19 +51,19 @@ namespace Microsoft.AspNet.Mvc.Logging /// The parameters of the action as . /// See . /// - public List Parameters { get; } + public IList Parameters { get; } /// /// The filters of the action as . /// See . /// - public List FilterDescriptors { get; } + public IList FilterDescriptors { get; } /// /// The route constraints of the action as . /// See /// - public List RouteConstraints { get; } + public IList RouteConstraints { get; } /// /// The attribute route info of the action as . @@ -74,23 +74,23 @@ namespace Microsoft.AspNet.Mvc.Logging /// /// See . /// - public Dictionary RouteValueDefaults { get; } + public IDictionary RouteValueDefaults { get; } /// /// The action constraints of the action as . /// See . /// - public List ActionConstraints { get; } + public IList ActionConstraints { get; } /// /// The http methods this action supports. /// - public List HttpMethods { get; } + public IList HttpMethods { get; } /// /// See . /// - public Dictionary Properties { get; } + public IDictionary Properties { get; } /// /// The method info of the action if this is a . diff --git a/src/Microsoft.AspNet.Mvc.Core/Logging/ControllerModelValues.cs b/src/Microsoft.AspNet.Mvc.Core/Logging/ControllerModelValues.cs index ae86c189d9..3b97532a49 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Logging/ControllerModelValues.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Logging/ControllerModelValues.cs @@ -52,37 +52,37 @@ namespace Microsoft.AspNet.Mvc.Logging /// The actions of the controller as . /// See . /// - public List Actions { get; } + public IList Actions { get; } /// /// The s of the controller's attributes. /// See . /// - public List Attributes { get; } + public IList Attributes { get; } /// /// The filters on the controller as . /// See . /// - public List Filters { get; } + public IList Filters { get; } /// /// The action constraints on the controller as . /// See . /// - public List ActionConstraints { get; } + public IList ActionConstraints { get; } /// /// The route constraints on the controller as . /// See . /// - public List RouteConstraints { get; set; } + public IList RouteConstraints { get; set; } /// /// The attribute routes on the controller as . /// See . /// - public List AttributeRoutes { get; set; } + public IList AttributeRoutes { get; set; } /// /// Gets the set of properties associated with the controller . diff --git a/src/Microsoft.AspNet.Mvc.Core/Logging/FilterValues.cs b/src/Microsoft.AspNet.Mvc.Core/Logging/FilterValues.cs index 2e6fa23978..669dce246e 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Logging/FilterValues.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Logging/FilterValues.cs @@ -59,7 +59,7 @@ namespace Microsoft.AspNet.Mvc.Logging /// /// A list of interfaces the implements. /// - public List FilterInterfaces { get; } + public IList FilterInterfaces { get; } public override string Format() { diff --git a/src/Microsoft.AspNet.Mvc.Core/MvcOptions.cs b/src/Microsoft.AspNet.Mvc.Core/MvcOptions.cs index 3e84d7cc12..7b267d17a4 100644 --- a/src/Microsoft.AspNet.Mvc.Core/MvcOptions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/MvcOptions.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Linq; using Microsoft.AspNet.Mvc.ApplicationModels; using Microsoft.AspNet.Mvc.Core; using Microsoft.AspNet.Mvc.OptionDescriptors; @@ -30,6 +29,9 @@ namespace Microsoft.AspNet.Mvc InputFormatters = new List(); Filters = new List(); FormatterMappings = new FormatterMappings(); + ValidationExcludeFilters = new List(); + ModelValidatorProviders = new List(); + CacheProfiles = new Dictionary(StringComparer.OrdinalIgnoreCase); } /// @@ -70,21 +72,20 @@ namespace Microsoft.AspNet.Mvc /// Gets a list of the which are used to construct /// a list of by . /// - public List OutputFormatters { get; private set; } + public IList OutputFormatters { get; } /// /// Gets a list of the which are used to construct /// a list of by . /// - public List InputFormatters { get; private set; } + public IList InputFormatters { get; } /// /// Gets a list of which are used to construct a list /// of exclude filters by . /// - public List ValidationExcludeFilters { get; } - = new List(); - + public IList ValidationExcludeFilters { get; } + /// /// Gets or sets the maximum number of validation errors that are allowed by this application before further /// errors are ignored. @@ -108,44 +109,42 @@ namespace Microsoft.AspNet.Mvc /// Gets a list of the used by the /// . /// - public List ModelBinders { get; private set; } + public IList ModelBinders { get; } /// /// Gets a list of the s used by /// . /// - public List ModelValidatorProviders { get; } - = new List(); + public IList ModelValidatorProviders { get; } /// /// Gets a list of descriptors that represent used /// by this application. /// - public List ViewEngines { get; private set; } + public IList ViewEngines { get; } /// /// Gets a list of descriptors that represent /// used by this application. /// - public List ValueProviderFactories { get; private set; } + public IList ValueProviderFactories { get; } /// /// Gets a list of instances that will be applied to /// the when discovering actions. /// - public List Conventions { get; private set; } + public IList Conventions { get; } /// /// Gets or sets the flag which causes content negotiation to ignore Accept header /// when it contains the media type */*. by default. /// - public bool RespectBrowserAcceptHeader { get; set; } = false; - + public bool RespectBrowserAcceptHeader { get; set; } + /// /// Gets a Dictionary of CacheProfile Names, which are pre-defined settings for /// . /// - public Dictionary CacheProfiles { get; } - = new Dictionary(StringComparer.OrdinalIgnoreCase); + public IDictionary CacheProfiles { get; } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/InjectChunkVisitor.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/InjectChunkVisitor.cs index 3fb71b5029..78ca8cff4a 100644 --- a/src/Microsoft.AspNet.Mvc.Razor.Host/InjectChunkVisitor.cs +++ b/src/Microsoft.AspNet.Mvc.Razor.Host/InjectChunkVisitor.cs @@ -9,7 +9,6 @@ namespace Microsoft.AspNet.Mvc.Razor { public class InjectChunkVisitor : MvcCSharpCodeVisitor { - private readonly List _injectChunks = new List(); private readonly string _activateAttribute; public InjectChunkVisitor([NotNull] CSharpCodeWriter writer, @@ -20,10 +19,7 @@ namespace Microsoft.AspNet.Mvc.Razor _activateAttribute = "[" + activateAttributeName + "]"; } - public List InjectChunks - { - get { return _injectChunks; } - } + public IList InjectChunks { get; } = new List(); protected override void Visit([NotNull] InjectChunk chunk) { @@ -53,7 +49,8 @@ namespace Microsoft.AspNet.Mvc.Razor .Write(chunk.MemberName) .WriteLine(" { get; private set; }"); } - _injectChunks.Add(chunk); + + InjectChunks.Add(chunk); } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.Razor/IRazorPage.cs b/src/Microsoft.AspNet.Mvc.Razor/IRazorPage.cs index 6e62b4a2b8..35d2ceec3e 100644 --- a/src/Microsoft.AspNet.Mvc.Razor/IRazorPage.cs +++ b/src/Microsoft.AspNet.Mvc.Razor/IRazorPage.cs @@ -58,12 +58,12 @@ namespace Microsoft.AspNet.Mvc.Razor /// /// Gets or sets the sections that can be rendered by this page. /// - Dictionary PreviousSectionWriters { get; set; } + IDictionary PreviousSectionWriters { get; set; } /// /// Gets the sections that are defined by this page. /// - Dictionary SectionWriters { get; } + IDictionary SectionWriters { get; } /// /// Renders the page and writes the output to the . diff --git a/src/Microsoft.AspNet.Mvc.Razor/RazorPage.cs b/src/Microsoft.AspNet.Mvc.Razor/RazorPage.cs index 630510435b..a94bf9e728 100644 --- a/src/Microsoft.AspNet.Mvc.Razor/RazorPage.cs +++ b/src/Microsoft.AspNet.Mvc.Razor/RazorPage.cs @@ -108,10 +108,10 @@ namespace Microsoft.AspNet.Mvc.Razor public bool IsLayoutBeingRendered { get; set; } /// - public Dictionary PreviousSectionWriters { get; set; } + public IDictionary PreviousSectionWriters { get; set; } /// - public Dictionary SectionWriters { get; private set; } + public IDictionary SectionWriters { get; private set; } /// public abstract Task ExecuteAsync(); diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ControllerActionInvokerTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ControllerActionInvokerTest.cs index a9f012eb15..b94c4bbfa4 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ControllerActionInvokerTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ControllerActionInvokerTest.cs @@ -1979,8 +1979,14 @@ namespace Microsoft.AspNet.Mvc var filterProvider = new Mock>(MockBehavior.Strict); filterProvider .Setup(fp => fp.Invoke(It.IsAny())) - .Callback( - context => context.Results.AddRange(filters.Select(f => new FilterItem(null, f)))); + .Callback(context => + { + foreach (var filter in filters.Select(f => new FilterItem(null, f))) + { + context.Results.Add(filter); + } + }); + var inputFormattersProvider = new Mock(); inputFormattersProvider.SetupGet(o => o.InputFormatters) .Returns(new List()); diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Description/DefaultApiDescriptionProviderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Description/DefaultApiDescriptionProviderTest.cs index 87f118a533..efd5878343 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Description/DefaultApiDescriptionProviderTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Description/DefaultApiDescriptionProviderTest.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Reflection; using System.Threading.Tasks; @@ -925,7 +926,7 @@ namespace Microsoft.AspNet.Mvc.Description modelMetadataProvider); provider.Invoke(context, () => { }); - return context.Results; + return new ReadOnlyCollection(context.Results); } private List CreateFormatters() diff --git a/test/WebSites/ApplicationModelWebSite/Conventions/ControllerLisenceConvention.cs b/test/WebSites/ApplicationModelWebSite/Conventions/ControllerLicenseConvention.cs similarity index 90% rename from test/WebSites/ApplicationModelWebSite/Conventions/ControllerLisenceConvention.cs rename to test/WebSites/ApplicationModelWebSite/Conventions/ControllerLicenseConvention.cs index b25c043448..080e3658e6 100644 --- a/test/WebSites/ApplicationModelWebSite/Conventions/ControllerLisenceConvention.cs +++ b/test/WebSites/ApplicationModelWebSite/Conventions/ControllerLicenseConvention.cs @@ -5,7 +5,7 @@ using Microsoft.AspNet.Mvc.ApplicationModels; namespace ApplicationModelWebSite { - public class ControllerLisenceConvention : IControllerModelConvention + public class ControllerLicenseConvention : IControllerModelConvention { public void Apply(ControllerModel controller) { diff --git a/test/WebSites/ApplicationModelWebSite/Startup.cs b/test/WebSites/ApplicationModelWebSite/Startup.cs index 030dc2da71..b13a74ced1 100644 --- a/test/WebSites/ApplicationModelWebSite/Startup.cs +++ b/test/WebSites/ApplicationModelWebSite/Startup.cs @@ -20,7 +20,7 @@ namespace ApplicationModelWebSite services.Configure(options => { options.Conventions.Add(new ApplicationDescription("Common Application Description")); - options.Conventions.Add(new ControllerLisenceConvention()); + options.Conventions.Add(new ControllerLicenseConvention()); options.Conventions.Add(new FromHeaderConvention()); }); });