Enable analyzers (#7789)

This commit is contained in:
Pavel Krymets 2018-05-18 10:26:42 -07:00 committed by GitHub
parent 4472c00c6f
commit a736441ca5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 74 additions and 12 deletions

View File

@ -5,6 +5,7 @@
<PropertyGroup Label="Package Versions">
<AngleSharpPackageVersion>0.9.9</AngleSharpPackageVersion>
<BenchmarkDotNetPackageVersion>0.10.13</BenchmarkDotNetPackageVersion>
<InternalAspNetCoreAnalyzersPackageVersion>2.2.0-a-preview1-aan-16524</InternalAspNetCoreAnalyzersPackageVersion>
<InternalAspNetCoreSdkPackageVersion>2.2.0-preview1-17051</InternalAspNetCoreSdkPackageVersion>
<MicrosoftAspNetCoreAnalyzerTestingPackageVersion>2.2.0-preview1-34184</MicrosoftAspNetCoreAnalyzerTestingPackageVersion>
<MicrosoftAspNetCoreAntiforgeryPackageVersion>2.2.0-preview1-34184</MicrosoftAspNetCoreAntiforgeryPackageVersion>

View File

@ -3,5 +3,6 @@
<ItemGroup>
<PackageReference Include="Internal.AspNetCore.Sdk" PrivateAssets="All" Version="$(InternalAspNetCoreSdkPackageVersion)" />
<PackageReference Include="Internal.AspNetCore.Analyzers" PrivateAssets="All" Version="$(InternalAspNetCoreAnalyzersPackageVersion)" />
</ItemGroup>
</Project>

View File

@ -19,7 +19,10 @@ namespace Microsoft.AspNetCore.Mvc.Controllers
public ControllerFactoryProvider(
IControllerActivatorProvider activatorProvider,
IControllerFactory controllerFactory,
IEnumerable<IControllerPropertyActivator> propertyActivators)
#pragma warning disable PUB0001 // Pubternal type in public API
IEnumerable<IControllerPropertyActivator> propertyActivators
#pragma warning restore PUB0001
)
{
if (activatorProvider == null)
{

View File

@ -18,7 +18,9 @@ namespace Microsoft.AspNetCore.Mvc.Controllers
/// Creates a new <see cref="DefaultControllerActivator"/>.
/// </summary>
/// <param name="typeActivatorCache">The <see cref="ITypeActivatorCache"/>.</param>
#pragma warning disable PUB0001 // Pubternal type in public API
public DefaultControllerActivator(ITypeActivatorCache typeActivatorCache)
#pragma warning restore PUB0001
{
if (typeActivatorCache == null)
{

View File

@ -29,7 +29,10 @@ namespace Microsoft.AspNetCore.Mvc.Controllers
/// </param>
public DefaultControllerFactory(
IControllerActivator controllerActivator,
IEnumerable<IControllerPropertyActivator> propertyActivators)
#pragma warning disable PUB0001 // Pubternal type in public API
IEnumerable<IControllerPropertyActivator> propertyActivators
#pragma warning restore PUB0001
)
{
if (controllerActivator == null)
{

View File

@ -67,7 +67,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
throw new ArgumentException(Resources.FormatArgument_InvalidOffsetLength(nameof(offset), nameof(length)));
}
}
_parameterParser = default(MediaTypeParameterParser);
var typeLength = GetTypeLength(mediaType, offset, out var type);
@ -393,7 +393,9 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
/// <param name="mediaType">The media type to parse.</param>
/// <param name="start">The position at which the parsing starts.</param>
/// <returns>The parsed media type with its associated quality.</returns>
#pragma warning disable PUB0001 // Pubternal type in public API
public static MediaTypeSegmentWithQuality CreateMediaTypeSegmentWithQuality(string mediaType, int start)
#pragma warning restore PUB0001
{
var parsedMediaType = new MediaType(mediaType, start, length: null);

View File

@ -46,7 +46,9 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
public CultureInfo Culture => _culture;
#pragma warning disable PUB0001 // Pubternal type in public API
protected PrefixContainer PrefixContainer
#pragma warning restore PUB0001
{
get
{

View File

@ -52,7 +52,9 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
public CultureInfo Culture { get; }
/// <inheritdoc />
#pragma warning disable PUB0001 // Pubternal type in public API
protected PrefixContainer PrefixContainer
#pragma warning restore PUB0001
{
get
{

View File

@ -101,7 +101,9 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
public abstract ValidationVisitor GetValidationVisitor(
ActionContext actionContext,
IModelValidatorProvider validatorProvider,
#pragma warning disable PUB0001 // Pubternal type in public API
ValidatorCache validatorCache,
#pragma warning restore PUB0001
IModelMetadataProvider metadataProvider,
ValidationStateDictionary validationState);
}

View File

@ -46,7 +46,9 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
public CultureInfo Culture => _culture;
#pragma warning disable PUB0001 // Pubternal type in public API
protected PrefixContainer PrefixContainer
#pragma warning restore PUB0001
{
get
{

View File

@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
}
/// <summary>
/// Creates a new <see cref="RouteValueProvider"/>.
/// Creates a new <see cref="RouteValueProvider"/>.
/// </summary>
/// <param name="bindingSource">The <see cref="BindingSource"/> of the data.</param>
/// <param name="values">The values.</param>
@ -57,7 +57,9 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
Culture = culture;
}
#pragma warning disable PUB0001 // Pubternal type in public API
protected PrefixContainer PrefixContainer
#pragma warning restore PUB0001
{
get
{

View File

@ -26,7 +26,9 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Validation
public ValidationVisitor(
ActionContext actionContext,
IModelValidatorProvider validatorProvider,
#pragma warning disable PUB0001 // Pubternal type in public API
ValidatorCache validatorCache,
#pragma warning restore PUB0001
IModelMetadataProvider metadataProvider,
ValidationStateDictionary validationState)
{
@ -58,11 +60,15 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Validation
protected IModelValidatorProvider ValidatorProvider { get; }
protected IModelMetadataProvider MetadataProvider { get; }
#pragma warning disable PUB0001 // Pubternal type in public API
protected ValidatorCache Cache { get; }
#pragma warning restore PUB0001
protected ActionContext Context { get; }
protected ModelStateDictionary ModelState { get; }
protected ValidationStateDictionary ValidationState { get; }
#pragma warning disable PUB0001 // Pubternal type in public API
protected ValidationStack CurrentPath { get; }
#pragma warning restore PUB0001
protected object Container { get; set; }
protected string Key { get; set; }

View File

@ -43,7 +43,12 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
/// <param name="factory">The factory containing the private <see cref="IMemoryCache"/> instance
/// used by the <see cref="CacheTagHelper"/>.</param>
/// <param name="htmlEncoder">The <see cref="HtmlEncoder"/> to use.</param>
public CacheTagHelper(CacheTagHelperMemoryCacheFactory factory, HtmlEncoder htmlEncoder) : base(htmlEncoder)
public CacheTagHelper(
#pragma warning disable PUB0001 // Pubternal type in public API
CacheTagHelperMemoryCacheFactory factory,
#pragma warning restore PUB0001
HtmlEncoder htmlEncoder)
: base(htmlEncoder)
{
MemoryCache = factory.Cache;
}

View File

@ -204,7 +204,9 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
protected JavaScriptEncoder JavaScriptEncoder { get; }
// Internal for ease of use when testing.
#pragma warning disable PUB0001 // Pubternal type in public API
protected internal GlobbingUrlBuilder GlobbingUrlBuilder { get; set; }
#pragma warning restore PUB0001
// Shared writer for determining the string content of a TagHelperAttribute's Value.
private StringWriter StringWriter

View File

@ -32,7 +32,10 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
public PartialTagHelper(
ICompositeViewEngine viewEngine,
IViewBufferScope viewBufferScope)
#pragma warning disable PUB0001 // Pubternal type in public API
IViewBufferScope viewBufferScope
#pragma warning restore PUB0001
)
{
_viewEngine = viewEngine ?? throw new ArgumentNullException(nameof(viewEngine));
_viewBufferScope = viewBufferScope ?? throw new ArgumentNullException(nameof(viewBufferScope));

View File

@ -168,7 +168,9 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
protected JavaScriptEncoder JavaScriptEncoder { get; }
// Internal for ease of use when testing.
#pragma warning disable PUB0001 // Pubternal type in public API
protected internal GlobbingUrlBuilder GlobbingUrlBuilder { get; set; }
#pragma warning restore PUB0001
// Shared writer for determining the string content of a TagHelperAttribute's Value.
private StringWriter StringWriter

View File

@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
/// <remarks>
/// The <see cref="DefaultViewComponentActivator"/> can provide the current instance of
/// <see cref="ViewComponentContext"/> to a public property of a view component marked
/// with <see cref="ViewComponentContextAttribute"/>.
/// with <see cref="ViewComponentContextAttribute"/>.
/// </remarks>
public class DefaultViewComponentActivator : IViewComponentActivator
{
@ -25,7 +25,9 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
/// <param name="typeActivatorCache">
/// The <see cref="ITypeActivatorCache"/> used to create new view component instances.
/// </param>
#pragma warning disable PUB0001 // Pubternal type in public API
public DefaultViewComponentActivator(ITypeActivatorCache typeActivatorCache)
#pragma warning restore PUB0001
{
if (typeActivatorCache == null)
{
@ -44,7 +46,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
}
var componentType = context.ViewComponentDescriptor.TypeInfo;
if (componentType == null)
{
throw new ArgumentException(Resources.FormatPropertyOfTypeCannotBeNull(

View File

@ -41,7 +41,10 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
HtmlEncoder htmlEncoder,
IViewComponentSelector selector,
IViewComponentInvokerFactory invokerFactory,
IViewBufferScope viewBufferScope)
#pragma warning disable PUB0001 // Pubternal type in public API
IViewBufferScope viewBufferScope
#pragma warning restore PUB0001
)
{
if (descriptorProvider == null)
{

View File

@ -32,7 +32,9 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
/// <param name="logger">The <see cref="ILogger"/>.</param>
public DefaultViewComponentInvoker(
IViewComponentFactory viewComponentFactory,
#pragma warning disable PUB0001 // Pubternal type in public API
ViewComponentInvokerCache viewComponentInvokerCache,
#pragma warning restore PUB0001
DiagnosticSource diagnosticSource,
ILogger logger)
{

View File

@ -17,7 +17,9 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
public DefaultViewComponentInvokerFactory(
IViewComponentFactory viewComponentFactory,
#pragma warning disable PUB0001 // Pubternal type in public API
ViewComponentInvokerCache viewComponentInvokerCache,
#pragma warning restore PUB0001
DiagnosticSource diagnosticSource,
ILoggerFactory loggerFactory)
{

View File

@ -30,7 +30,10 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
public DefaultValidationHtmlAttributeProvider(
IOptions<MvcViewOptions> optionsAccessor,
IModelMetadataProvider metadataProvider,
ClientValidatorCache clientValidatorCache)
#pragma warning disable PUB0001 // Pubternal type in public API
ClientValidatorCache clientValidatorCache
#pragma warning restore PUB0001
)
{
if (optionsAccessor == null)
{

View File

@ -43,7 +43,9 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
IHtmlGenerator htmlGenerator,
ICompositeViewEngine viewEngine,
IModelMetadataProvider metadataProvider,
#pragma warning disable PUB0001 // Pubternal type in public API
IViewBufferScope bufferScope,
#pragma warning restore PUB0001
HtmlEncoder htmlEncoder,
UrlEncoder urlEncoder)
{

View File

@ -24,10 +24,15 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
IHtmlGenerator htmlGenerator,
ICompositeViewEngine viewEngine,
IModelMetadataProvider metadataProvider,
#pragma warning disable PUB0001 // Pubternal type in public API
IViewBufferScope bufferScope,
#pragma warning restore PUB0001
HtmlEncoder htmlEncoder,
UrlEncoder urlEncoder,
ExpressionTextCache expressionTextCache)
#pragma warning disable PUB0001 // Pubternal type in public API
ExpressionTextCache expressionTextCache
#pragma warning restore PUB0001
)
: base(
htmlGenerator,
viewEngine,

View File

@ -23,7 +23,10 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
/// <param name="expressionTextCache">The <see cref="ExpressionTextCache"/>.</param>
public ModelExpressionProvider(
IModelMetadataProvider modelMetadataProvider,
ExpressionTextCache expressionTextCache)
#pragma warning disable PUB0001 // Pubternal type in public API
ExpressionTextCache expressionTextCache
#pragma warning restore PUB0001
)
{
if (modelMetadataProvider == null)
{