Fixing style issues in Mvc.Core
This commit is contained in:
parent
ecbc179d76
commit
cf0304b897
|
|
@ -3,9 +3,9 @@
|
|||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Microsoft.AspNet.Mvc.Core;
|
||||
using Microsoft.AspNet.Security.DataProtection;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc
|
||||
{
|
||||
|
|
@ -37,7 +37,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
}
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
// swallow all exceptions - homogenize error if something went wrong
|
||||
innerException = ex;
|
||||
|
|
|
|||
|
|
@ -156,10 +156,10 @@ namespace Microsoft.AspNet.Mvc
|
|||
|
||||
Contract.Assert(_validator.IsCookieTokenValid(oldCookieToken));
|
||||
|
||||
AntiForgeryToken formToken = _generator.
|
||||
GenerateFormToken(httpContext,
|
||||
ExtractIdentity(httpContext),
|
||||
oldCookieToken);
|
||||
AntiForgeryToken formToken = _generator.GenerateFormToken(
|
||||
httpContext,
|
||||
ExtractIdentity(httpContext),
|
||||
oldCookieToken);
|
||||
|
||||
return new AntiForgeryTokenSetInternal()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ using System.Diagnostics;
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using Microsoft.AspNet.Security.DataProtection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,10 +3,9 @@
|
|||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Security.Principal;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc.Core;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc
|
||||
{
|
||||
|
|
@ -72,8 +71,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
{
|
||||
// Application says user is authenticated, but we have no identifier for the user.
|
||||
throw new InvalidOperationException(
|
||||
Resources.
|
||||
FormatTokenValidator_AuthenticatedUserWithoutUsername(identity.GetType()));
|
||||
Resources.FormatTokenValidator_AuthenticatedUserWithoutUsername(identity.GetType()));
|
||||
}
|
||||
|
||||
return formToken;
|
||||
|
|
@ -132,9 +130,8 @@ namespace Microsoft.AspNet.Mvc
|
|||
StringComparison.Ordinal :
|
||||
StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
throw new InvalidOperationException(Resources.
|
||||
FormatAntiForgeryToken_UsernameMismatch(fieldToken.Username,
|
||||
currentUsername));
|
||||
throw new InvalidOperationException(
|
||||
Resources.FormatAntiForgeryToken_UsernameMismatch(fieldToken.Username, currentUsername));
|
||||
}
|
||||
|
||||
if (!Equals(fieldToken.ClaimUid, currentClaimUid))
|
||||
|
|
|
|||
|
|
@ -22,11 +22,11 @@ namespace Microsoft.AspNet.Mvc
|
|||
// Iterate all the Reflected Action Descriptor providers and add area or other route constraints
|
||||
foreach (var actionDescriptor in context.Results.OfType<ReflectedActionDescriptor>())
|
||||
{
|
||||
var routeConstraints = actionDescriptor.
|
||||
ControllerDescriptor.
|
||||
ControllerTypeInfo.
|
||||
GetCustomAttributes<RouteConstraintAttribute>().
|
||||
ToArray();
|
||||
var routeConstraints = actionDescriptor
|
||||
.ControllerDescriptor
|
||||
.ControllerTypeInfo
|
||||
.GetCustomAttributes<RouteConstraintAttribute>()
|
||||
.ToArray();
|
||||
|
||||
foreach (var routeConstraint in routeConstraints)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,5 +14,4 @@ namespace Microsoft.AspNet.Mvc
|
|||
|
||||
public Type ParameterType { get; private set; }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -314,7 +314,6 @@ namespace Microsoft.AspNet.Mvc
|
|||
// Ex: These are not in the same equivalence class.
|
||||
// Action 1: constraint keys - { action, controller, area }
|
||||
// Action 2: constraint keys - { action, module }
|
||||
//
|
||||
private ActionDescriptor FindEquivalenceClass(ActionDescriptor[] candidates)
|
||||
{
|
||||
Contract.Assert(candidates.Length > 1);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ using System.Reflection;
|
|||
|
||||
namespace Microsoft.AspNet.Mvc
|
||||
{
|
||||
public class DefaultControllerDescriptorFactory : IControllerDescriptorFactory
|
||||
public class DefaultControllerDescriptorFactory : IControllerDescriptorFactory
|
||||
{
|
||||
public ControllerDescriptor CreateControllerDescriptor(TypeInfo typeInfo)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
|
||||
public AuthorizeAttribute(string claimType, string claimValue)
|
||||
{
|
||||
_claims = new [] { new Claim(claimType, claimValue) };
|
||||
_claims = new[] { new Claim(claimType, claimValue) };
|
||||
}
|
||||
|
||||
public AuthorizeAttribute(string claimType, string claimValue, params string[] otherClaimValues)
|
||||
|
|
@ -53,9 +53,9 @@ namespace Microsoft.AspNet.Mvc
|
|||
user.Identity == null ||
|
||||
!user.Identity.IsAuthenticated;
|
||||
|
||||
if(userIsAnonymous && !HasAllowAnonymous(context))
|
||||
if (userIsAnonymous && !HasAllowAnonymous(context))
|
||||
{
|
||||
base.Fail(context);
|
||||
Fail(context);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -71,7 +71,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
|
||||
if (!authorized)
|
||||
{
|
||||
base.Fail(context);
|
||||
Fail(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,6 @@ namespace Microsoft.AspNet.Mvc.Filters
|
|||
var orderedControllerFilter = controllerFilter as IOrderedFilter;
|
||||
if (orderedControllerFilter != null)
|
||||
{
|
||||
|
||||
order = orderedControllerFilter.Order;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,10 @@ namespace Microsoft.AspNet.Mvc
|
|||
{
|
||||
private static readonly FilterDescriptorOrderComparer _comparer = new FilterDescriptorOrderComparer();
|
||||
|
||||
public static FilterDescriptorOrderComparer Comparer { get { return _comparer; } }
|
||||
public static FilterDescriptorOrderComparer Comparer
|
||||
{
|
||||
get { return _comparer; }
|
||||
}
|
||||
|
||||
public int Compare([NotNull]FilterDescriptor x, [NotNull]FilterDescriptor y)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,7 +9,10 @@ namespace Microsoft.AspNet.Mvc
|
|||
{
|
||||
private static readonly FilterItemOrderComparer _comparer = new FilterItemOrderComparer();
|
||||
|
||||
public static FilterItemOrderComparer Comparer { get { return _comparer; } }
|
||||
public static FilterItemOrderComparer Comparer
|
||||
{
|
||||
get { return _comparer; }
|
||||
}
|
||||
|
||||
public int Compare([NotNull] FilterItem x, [NotNull] FilterItem y)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
|
@ -36,9 +35,10 @@ namespace Microsoft.AspNet.Mvc
|
|||
/// If the object is already an <see cref="IDictionary{string, object}"/> instance, then a copy
|
||||
/// is returned.
|
||||
/// </summary>
|
||||
//
|
||||
// The implementation of PropertyHelper will cache the property accessors per-type. This is
|
||||
// faster when the the same type is used multiple times with ObjectToDictionary.
|
||||
/// <remarks>
|
||||
/// The implementation of PropertyHelper will cache the property accessors per-type. This is
|
||||
/// faster when the the same type is used multiple times with ObjectToDictionary.
|
||||
/// </remarks>
|
||||
public static IDictionary<string, object> ObjectToDictionary(object value)
|
||||
{
|
||||
var dictionary = value as IDictionary<string, object>;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
using System.Text;
|
||||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.Internal
|
||||
{
|
||||
|
|
|
|||
|
|
@ -40,8 +40,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
new CompositeModelBinder(_modelBinders),
|
||||
new CompositeValueProvider(valueProviders),
|
||||
_inputFormatterProvider,
|
||||
_validatorProviders
|
||||
);
|
||||
_validatorProviders);
|
||||
|
||||
return Task.FromResult(context);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,13 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNet.Mvc.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.ExceptionServices;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc.Core;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc
|
||||
{
|
||||
|
|
@ -128,11 +127,10 @@ namespace Microsoft.AspNet.Mvc
|
|||
if (innerTaskType != null && typeof(Task).IsAssignableFrom(innerTaskType))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
Resources.FormatActionExecutor_WrappedTaskInstance(
|
||||
methodName,
|
||||
declaringType,
|
||||
actualTypeReturned.FullName
|
||||
));
|
||||
Resources.FormatActionExecutor_WrappedTaskInstance(
|
||||
methodName,
|
||||
declaringType,
|
||||
actualTypeReturned.FullName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -281,7 +281,6 @@ namespace Microsoft.AspNet.Mvc
|
|||
|
||||
var inputFormatter = actionBindingContext.InputFormatterProvider.GetInputFormatter(providerContext);
|
||||
|
||||
|
||||
var formatterContext = new InputFormatterContext(actionBindingContext.ActionContext.HttpContext,
|
||||
modelMetadata,
|
||||
modelState);
|
||||
|
|
@ -519,7 +518,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
ActionMethod,
|
||||
ResultFilters,
|
||||
ActionResult
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A one-way cursor for filters.
|
||||
|
|
@ -543,44 +542,44 @@ namespace Microsoft.AspNet.Mvc
|
|||
/// </remarks>
|
||||
private struct FilterCursor
|
||||
{
|
||||
private FilterStage Stage;
|
||||
private int Index;
|
||||
private readonly IFilter[] Filters;
|
||||
private FilterStage _stage;
|
||||
private int _index;
|
||||
private readonly IFilter[] _filters;
|
||||
|
||||
public FilterCursor(FilterStage stage, int index, IFilter[] filters)
|
||||
{
|
||||
Stage = stage;
|
||||
Index = index;
|
||||
Filters = filters;
|
||||
_stage = stage;
|
||||
_index = index;
|
||||
_filters = filters;
|
||||
}
|
||||
|
||||
public FilterCursor(IFilter[] filters)
|
||||
{
|
||||
Stage = FilterStage.Undefined;
|
||||
Index = 0;
|
||||
Filters = filters;
|
||||
_stage = FilterStage.Undefined;
|
||||
_index = 0;
|
||||
_filters = filters;
|
||||
}
|
||||
|
||||
public void SetStage(FilterStage stage)
|
||||
{
|
||||
Stage = stage;
|
||||
Index = 0;
|
||||
_stage = stage;
|
||||
_index = 0;
|
||||
}
|
||||
|
||||
public FilterCursorItem<TFilter, TFilterAsync> GetNextFilter<TFilter, TFilterAsync>()
|
||||
where TFilter : class
|
||||
where TFilterAsync : class
|
||||
{
|
||||
while (Index < Filters.Length)
|
||||
while (_index < _filters.Length)
|
||||
{
|
||||
var filter = Filters[Index] as TFilter;
|
||||
var filterAsync = Filters[Index] as TFilterAsync;
|
||||
var filter = _filters[_index] as TFilter;
|
||||
var filterAsync = _filters[_index] as TFilterAsync;
|
||||
|
||||
Index += 1;
|
||||
_index += 1;
|
||||
|
||||
if (filter != null || filterAsync != null)
|
||||
{
|
||||
return new FilterCursorItem<TFilter, TFilterAsync>(Stage, Index, filter, filterAsync);
|
||||
return new FilterCursorItem<TFilter, TFilterAsync>(_stage, _index, filter, filterAsync);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -589,7 +588,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
|
||||
public bool StillAt<TFilter, TFilterAsync>(FilterCursorItem<TFilter, TFilterAsync> current)
|
||||
{
|
||||
return current.Stage == Stage && current.Index == Index;
|
||||
return current.Stage == _stage && current.Index == _index;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ namespace Microsoft.AspNet.Mvc.Rendering.Expressions
|
|||
[NotNull] ViewDataDictionary viewData,
|
||||
IModelMetadataProvider metadataProvider)
|
||||
{
|
||||
if(string.IsNullOrEmpty(expression))
|
||||
if (string.IsNullOrEmpty(expression))
|
||||
{
|
||||
return viewData.ModelMetadata;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1291,7 +1291,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
|||
var modelErrors = tryGetModelStateResult ? modelState.Errors : null;
|
||||
|
||||
ModelError modelError = null;
|
||||
if(modelErrors != null && modelErrors.Count != 0)
|
||||
if (modelErrors != null && modelErrors.Count != 0)
|
||||
{
|
||||
modelError = modelErrors.FirstOrDefault(m => !string.IsNullOrEmpty(m.ErrorMessage)) ?? modelErrors[0];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,12 +98,11 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
|||
public HtmlString DisplayNameForInnerType<TInnerModel, TValue>(
|
||||
[NotNull] Expression<Func<TInnerModel, TValue>> expression)
|
||||
{
|
||||
var metadata = ExpressionMetadataProvider.
|
||||
FromLambdaExpression<TInnerModel, TValue>(
|
||||
expression,
|
||||
new ViewDataDictionary<TInnerModel>(
|
||||
MetadataProvider),
|
||||
MetadataProvider);
|
||||
var metadata = ExpressionMetadataProvider.FromLambdaExpression<TInnerModel, TValue>(
|
||||
expression,
|
||||
new ViewDataDictionary<TInnerModel>(MetadataProvider),
|
||||
MetadataProvider);
|
||||
|
||||
var expressionText = ExpressionHelper.GetExpressionText(expression);
|
||||
if (metadata == null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -125,7 +125,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
|||
private IEnumerable<string> GetViewNames()
|
||||
{
|
||||
var metadata = _viewData.ModelMetadata;
|
||||
var templateHints = new string[] {
|
||||
var templateHints = new string[]
|
||||
{
|
||||
_templateName,
|
||||
metadata.TemplateHint,
|
||||
metadata.DataTypeName
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
|||
/// <returns>
|
||||
/// The display name for the model.
|
||||
/// </returns>
|
||||
public static HtmlString DisplayNameFor<TInnerModel,TValue>(
|
||||
public static HtmlString DisplayNameFor<TInnerModel, TValue>(
|
||||
[NotNull] this IHtmlHelper<IEnumerable<TInnerModel>> htmlHelper,
|
||||
[NotNull] Expression<Func<TInnerModel, TValue>> expression)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
|||
public static HtmlString TextArea([NotNull] this IHtmlHelper htmlHelper,
|
||||
string name, object htmlAttributes)
|
||||
{
|
||||
return htmlHelper.TextArea(name, value: null, rows: 0, columns:0, htmlAttributes: htmlAttributes);
|
||||
return htmlHelper.TextArea(name, value: null, rows: 0, columns: 0, htmlAttributes: htmlAttributes);
|
||||
}
|
||||
|
||||
public static HtmlString TextArea([NotNull] this IHtmlHelper htmlHelper,
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNet.Mvc.ModelBinding;
|
||||
using Microsoft.AspNet.Mvc.Core;
|
||||
using Microsoft.AspNet.Mvc.ModelBinding;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.Rendering
|
||||
{
|
||||
|
|
|
|||
|
|
@ -66,7 +66,6 @@ namespace Microsoft.AspNet.Mvc
|
|||
result = await InvokeAsyncCore(asyncMethod, context.ViewContext);
|
||||
}
|
||||
|
||||
|
||||
await result.ExecuteAsync(context);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
var components =
|
||||
types
|
||||
.Where(ViewComponentConventions.IsComponent)
|
||||
.Select(c => new {Name = ViewComponentConventions.GetComponentName(c), Type = c.AsType()});
|
||||
.Select(c => new { Name = ViewComponentConventions.GetComponentName(c), Type = c.AsType() });
|
||||
|
||||
var matching =
|
||||
components
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ namespace Microsoft.AspNet.Mvc.Core.Test
|
|||
#pragma warning disable 1998
|
||||
public async Task<int> TaskValueTypeAction(int i, string s)
|
||||
{
|
||||
Console.WriteLine(s);
|
||||
return i;
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
|
|
@ -59,13 +58,11 @@ namespace Microsoft.AspNet.Mvc.Core.Test
|
|||
|
||||
public TaskDerivedType TaskActionWithCustomTaskReturnType(int i, string s)
|
||||
{
|
||||
Console.WriteLine(s);
|
||||
return new TaskDerivedType();
|
||||
}
|
||||
|
||||
public TaskOfTDerivedType<int> TaskActionWithCustomTaskOfTReturnType(int i, string s)
|
||||
{
|
||||
Console.WriteLine(s);
|
||||
return new TaskOfTDerivedType<int>(1);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue