Code clean up
This commit is contained in:
parent
6961cf9211
commit
1c4b0fcdf3
|
|
@ -2,7 +2,6 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNetCore.Mvc.Formatters;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.ApiExplorer
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
/// Initializes a new instance of the <see cref="FormatterCollection{TFormatter}"/> class that is empty.
|
||||
/// </summary>
|
||||
public FormatterCollection()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
// 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.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
||||
{
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|||
}
|
||||
else
|
||||
{
|
||||
return $"Failed";
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -419,7 +419,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|||
/// <inheritdoc />
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return base.Equals(obj as ModelMetadata);
|
||||
return Equals(obj as ModelMetadata);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc.Abstractions;
|
||||
|
|
@ -118,7 +117,7 @@ namespace Microsoft.AspNetCore.Mvc.ApiExplorer
|
|||
|
||||
var runtimeReturnType = GetRuntimeReturnType(declaredReturnType);
|
||||
|
||||
var apiResponseTypes = GetApiResponseTypes(action, responseMetadataAttributes, runtimeReturnType);
|
||||
var apiResponseTypes = GetApiResponseTypes(responseMetadataAttributes, runtimeReturnType);
|
||||
foreach (var apiResponseType in apiResponseTypes)
|
||||
{
|
||||
apiDescription.SupportedResponseTypes.Add(apiResponseType);
|
||||
|
|
@ -128,7 +127,7 @@ namespace Microsoft.AspNetCore.Mvc.ApiExplorer
|
|||
// could end up with duplicate data.
|
||||
foreach (var parameter in apiDescription.ParameterDescriptions.Where(p => p.Source == BindingSource.Body))
|
||||
{
|
||||
var requestFormats = GetRequestFormats(action, requestMetadataAttributes, parameter.Type);
|
||||
var requestFormats = GetRequestFormats(requestMetadataAttributes, parameter.Type);
|
||||
foreach (var format in requestFormats)
|
||||
{
|
||||
apiDescription.SupportedRequestFormats.Add(format);
|
||||
|
|
@ -302,7 +301,6 @@ namespace Microsoft.AspNetCore.Mvc.ApiExplorer
|
|||
}
|
||||
|
||||
private IReadOnlyList<ApiRequestFormat> GetRequestFormats(
|
||||
ControllerActionDescriptor action,
|
||||
IApiRequestMetadataProvider[] requestMetadataAttributes,
|
||||
Type type)
|
||||
{
|
||||
|
|
@ -352,7 +350,6 @@ namespace Microsoft.AspNetCore.Mvc.ApiExplorer
|
|||
}
|
||||
|
||||
private IReadOnlyList<ApiResponseType> GetApiResponseTypes(
|
||||
ControllerActionDescriptor action,
|
||||
IApiResponseMetadataProvider[] responseMetadataAttributes,
|
||||
Type type)
|
||||
{
|
||||
|
|
@ -579,7 +576,7 @@ namespace Microsoft.AspNetCore.Mvc.ApiExplorer
|
|||
Context = context;
|
||||
Parameter = parameter;
|
||||
|
||||
Visited = new HashSet<PropertyKey>();
|
||||
Visited = new HashSet<PropertyKey>(new PropertyKeyEqualityComparer());
|
||||
}
|
||||
|
||||
public ApiParameterContext Context { get; }
|
||||
|
|
@ -736,7 +733,11 @@ namespace Microsoft.AspNetCore.Mvc.ApiExplorer
|
|||
|
||||
public int GetHashCode(PropertyKey obj)
|
||||
{
|
||||
return obj.ContainerType.GetHashCode() ^ obj.PropertyName.GetHashCode() ^ obj.Source.GetHashCode();
|
||||
var hashCodeCombiner = HashCodeCombiner.Start();
|
||||
hashCodeCombiner.Add(obj.ContainerType);
|
||||
hashCodeCombiner.Add(obj.PropertyName);
|
||||
hashCodeCombiner.Add(obj.Source);
|
||||
return hashCodeCombiner.CombinedHash;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
<ProjectReference Include="..\Microsoft.AspNetCore.Mvc.Core\Microsoft.AspNetCore.Mvc.Core.csproj" />
|
||||
|
||||
<PackageReference Include="Microsoft.Extensions.ClosedGenericMatcher.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
|
||||
<PackageReference Include="Microsoft.Extensions.HashCodeCombiner.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
|
||||
<PackageReference Include="Microsoft.Extensions.PropertyHelper.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
/// </summary>
|
||||
/// <param name="method">The HTTP method the action supports.</param>
|
||||
public AcceptVerbsAttribute(string method)
|
||||
: this(new string[] { method })
|
||||
: this(new [] { method })
|
||||
{
|
||||
if (method == null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc.Internal;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.ApiExplorer
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ using System.Diagnostics;
|
|||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.AspNetCore.Mvc.Routing;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.ApplicationModels
|
||||
|
|
|
|||
|
|
@ -5,16 +5,13 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Authorization.Policy;
|
||||
using Microsoft.AspNetCore.Mvc.Core;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.AspNetCore.Mvc.Internal;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Internal;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Authorization
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
// 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.IO;
|
||||
using System.Linq.Expressions;
|
||||
using System.Security.Claims;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
/// The default constructor is provided for unit test purposes only.
|
||||
/// </remarks>
|
||||
public ControllerContext()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ namespace Microsoft.AspNetCore.Mvc.Controllers
|
|||
/// </summary>
|
||||
public class ControllerActivatorProvider : IControllerActivatorProvider
|
||||
{
|
||||
private static readonly Func<Type, ObjectFactory> _createFactory = (type) => ActivatorUtilities.CreateFactory(type, Type.EmptyTypes);
|
||||
private static readonly Action<ControllerContext, object> _dispose = Dispose;
|
||||
private readonly Func<ControllerContext, object> _controllerActivatorCreate;
|
||||
private readonly Action<ControllerContext, object> _controllerActivatorRelease;
|
||||
|
|
|
|||
|
|
@ -2,9 +2,7 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNetCore.Mvc.Core;
|
||||
using Microsoft.AspNetCore.Mvc.Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc.Internal;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Controllers
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
// 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;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
throw new ArgumentNullException(nameof(setupAction));
|
||||
}
|
||||
|
||||
builder.Services.Configure<MvcOptions>(setupAction);
|
||||
builder.Services.Configure(setupAction);
|
||||
return builder;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
throw new ArgumentNullException(nameof(setupAction));
|
||||
}
|
||||
|
||||
builder.Services.Configure<MvcOptions>(setupAction);
|
||||
builder.Services.Configure(setupAction);
|
||||
return builder;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNetCore.Mvc.Core;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Filters
|
||||
|
|
|
|||
|
|
@ -77,8 +77,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
|
||||
format = RemovePeriodIfPresent(format);
|
||||
|
||||
string value = null;
|
||||
_map.TryGetValue(format, out value);
|
||||
_map.TryGetValue(format, out var value);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -684,9 +684,6 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
|
||||
private struct MediaTypeParameter : IEquatable<MediaTypeParameter>
|
||||
{
|
||||
public static readonly StringSegment Type = new StringSegment("type");
|
||||
public static readonly StringSegment Subtype = new StringSegment("subtype");
|
||||
|
||||
public MediaTypeParameter(StringSegment name, StringSegment value)
|
||||
{
|
||||
Name = name;
|
||||
|
|
|
|||
|
|
@ -12,13 +12,6 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
/// </summary>
|
||||
public class MediaTypeCollection : Collection<string>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref="MediaTypeCollection"/>.
|
||||
/// </summary>
|
||||
public MediaTypeCollection()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an object to the end of the <see cref="MediaTypeCollection"/>.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
throw new ArgumentNullException(nameof(context));
|
||||
}
|
||||
|
||||
var request = context.HttpContext.Request;
|
||||
var selectedEncoding = SelectCharacterEncoding(context);
|
||||
if (selectedEncoding == null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -207,7 +207,6 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
private IList<StringWithQualityHeaderValue> Sort(IList<StringWithQualityHeaderValue> values)
|
||||
{
|
||||
var sortNeeded = false;
|
||||
var count = 0;
|
||||
|
||||
for (var i = 0; i < values.Count; i++)
|
||||
{
|
||||
|
|
@ -218,13 +217,8 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
}
|
||||
else if (value.Quality != null)
|
||||
{
|
||||
count++;
|
||||
sortNeeded = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!sortNeeded)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
/// </summary>
|
||||
public class HttpDeleteAttribute : HttpMethodAttribute
|
||||
{
|
||||
private static readonly IEnumerable<string> _supportedMethods = new string[] { "DELETE" };
|
||||
private static readonly IEnumerable<string> _supportedMethods = new [] { "DELETE" };
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="HttpDeleteAttribute"/>.
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
/// </summary>
|
||||
public class HttpGetAttribute : HttpMethodAttribute
|
||||
{
|
||||
private static readonly IEnumerable<string> _supportedMethods = new string[] { "GET" };
|
||||
private static readonly IEnumerable<string> _supportedMethods = new [] { "GET" };
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="HttpGetAttribute"/>.
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
/// </summary>
|
||||
public class HttpHeadAttribute : HttpMethodAttribute
|
||||
{
|
||||
private static readonly IEnumerable<string> _supportedMethods = new string[] { "HEAD" };
|
||||
private static readonly IEnumerable<string> _supportedMethods = new [] { "HEAD" };
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="HttpHeadAttribute"/>.
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
/// </summary>
|
||||
public class HttpOptionsAttribute : HttpMethodAttribute
|
||||
{
|
||||
private static readonly IEnumerable<string> _supportedMethods = new string[] { "OPTIONS" };
|
||||
private static readonly IEnumerable<string> _supportedMethods = new [] { "OPTIONS" };
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="HttpOptionsAttribute"/>.
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
/// </summary>
|
||||
public class HttpPatchAttribute : HttpMethodAttribute
|
||||
{
|
||||
private static readonly IEnumerable<string> _supportedMethods = new string[] { "PATCH" };
|
||||
private static readonly IEnumerable<string> _supportedMethods = new [] { "PATCH" };
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="HttpPatchAttribute"/>.
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
/// </summary>
|
||||
public class HttpPostAttribute : HttpMethodAttribute
|
||||
{
|
||||
private static readonly IEnumerable<string> _supportedMethods = new string[] { "POST" };
|
||||
private static readonly IEnumerable<string> _supportedMethods = new [] { "POST" };
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="HttpPostAttribute"/>.
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
/// </summary>
|
||||
public class HttpPutAttribute : HttpMethodAttribute
|
||||
{
|
||||
private static readonly IEnumerable<string> _supportedMethods = new string[] { "PUT" };
|
||||
private static readonly IEnumerable<string> _supportedMethods = new [] { "PUT" };
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="HttpPutAttribute"/>.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.AspNetCore.Mvc.Core;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Formatters.Internal
|
||||
{
|
||||
|
|
@ -71,8 +70,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Internal
|
|||
return true;
|
||||
}
|
||||
|
||||
var separatorFound = false;
|
||||
var currentIndex = GetNextNonEmptyOrWhitespaceIndex(value, index, out separatorFound);
|
||||
var currentIndex = GetNextNonEmptyOrWhitespaceIndex(value, index, out var separatorFound);
|
||||
|
||||
if (currentIndex == value.Length)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
|
||||
if (handlerFactory == null)
|
||||
{
|
||||
_handlerFactory = handlerFactory;
|
||||
throw new ArgumentNullException(nameof(handlerFactory));
|
||||
}
|
||||
|
||||
_actionDescriptorCollectionProvider = actionDescriptorCollectionProvider;
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
.Where(constraint => !(constraint is IRouteTemplateProvider)).ToList();
|
||||
}
|
||||
|
||||
AddActionConstraints(actionDescriptor, action, actionSelectorModel, controllerConstraints);
|
||||
AddActionConstraints(actionDescriptor, actionSelectorModel, controllerConstraints);
|
||||
}
|
||||
else if (controllerAttributeRoutes.Count > 0)
|
||||
{
|
||||
|
|
@ -195,7 +195,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
// metadata from the 'other' attribute routes.
|
||||
var controllerConstraints = controllerSelectorModel.ActionConstraints
|
||||
.Where(c => c == controllerAttributeRoute?.Attribute || !(c is IRouteTemplateProvider));
|
||||
AddActionConstraints(actionDescriptor, action, actionSelectorModel, controllerConstraints);
|
||||
AddActionConstraints(actionDescriptor, actionSelectorModel, controllerConstraints);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -216,7 +216,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
// If there's no attribute route on the controller, then we use all of the filters/constraints
|
||||
// on the controller regardless.
|
||||
AddActionFilters(actionDescriptor, action.Filters, controller.Filters, application.Filters);
|
||||
AddActionConstraints(actionDescriptor, action, actionSelectorModel, controllerConstraints);
|
||||
AddActionConstraints(actionDescriptor, actionSelectorModel, controllerConstraints);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -378,7 +378,6 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
|
||||
private static void AddActionConstraints(
|
||||
ControllerActionDescriptor actionDescriptor,
|
||||
ActionModel action,
|
||||
SelectorModel selectorModel,
|
||||
IEnumerable<IActionConstraintMetadata> controllerConstraints)
|
||||
{
|
||||
|
|
@ -673,8 +672,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
ActionModel action,
|
||||
IList<ControllerActionDescriptor> actionDescriptors)
|
||||
{
|
||||
IDictionary<ActionModel, IList<ControllerActionDescriptor>> actionsForMethod = null;
|
||||
if (TryGetValue(action.ActionMethod, out actionsForMethod))
|
||||
if (TryGetValue(action.ActionMethod, out var actionsForMethod))
|
||||
{
|
||||
actionsForMethod.Add(action, actionDescriptors);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,9 +54,6 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
|
||||
private Task Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
|
||||
{
|
||||
var diagnosticSource = _diagnosticSource;
|
||||
var logger = _logger;
|
||||
|
||||
switch (next)
|
||||
{
|
||||
case State.ActionBegin:
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
throw new ArgumentNullException(nameof(context));
|
||||
}
|
||||
|
||||
if (context.ActionContext.ActionDescriptor is ControllerActionDescriptor actionDescriptor)
|
||||
if (context.ActionContext.ActionDescriptor is ControllerActionDescriptor)
|
||||
{
|
||||
var controllerContext = new ControllerContext(context.ActionContext);
|
||||
// PERF: These are rarely going to be changed, so let's go copy-on-write.
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
var currentTypeInfo = typeInfo;
|
||||
var objectTypeInfo = typeof(object).GetTypeInfo();
|
||||
|
||||
IRouteTemplateProvider[] routeAttributes = null;
|
||||
IRouteTemplateProvider[] routeAttributes;
|
||||
|
||||
do
|
||||
{
|
||||
|
|
@ -139,7 +139,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
|
||||
// CoreCLR returns IEnumerable<Attribute> from GetCustomAttributes - the OfType<object>
|
||||
// is needed to so that the result of ToArray() is object
|
||||
var attributes = typeInfo.GetCustomAttributes(inherit: true).OfType<object>().ToArray();
|
||||
var attributes = typeInfo.GetCustomAttributes(inherit: true);
|
||||
|
||||
// This is fairly complicated so that we maintain referential equality between items in
|
||||
// ControllerModel.Attributes and ControllerModel.Attributes[*].Attribute.
|
||||
|
|
@ -220,7 +220,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
|
||||
// CoreCLR returns IEnumerable<Attribute> from GetCustomAttributes - the OfType<object>
|
||||
// is needed to so that the result of ToArray() is object
|
||||
var attributes = propertyInfo.GetCustomAttributes(inherit: true).OfType<object>().ToArray();
|
||||
var attributes = propertyInfo.GetCustomAttributes(inherit: true);
|
||||
var propertyModel = new PropertyModel(propertyInfo, attributes);
|
||||
var bindingInfo = BindingInfo.GetBindingInfo(attributes);
|
||||
|
||||
|
|
@ -261,7 +261,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
|
||||
// CoreCLR returns IEnumerable<Attribute> from GetCustomAttributes - the OfType<object>
|
||||
// is needed to so that the result of ToArray() is object
|
||||
var attributes = methodInfo.GetCustomAttributes(inherit: true).OfType<object>().ToArray();
|
||||
var attributes = methodInfo.GetCustomAttributes(inherit: true);
|
||||
|
||||
var actionModel = new ActionModel(methodInfo, attributes);
|
||||
|
||||
|
|
@ -304,7 +304,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
// Then we want to 'filter' the set of attributes, so that only the effective routes apply.
|
||||
var currentMethodInfo = methodInfo;
|
||||
|
||||
IRouteTemplateProvider[] routeAttributes = null;
|
||||
IRouteTemplateProvider[] routeAttributes;
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
|
@ -432,7 +432,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
|
||||
// CoreCLR returns IEnumerable<Attribute> from GetCustomAttributes - the OfType<object>
|
||||
// is needed to so that the result of ToArray() is object
|
||||
var attributes = parameterInfo.GetCustomAttributes(inherit: true).OfType<object>().ToArray();
|
||||
var attributes = parameterInfo.GetCustomAttributes(inherit: true);
|
||||
var parameterModel = new ParameterModel(parameterInfo, attributes);
|
||||
|
||||
var bindingInfo = BindingInfo.GetBindingInfo(attributes);
|
||||
|
|
|
|||
|
|
@ -20,13 +20,6 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|||
private State _state;
|
||||
private readonly Stack<State> _stack = new Stack<State>();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DefaultModelBindingContext"/> class.
|
||||
/// </summary>
|
||||
public DefaultModelBindingContext()
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override ActionContext ActionContext
|
||||
{
|
||||
|
|
|
|||
|
|
@ -60,10 +60,8 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
var response = context.HttpContext.Response;
|
||||
var outputStream = response.Body;
|
||||
var fileContentsStream = new MemoryStream(result.FileContents);
|
||||
return WriteFileAsync(context.HttpContext, fileContentsStream, range, rangeLength);
|
||||
var fileContentStream = new MemoryStream(result.FileContents);
|
||||
return WriteFileAsync(context.HttpContext, fileContentStream, range, rangeLength);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,8 +65,6 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
var response = context.HttpContext.Response;
|
||||
var outputStream = response.Body;
|
||||
return WriteFileAsync(context.HttpContext, result.FileStream, range, rangeLength);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Internal
|
|||
}
|
||||
|
||||
var nestedLength = 0;
|
||||
HttpParseResult nestedResult = GetExpressionLength(input, current, openChar, closeChar,
|
||||
var nestedResult = GetExpressionLength(input, current, openChar, closeChar,
|
||||
supportsNesting, ref nestedCount, out nestedLength);
|
||||
|
||||
switch (nestedResult)
|
||||
|
|
|
|||
|
|
@ -46,13 +46,12 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
var urlHelper = result.UrlHelper ?? _urlHelperFactory.GetUrlHelper(context);
|
||||
|
||||
// IsLocalUrl is called to handle Urls starting with '~/'.
|
||||
var destinationUrl = result.Url;
|
||||
if (!urlHelper.IsLocalUrl(result.Url))
|
||||
{
|
||||
throw new InvalidOperationException(Resources.UrlNotLocal);
|
||||
}
|
||||
|
||||
destinationUrl = urlHelper.Content(result.Url);
|
||||
var destinationUrl = urlHelper.Content(result.Url);
|
||||
_logger.LocalRedirectResultExecuting(destinationUrl);
|
||||
|
||||
if (result.PreserveMethod)
|
||||
|
|
|
|||
|
|
@ -2,9 +2,7 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc.ApplicationParts;
|
||||
using Microsoft.AspNetCore.Mvc.Infrastructure;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Internal
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
}
|
||||
|
||||
var request = formatterContext.HttpContext.Request;
|
||||
var acceptableMediaTypes = GetAcceptableMediaTypes(contentTypes, request);
|
||||
var acceptableMediaTypes = GetAcceptableMediaTypes(request);
|
||||
var selectFormatterWithoutRegardingAcceptHeader = false;
|
||||
IOutputFormatter selectedFormatter = null;
|
||||
|
||||
|
|
@ -254,12 +254,11 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
}
|
||||
|
||||
private List<MediaTypeSegmentWithQuality> GetAcceptableMediaTypes(
|
||||
MediaTypeCollection contentTypes,
|
||||
HttpRequest request)
|
||||
{
|
||||
var result = new List<MediaTypeSegmentWithQuality>();
|
||||
AcceptHeaderParser.ParseAcceptHeader(request.Headers[HeaderNames.Accept], result);
|
||||
for (int i = 0; i < result.Count; i++)
|
||||
for (var i = 0; i < result.Count; i++)
|
||||
{
|
||||
var mediaType = new MediaType(result[i].MediaType);
|
||||
if (!RespectBrowserAcceptHeader && mediaType.MatchesAllSubTypes && mediaType.MatchesAllTypes)
|
||||
|
|
|
|||
|
|
@ -159,9 +159,6 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
|
||||
private Task Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
|
||||
{
|
||||
var diagnosticSource = _diagnosticSource;
|
||||
var logger = _logger;
|
||||
|
||||
switch (next)
|
||||
{
|
||||
case State.InvokeBegin:
|
||||
|
|
@ -733,7 +730,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
var resultExecutingContext = _resultExecutingContext;
|
||||
var resultExecutedContext = _resultExecutedContext;
|
||||
|
||||
if (resultExecutedContext == null || resultExecutingContext.Cancel == true)
|
||||
if (resultExecutedContext == null || resultExecutingContext.Cancel)
|
||||
{
|
||||
// Short-circuited by not calling next || Short-circuited by setting Cancel == true
|
||||
_logger.ResultFilterShortCircuited(filter);
|
||||
|
|
@ -766,7 +763,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
|
||||
_diagnosticSource.AfterOnResultExecuting(resultExecutingContext, filter);
|
||||
|
||||
if (_resultExecutingContext.Cancel == true)
|
||||
if (_resultExecutingContext.Cancel)
|
||||
{
|
||||
// Short-circuited by setting Cancel == true
|
||||
_logger.ResultFilterShortCircuited(filter);
|
||||
|
|
@ -857,8 +854,6 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
|
||||
case State.ResourceInsideEnd:
|
||||
{
|
||||
var result = _result;
|
||||
|
||||
if (scope == Scope.Resource)
|
||||
{
|
||||
_resourceExecutedContext = new ResourceExecutedContext(_actionContext, _filters)
|
||||
|
|
@ -991,7 +986,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
private async Task<ResultExecutedContext> InvokeNextResultFilterAwaitedAsync()
|
||||
{
|
||||
Debug.Assert(_resultExecutingContext != null);
|
||||
if (_resultExecutingContext.Cancel == true)
|
||||
if (_resultExecutingContext.Cancel)
|
||||
{
|
||||
// If we get here, it means that an async filter set cancel == true AND called next().
|
||||
// This is forbidden.
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
/// <summary>
|
||||
/// An <see cref="IActionFilter"/> which sets the appropriate headers related to response caching.
|
||||
/// </summary>
|
||||
public class ResponseCacheFilter : IActionFilter, IResponseCacheFilter
|
||||
public class ResponseCacheFilter : IResponseCacheFilter
|
||||
{
|
||||
private readonly CacheProfile _cacheProfile;
|
||||
private int? _cacheDuration;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Mvc.Internal;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
|
||||
{
|
||||
|
|
|
|||
|
|
@ -150,7 +150,6 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
|
|||
|
||||
try
|
||||
{
|
||||
var previousCount = bindingContext.ModelState.ErrorCount;
|
||||
var result = await formatter.ReadAsync(formatterContext);
|
||||
var model = result.Model;
|
||||
|
||||
|
|
@ -177,13 +176,10 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
|
|||
.MissingRequestBodyRequiredValueAccessor();
|
||||
bindingContext.ModelState.AddModelError(modelBindingKey, message);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
bindingContext.ModelState.AddModelError(modelBindingKey, ex, bindingContext.ModelMetadata);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
|
|
@ -182,7 +181,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
|
|||
bindingContext.ValueProvider
|
||||
};
|
||||
|
||||
object boundValue = null;
|
||||
object boundValue;
|
||||
|
||||
using (bindingContext.EnterNestedScope(
|
||||
elementMetadata,
|
||||
|
|
@ -355,32 +354,6 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
|
|||
}
|
||||
}
|
||||
|
||||
private static object[] RawValueToObjectArray(object rawValue)
|
||||
{
|
||||
// precondition: rawValue is not null
|
||||
|
||||
// Need to special-case String so it's not caught by the IEnumerable check which follows
|
||||
if (rawValue is string)
|
||||
{
|
||||
return new[] { rawValue };
|
||||
}
|
||||
|
||||
var rawValueAsObjectArray = rawValue as object[];
|
||||
if (rawValueAsObjectArray != null)
|
||||
{
|
||||
return rawValueAsObjectArray;
|
||||
}
|
||||
|
||||
var rawValueAsEnumerable = rawValue as IEnumerable;
|
||||
if (rawValueAsEnumerable != null)
|
||||
{
|
||||
return rawValueAsEnumerable.Cast<object>().ToArray();
|
||||
}
|
||||
|
||||
// fallback
|
||||
return new[] { rawValue };
|
||||
}
|
||||
|
||||
private static IEnumerable<string> GetIndexNamesFromValueProviderResult(ValueProviderResult valueProviderResult)
|
||||
{
|
||||
IEnumerable<string> indexNames = null;
|
||||
|
|
|
|||
|
|
@ -400,15 +400,14 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
|
|||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
AddModelError(exception, modelName, bindingContext, result);
|
||||
AddModelError(exception, modelName, bindingContext);
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddModelError(
|
||||
Exception exception,
|
||||
string modelName,
|
||||
ModelBindingContext bindingContext,
|
||||
ModelBindingResult result)
|
||||
ModelBindingContext bindingContext)
|
||||
{
|
||||
var targetInvocationException = exception as TargetInvocationException;
|
||||
if (targetInvocationException != null && targetInvocationException.InnerException != null)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
|
||||
{
|
||||
|
|
|
|||
|
|
@ -78,21 +78,11 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
|
|||
return false;
|
||||
}
|
||||
|
||||
public string Get(string key)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public IEnumerator<KeyValuePair<string, StringValues>> GetEnumerator()
|
||||
{
|
||||
return Enumerable.Empty<KeyValuePair<string, StringValues>>().GetEnumerator();
|
||||
}
|
||||
|
||||
public IList<StringValues> GetValues(string key)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool TryGetValue(string key, out StringValues value)
|
||||
{
|
||||
value = default(StringValues);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|||
/// Initializes a new instance of <see cref="CompositeValueProvider"/>.
|
||||
/// </summary>
|
||||
public CompositeValueProvider()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -275,7 +275,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Internal
|
|||
valueProvider,
|
||||
modelMetadata,
|
||||
bindingInfo: null,
|
||||
modelName: prefix ?? string.Empty);
|
||||
modelName: prefix);
|
||||
|
||||
modelBindingContext.Model = model;
|
||||
modelBindingContext.PropertyFilter = propertyFilter;
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.ModelBinding.Metadata
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.ModelBinding.Metadata
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Mvc.Formatters;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.AspNetCore.Mvc.Abstractions;
|
||||
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Routing
|
||||
|
|
|
|||
|
|
@ -2,9 +2,7 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc.Internal;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
|
|
|
|||
|
|
@ -38,12 +38,8 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
}
|
||||
|
||||
AddCorsServices(builder.Services);
|
||||
|
||||
if (setupAction != null)
|
||||
{
|
||||
builder.Services.Configure(setupAction);
|
||||
}
|
||||
|
||||
builder.Services.Configure(setupAction);
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using System.Threading.Tasks;
|
|||
using Microsoft.AspNetCore.Cors.Infrastructure;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.AspNetCore.Mvc.Internal;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Cors.Internal
|
||||
|
|
|
|||
|
|
@ -5,8 +5,6 @@ using System;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.DataAnnotations;
|
||||
using Microsoft.AspNetCore.Mvc.DataAnnotations.Internal;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
|
|
|
|||
|
|
@ -26,15 +26,12 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations.Internal
|
|||
MergeAttribute(context.Attributes, "data-val-number", GetErrorMessage(context.ModelMetadata));
|
||||
}
|
||||
|
||||
private static bool MergeAttribute(IDictionary<string, string> attributes, string key, string value)
|
||||
private static void MergeAttribute(IDictionary<string, string> attributes, string key, string value)
|
||||
{
|
||||
if (attributes.ContainsKey(key))
|
||||
if (!attributes.ContainsKey(key))
|
||||
{
|
||||
return false;
|
||||
attributes.Add(key, value);
|
||||
}
|
||||
|
||||
attributes.Add(key, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
private string GetErrorMessage(ModelMetadata modelMetadata)
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
throw new ArgumentNullException(nameof(setupAction));
|
||||
}
|
||||
|
||||
builder.Services.Configure<MvcJsonOptions>(setupAction);
|
||||
builder.Services.Configure(setupAction);
|
||||
return builder;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -99,8 +99,8 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Json.Internal
|
|||
|
||||
var response = context.HttpContext.Response;
|
||||
|
||||
string resolvedContentType = null;
|
||||
Encoding resolvedContentTypeEncoding = null;
|
||||
string resolvedContentType;
|
||||
Encoding resolvedContentTypeEncoding;
|
||||
ResponseContentTypeHelper.ResolveContentTypeAndEncoding(
|
||||
result.ContentType,
|
||||
response.ContentType,
|
||||
|
|
|
|||
|
|
@ -153,8 +153,6 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
{
|
||||
successful = false;
|
||||
|
||||
var exception = eventArgs.ErrorContext.Error;
|
||||
|
||||
// Handle path combinations such as "" + "Property", "Parent" + "Property", or "Parent" + "[12]".
|
||||
var key = eventArgs.ErrorContext.Path;
|
||||
if (!string.IsNullOrEmpty(context.ModelName))
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Xml
|
|||
return null;
|
||||
}
|
||||
|
||||
return _wrappingTypeConstructor.Invoke(new object[] { original, _wrapperProvider });
|
||||
return _wrappingTypeConstructor.Invoke(new[] { original, _wrapperProvider });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -166,8 +166,6 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
throw new ArgumentNullException(nameof(selectedEncoding));
|
||||
}
|
||||
|
||||
var response = context.HttpContext.Response;
|
||||
|
||||
var writerSettings = WriterSettings.Clone();
|
||||
writerSettings.Encoding = selectedEncoding;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ using System;
|
|||
using System.IO;
|
||||
using System.Text.Encodings.Web;
|
||||
using Microsoft.AspNetCore.Html;
|
||||
using Microsoft.AspNetCore.Mvc.Internal;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Localization
|
||||
{
|
||||
|
|
@ -22,7 +21,7 @@ namespace Microsoft.AspNetCore.Mvc.Localization
|
|||
/// <param name="name">The name of the string resource.</param>
|
||||
/// <param name="value">The string resource.</param>
|
||||
public LocalizedHtmlString(string name, string value)
|
||||
: this(name, value, isResourceNotFound: false, arguments: Array.Empty<string>())
|
||||
: this(name, value, isResourceNotFound: false, arguments: Array.Empty<object>())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -33,7 +32,7 @@ namespace Microsoft.AspNetCore.Mvc.Localization
|
|||
/// <param name="value">The string resource.</param>
|
||||
/// <param name="isResourceNotFound">A flag that indicates if the resource is not found.</param>
|
||||
public LocalizedHtmlString(string name, string value, bool isResourceNotFound)
|
||||
: this(name, value, isResourceNotFound, arguments: Array.Empty<string>())
|
||||
: this(name, value, isResourceNotFound, arguments: Array.Empty<object>())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,10 +52,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
AddRazorViewEngineFeatureProviders(builder);
|
||||
AddRazorViewEngineServices(builder.Services);
|
||||
|
||||
if (setupAction != null)
|
||||
{
|
||||
builder.Services.Configure(setupAction);
|
||||
}
|
||||
builder.Services.Configure(setupAction);
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
|
@ -164,7 +161,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
services.TryAddSingleton<RazorTemplateEngine, MvcRazorTemplateEngine>();
|
||||
services.TryAddSingleton<LazyMetadataReferenceFeature>();
|
||||
|
||||
services.TryAddSingleton<RazorEngine>(s =>
|
||||
services.TryAddSingleton(s =>
|
||||
{
|
||||
return RazorEngine.Create(b =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
|
|||
|
||||
private static string ReadContent(RazorCodeDocument codeDocument, string filePath)
|
||||
{
|
||||
RazorSourceDocument sourceDocument = null;
|
||||
RazorSourceDocument sourceDocument;
|
||||
if (string.IsNullOrEmpty(filePath) || string.Equals(codeDocument.Source.FileName, filePath, StringComparison.Ordinal))
|
||||
{
|
||||
sourceDocument = codeDocument.Source;
|
||||
|
|
|
|||
|
|
@ -149,9 +149,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
|
|||
SimpleLambdaExpressionSyntax node,
|
||||
IdentifierNameSyntax memberAccess)
|
||||
{
|
||||
// We want to make the new span
|
||||
var originalSpan = node.GetLocation().GetMappedLineSpan();
|
||||
|
||||
var charactersToExclude = memberAccess.Identifier.Text.Length;
|
||||
var triviaList = new SyntaxTriviaList();
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
|
|||
/// </summary>
|
||||
public class RazorViewCompiler : IViewCompiler
|
||||
{
|
||||
private readonly object _initializeLock = new object();
|
||||
private readonly object _cacheLock = new object();
|
||||
private readonly Dictionary<string, Task<CompiledViewDescriptor>> _precompiledViewLookup;
|
||||
private readonly ConcurrentDictionary<string, string> _normalizedPathLookup;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,13 +3,10 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Html;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor
|
||||
{
|
||||
|
|
@ -23,13 +20,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor
|
|||
private bool _ignoreBody;
|
||||
private HashSet<string> _ignoredSections;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref="RazorPage"/>.
|
||||
/// </summary>
|
||||
public RazorPage()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An <see cref="HttpContext"/> representing the current request execution.
|
||||
/// </summary>
|
||||
|
|
@ -284,10 +274,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor
|
|||
}
|
||||
}
|
||||
|
||||
// Working around an issue with ApiCheck tool
|
||||
/// <inheritdoc />
|
||||
public override Task<HtmlString> FlushAsync() => base.FlushAsync();
|
||||
|
||||
public override void BeginContext(int position, int length, bool isLiteral)
|
||||
{
|
||||
const string BeginContextEvent = "Microsoft.AspNetCore.Mvc.Razor.BeginInstrumentationContext";
|
||||
|
|
|
|||
|
|
@ -1,14 +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.Linq.Expressions;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||
using Microsoft.AspNetCore.Mvc.Razor.Internal;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor
|
||||
{
|
||||
|
|
|
|||
|
|
@ -273,7 +273,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor
|
|||
{
|
||||
// This means we're writing to another buffer. Use MoveTo to combine them.
|
||||
bodyWriter.Buffer.MoveTo(viewBufferTextWriter.Buffer);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
|
|||
cacheResult = new ViewLocationCacheResult(new[] { applicationRelativePath });
|
||||
}
|
||||
|
||||
cacheResult = ViewLookupCache.Set<ViewLocationCacheResult>(
|
||||
cacheResult = ViewLookupCache.Set(
|
||||
cacheKey,
|
||||
cacheResult,
|
||||
cacheEntryOptions);
|
||||
|
|
@ -384,7 +384,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
|
|||
cacheEntryOptions.AddExpirationToken(expirationToken);
|
||||
}
|
||||
|
||||
return ViewLookupCache.Set<ViewLocationCacheResult>(cacheKey, cacheResult, cacheEntryOptions);
|
||||
return ViewLookupCache.Set(cacheKey, cacheResult, cacheEntryOptions);
|
||||
}
|
||||
|
||||
// Internal for unit testing
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
// 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;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNetCore.Mvc.ApplicationParts;
|
||||
using Microsoft.AspNetCore.Razor.TagHelpers;
|
||||
|
|
|
|||
|
|
@ -2,10 +2,8 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Mvc.Abstractions;
|
||||
using Microsoft.AspNetCore.Mvc.ApplicationModels;
|
||||
using Microsoft.AspNetCore.Mvc.ApplicationParts;
|
||||
using Microsoft.AspNetCore.Mvc.Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc.Razor;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNetCore.Mvc.Internal;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
|
||||
|
|
|
|||
|
|
@ -3,12 +3,10 @@
|
|||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc.Internal;
|
||||
using Microsoft.AspNetCore.Mvc.Razor;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages.Internal;
|
||||
using Microsoft.AspNetCore.Mvc.ViewEngines;
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Html;
|
||||
using Microsoft.AspNetCore.Mvc.Razor;
|
||||
|
|
|
|||
|
|
@ -30,10 +30,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Internal
|
|||
var method = handlerDescriptor.MethodInfo;
|
||||
var parameters = handlerDescriptor.Parameters.ToArray();
|
||||
|
||||
var methodParameters = method.GetParameters();
|
||||
|
||||
var returnType = method.ReturnType;
|
||||
var returnTypeInfo = method.ReturnType.GetTypeInfo();
|
||||
if (returnType == typeof(void))
|
||||
{
|
||||
return new VoidHandlerMethod(parameters, method);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Internal
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using System.Collections.Concurrent;
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc.Abstractions;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
|
|
@ -227,21 +226,6 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Internal
|
|||
return viewStartFactories;
|
||||
}
|
||||
|
||||
private static object GetDefaultValue(ParameterInfo methodParameter)
|
||||
{
|
||||
object defaultValue = null;
|
||||
if (methodParameter.HasDefaultValue)
|
||||
{
|
||||
defaultValue = methodParameter.DefaultValue;
|
||||
}
|
||||
else if (methodParameter.ParameterType.GetTypeInfo().IsValueType)
|
||||
{
|
||||
defaultValue = Activator.CreateInstance(methodParameter.ParameterType);
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
private static Func<object, object[], Task<IActionResult>>[] GetExecutors(CompiledPageActionDescriptor actionDescriptor)
|
||||
{
|
||||
if (actionDescriptor.HandlerMethods == null || actionDescriptor.HandlerMethods.Count == 0)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure;
|
||||
|
|
@ -12,7 +11,6 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Internal
|
|||
{
|
||||
internal static class PageLoggerExtensions
|
||||
{
|
||||
private static readonly double TimestampToTicks = TimeSpan.TicksPerSecond / (double)Stopwatch.Frequency;
|
||||
private static readonly Action<ILogger, string, string[], ModelValidationState, Exception> _handlerMethodExecuting;
|
||||
private static readonly Action<ILogger, string, string, Exception> _handlerMethodExecuted;
|
||||
private static readonly Action<ILogger, object, Exception> _pageFilterShortCircuit;
|
||||
|
|
|
|||
|
|
@ -34,8 +34,6 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Internal
|
|||
return null;
|
||||
}
|
||||
|
||||
var isHandlerThePage = actionDescriptor.HandlerTypeInfo == actionDescriptor.PageTypeInfo;
|
||||
|
||||
var type = actionDescriptor.HandlerTypeInfo.AsType();
|
||||
var metadata = new ModelMetadata[properties.Count];
|
||||
for (var i = 0; i < properties.Count; i++)
|
||||
|
|
|
|||
|
|
@ -1,24 +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;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq.Expressions;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Internal;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
||||
using Microsoft.AspNetCore.Mvc.Razor;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.RazorPages
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ using System.Text;
|
|||
using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Html;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.TagHelpers.Internal;
|
||||
using Microsoft.AspNetCore.Razor.TagHelpers;
|
||||
using Microsoft.Extensions.Caching.Distributed;
|
||||
|
|
@ -81,7 +80,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers.Cache
|
|||
|
||||
while (content == null)
|
||||
{
|
||||
Task<IHtmlContent> result = null;
|
||||
Task<IHtmlContent> result;
|
||||
|
||||
// Is there any request already processing the value?
|
||||
if (!_workers.TryGetValue(key, out result))
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
|
||||
while (content == null)
|
||||
{
|
||||
Task<IHtmlContent> result = null;
|
||||
Task<IHtmlContent> result;
|
||||
|
||||
if (!MemoryCache.TryGetValue(cacheKey, out result))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,9 +23,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
private const string ExpiresOnAttributeName = "expires-on";
|
||||
private const string ExpiresAfterAttributeName = "expires-after";
|
||||
private const string ExpiresSlidingAttributeName = "expires-sliding";
|
||||
private const string CacheKeyTokenSeparator = "||";
|
||||
private const string EnabledAttributeName = "enabled";
|
||||
private static readonly char[] AttributeSeparator = new[] { ',' };
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="CacheTagHelperBase"/>.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
using System;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Html;
|
||||
using Microsoft.AspNetCore.Mvc.TagHelpers.Cache;
|
||||
|
|
@ -65,12 +64,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
throw new ArgumentNullException(nameof(output));
|
||||
}
|
||||
|
||||
IHtmlContent content = null;
|
||||
|
||||
// Create a cancellation token that will be used
|
||||
// to release the task from the memory cache.
|
||||
var tokenSource = new CancellationTokenSource();
|
||||
|
||||
IHtmlContent content;
|
||||
if (Enabled)
|
||||
{
|
||||
var cacheKey = new CacheTagKey(this);
|
||||
|
|
|
|||
|
|
@ -150,7 +150,6 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
// This instance had at least one non-empty environment (names or include) specified but none of these
|
||||
// environments matched the current environment. Suppress the output in this case.
|
||||
output.SuppressOutput();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,10 +5,8 @@ using System;
|
|||
using System.Text.Encodings.Web;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc.Razor.TagHelpers;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.Routing;
|
||||
using Microsoft.AspNetCore.Mvc.TagHelpers.Internal;
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
using Microsoft.AspNetCore.Razor.TagHelpers;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
|
|
@ -26,8 +24,6 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
|
|||
TagStructure = TagStructure.WithoutEndTag)]
|
||||
public class ImageTagHelper : UrlResolutionTagHelper
|
||||
{
|
||||
private static readonly string Namespace = typeof(ImageTagHelper).Namespace;
|
||||
|
||||
private const string AppendVersionAttributeName = "asp-append-version";
|
||||
private const string SrcAttributeName = "src";
|
||||
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers.Internal
|
|||
value = path;
|
||||
}
|
||||
|
||||
value = _cache.Set<string>(path, value, cacheEntryOptions);
|
||||
value = _cache.Set(path, value, cacheEntryOptions);
|
||||
}
|
||||
|
||||
return value;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc.Internal;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
using Microsoft.Extensions.FileSystemGlobbing;
|
||||
|
|
@ -149,7 +148,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers.Internal
|
|||
matcher.AddExcludePatterns(trimmedExcludePatterns);
|
||||
}
|
||||
|
||||
return Cache.Set<List<string>>(
|
||||
return Cache.Set(
|
||||
cacheKey,
|
||||
FindFiles(matcher),
|
||||
options);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ using System.Text.Encodings.Web;
|
|||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Html;
|
||||
using Microsoft.AspNetCore.Mvc.Razor.TagHelpers;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.Routing;
|
||||
using Microsoft.AspNetCore.Mvc.TagHelpers.Internal;
|
||||
using Microsoft.AspNetCore.Razor.TagHelpers;
|
||||
|
|
|
|||
|
|
@ -4,13 +4,10 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.Encodings.Web;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Html;
|
||||
using Microsoft.AspNetCore.Mvc.Razor;
|
||||
using Microsoft.AspNetCore.Mvc.Razor.TagHelpers;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.Routing;
|
||||
using Microsoft.AspNetCore.Mvc.TagHelpers.Internal;
|
||||
using Microsoft.AspNetCore.Razor.TagHelpers;
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue