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"> <PropertyGroup Label="Package Versions">
<AngleSharpPackageVersion>0.9.9</AngleSharpPackageVersion> <AngleSharpPackageVersion>0.9.9</AngleSharpPackageVersion>
<BenchmarkDotNetPackageVersion>0.10.13</BenchmarkDotNetPackageVersion> <BenchmarkDotNetPackageVersion>0.10.13</BenchmarkDotNetPackageVersion>
<InternalAspNetCoreAnalyzersPackageVersion>2.2.0-a-preview1-aan-16524</InternalAspNetCoreAnalyzersPackageVersion>
<InternalAspNetCoreSdkPackageVersion>2.2.0-preview1-17051</InternalAspNetCoreSdkPackageVersion> <InternalAspNetCoreSdkPackageVersion>2.2.0-preview1-17051</InternalAspNetCoreSdkPackageVersion>
<MicrosoftAspNetCoreAnalyzerTestingPackageVersion>2.2.0-preview1-34184</MicrosoftAspNetCoreAnalyzerTestingPackageVersion> <MicrosoftAspNetCoreAnalyzerTestingPackageVersion>2.2.0-preview1-34184</MicrosoftAspNetCoreAnalyzerTestingPackageVersion>
<MicrosoftAspNetCoreAntiforgeryPackageVersion>2.2.0-preview1-34184</MicrosoftAspNetCoreAntiforgeryPackageVersion> <MicrosoftAspNetCoreAntiforgeryPackageVersion>2.2.0-preview1-34184</MicrosoftAspNetCoreAntiforgeryPackageVersion>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -26,7 +26,9 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Validation
public ValidationVisitor( public ValidationVisitor(
ActionContext actionContext, ActionContext actionContext,
IModelValidatorProvider validatorProvider, IModelValidatorProvider validatorProvider,
#pragma warning disable PUB0001 // Pubternal type in public API
ValidatorCache validatorCache, ValidatorCache validatorCache,
#pragma warning restore PUB0001
IModelMetadataProvider metadataProvider, IModelMetadataProvider metadataProvider,
ValidationStateDictionary validationState) ValidationStateDictionary validationState)
{ {
@ -58,11 +60,15 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Validation
protected IModelValidatorProvider ValidatorProvider { get; } protected IModelValidatorProvider ValidatorProvider { get; }
protected IModelMetadataProvider MetadataProvider { get; } protected IModelMetadataProvider MetadataProvider { get; }
#pragma warning disable PUB0001 // Pubternal type in public API
protected ValidatorCache Cache { get; } protected ValidatorCache Cache { get; }
#pragma warning restore PUB0001
protected ActionContext Context { get; } protected ActionContext Context { get; }
protected ModelStateDictionary ModelState { get; } protected ModelStateDictionary ModelState { get; }
protected ValidationStateDictionary ValidationState { get; } protected ValidationStateDictionary ValidationState { get; }
#pragma warning disable PUB0001 // Pubternal type in public API
protected ValidationStack CurrentPath { get; } protected ValidationStack CurrentPath { get; }
#pragma warning restore PUB0001
protected object Container { get; set; } protected object Container { get; set; }
protected string Key { 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 /// <param name="factory">The factory containing the private <see cref="IMemoryCache"/> instance
/// used by the <see cref="CacheTagHelper"/>.</param> /// used by the <see cref="CacheTagHelper"/>.</param>
/// <param name="htmlEncoder">The <see cref="HtmlEncoder"/> to use.</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; MemoryCache = factory.Cache;
} }

View File

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

View File

@ -32,7 +32,10 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
public PartialTagHelper( public PartialTagHelper(
ICompositeViewEngine viewEngine, 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)); _viewEngine = viewEngine ?? throw new ArgumentNullException(nameof(viewEngine));
_viewBufferScope = viewBufferScope ?? throw new ArgumentNullException(nameof(viewBufferScope)); _viewBufferScope = viewBufferScope ?? throw new ArgumentNullException(nameof(viewBufferScope));

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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