From 7a040f310bf83ed5a731a506b693eb5054cb1637 Mon Sep 17 00:00:00 2001 From: John Luo Date: Fri, 19 Apr 2019 18:49:07 -0700 Subject: [PATCH] Enable Pubternal API checks (#9530) * Enable Pubternal API checks * Use pragma * Convert to pragma * Test fix * Remove extra restore dependencies --- Directory.Build.props | 4 ++++ .../JsonPatch/src/Adapters/AdapterFactory.cs | 2 ++ .../JsonPatch/src/Adapters/IAdapterFactory.cs | 4 +++- src/Hosting/TestHost/src/ClientHandler.cs | 2 ++ .../Routing/src/Template/TemplateBinder.cs | 18 +++++++++++------- src/Http/Routing/src/Tree/TreeRouteBuilder.cs | 4 ++-- src/Http/Routing/src/Tree/TreeRouter.cs | 4 ++-- src/Installers/Debian/Directory.Build.props | 1 + src/Mvc/test/WebSites/Directory.Build.props | 3 +++ src/Tools/Directory.Build.props | 1 + 10 files changed, 31 insertions(+), 12 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index b49a722dc7..da12b272ad 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -79,6 +79,10 @@ + + + + Debug diff --git a/src/Features/JsonPatch/src/Adapters/AdapterFactory.cs b/src/Features/JsonPatch/src/Adapters/AdapterFactory.cs index 82aaa56a70..078f83e175 100644 --- a/src/Features/JsonPatch/src/Adapters/AdapterFactory.cs +++ b/src/Features/JsonPatch/src/Adapters/AdapterFactory.cs @@ -13,7 +13,9 @@ namespace Microsoft.AspNetCore.JsonPatch.Adapters public class AdapterFactory : IAdapterFactory { /// +#pragma warning disable PUB0001 public virtual IAdapter Create(object target, IContractResolver contractResolver) +#pragma warning restore PUB0001 { if (target == null) { diff --git a/src/Features/JsonPatch/src/Adapters/IAdapterFactory.cs b/src/Features/JsonPatch/src/Adapters/IAdapterFactory.cs index 43ca1e65b6..050c513cb4 100644 --- a/src/Features/JsonPatch/src/Adapters/IAdapterFactory.cs +++ b/src/Features/JsonPatch/src/Adapters/IAdapterFactory.cs @@ -12,11 +12,13 @@ namespace Microsoft.AspNetCore.JsonPatch.Adapters public interface IAdapterFactory { /// - /// Creates an for the current object + /// Creates an for the current object /// /// The target object /// The current contract resolver /// The needed +#pragma warning disable PUB0001 IAdapter Create(object target, IContractResolver contractResolver); +#pragma warning restore PUB0001 } } diff --git a/src/Hosting/TestHost/src/ClientHandler.cs b/src/Hosting/TestHost/src/ClientHandler.cs index f672939cdf..e10c3ffebc 100644 --- a/src/Hosting/TestHost/src/ClientHandler.cs +++ b/src/Hosting/TestHost/src/ClientHandler.cs @@ -31,7 +31,9 @@ namespace Microsoft.AspNetCore.TestHost /// /// The base path. /// The . +#pragma warning disable PUB0001 public ClientHandler(PathString pathBase, IHttpApplication application) +#pragma warning restore PUB0001 { _application = application ?? throw new ArgumentNullException(nameof(application)); diff --git a/src/Http/Routing/src/Template/TemplateBinder.cs b/src/Http/Routing/src/Template/TemplateBinder.cs index efc46f3781..e0f72fdfa5 100644 --- a/src/Http/Routing/src/Template/TemplateBinder.cs +++ b/src/Http/Routing/src/Template/TemplateBinder.cs @@ -47,7 +47,9 @@ namespace Microsoft.AspNetCore.Routing.Template "to create TemplateBinder instances.")] public TemplateBinder( UrlEncoder urlEncoder, +#pragma warning disable PUB0001 ObjectPool pool, +#pragma warning restore PUB0001 RouteTemplate template, RouteValueDictionary defaults) : this(urlEncoder, pool, template?.ToRoutePattern(), defaults, requiredKeys: null, parameterPolicies: null) @@ -70,7 +72,9 @@ namespace Microsoft.AspNetCore.Routing.Template "to create TemplateBinder instances.")] public TemplateBinder( UrlEncoder urlEncoder, +#pragma warning disable PUB0001 ObjectPool pool, +#pragma warning restore PUB0001 RoutePattern pattern, RouteValueDictionary defaults, IEnumerable requiredKeys, @@ -305,7 +309,7 @@ namespace Microsoft.AspNetCore.Routing.Template // // We can still generate a URL from this ("/a") but we shouldn't accept 'c' because // we can't use it. - // + // // In the example above we should fall into this block for 'b'. copyAmbientValues = false; } @@ -328,11 +332,11 @@ namespace Microsoft.AspNetCore.Routing.Template if (hasAmbientValue && (RoutePartsEqual(requiredValue, ambientValue) || RoutePattern.IsRequiredValueAny(requiredValue))) { - // Treat this an an explicit value to *force it*. + // Treat this an an explicit value to *force it*. slots[i] = new KeyValuePair(key, ambientValue); hasExplicitValue = true; value = ambientValue; - } + } } // If the parameter is a match, add it to the list of values we will use for URI generation @@ -346,7 +350,7 @@ namespace Microsoft.AspNetCore.Routing.Template } else if (parameter.IsOptional || parameter.IsCatchAll) { - // Value isn't needed for optional or catchall parameters - wipe out the key, so it + // Value isn't needed for optional or catchall parameters - wipe out the key, so it // will be omitted from the RVD. slots[i] = default; } @@ -567,13 +571,13 @@ namespace Microsoft.AspNetCore.Routing.Template } else { - // If the value is not accepted, it is null or empty value in the + // If the value is not accepted, it is null or empty value in the // middle of the segment. We accept this if the parameter is an // optional parameter and it is preceded by an optional seperator. // In this case, we need to remove the optional seperator that we // have added to the URI // Example: template = {id}.{format?}. parameters: id=5 - // In this case after we have generated "5.", we wont find any value + // In this case after we have generated "5.", we wont find any value // for format, so we remove '.' and generate 5. if (!context.Accept(converted, parameterPart.EncodeSlashes)) { @@ -739,7 +743,7 @@ namespace Microsoft.AspNetCore.Routing.Template return slots; } - // This represents an 'explicit null' in the slots array. + // This represents an 'explicit null' in the slots array. [DebuggerDisplay("explicit null")] private class SentinullValue { diff --git a/src/Http/Routing/src/Tree/TreeRouteBuilder.cs b/src/Http/Routing/src/Tree/TreeRouteBuilder.cs index ba4bdefdfa..31024de23c 100644 --- a/src/Http/Routing/src/Tree/TreeRouteBuilder.cs +++ b/src/Http/Routing/src/Tree/TreeRouteBuilder.cs @@ -34,9 +34,9 @@ namespace Microsoft.AspNetCore.Routing.Tree [Obsolete("This constructor will be marked internal in a future release. Use the service provider to create instances of TreeRouteBuilder.")] public TreeRouteBuilder( ILoggerFactory loggerFactory, -#pragma warning disable CS0618 // Type or member is obsolete +#pragma warning disable CS0618, PUB0001 // Type or member is obsolete ObjectPool objectPool, -#pragma warning restore CS0618 // Type or member is obsolete +#pragma warning restore CS0618, PUB0001 // Type or member is obsolete IInlineConstraintResolver constraintResolver) { if (loggerFactory == null) diff --git a/src/Http/Routing/src/Tree/TreeRouter.cs b/src/Http/Routing/src/Tree/TreeRouter.cs index 46828b94dd..69b9b5085f 100644 --- a/src/Http/Routing/src/Tree/TreeRouter.cs +++ b/src/Http/Routing/src/Tree/TreeRouter.cs @@ -45,9 +45,9 @@ namespace Microsoft.AspNetCore.Routing.Tree UrlMatchingTree[] trees, IEnumerable linkGenerationEntries, UrlEncoder urlEncoder, -#pragma warning disable CS0618 // Type or member is obsolete +#pragma warning disable CS0618, PUB0001 // Type or member is obsolete ObjectPool objectPool, -#pragma warning restore CS0618 // Type or member is obsolete +#pragma warning restore CS0618, PUB0001 // Type or member is obsolete ILogger routeLogger, ILogger constraintLogger, int version) diff --git a/src/Installers/Debian/Directory.Build.props b/src/Installers/Debian/Directory.Build.props index c0e9981de7..f235d1ee8a 100644 --- a/src/Installers/Debian/Directory.Build.props +++ b/src/Installers/Debian/Directory.Build.props @@ -1,6 +1,7 @@ true + true diff --git a/src/Mvc/test/WebSites/Directory.Build.props b/src/Mvc/test/WebSites/Directory.Build.props index 2ec275baa1..16d5bfcfea 100644 --- a/src/Mvc/test/WebSites/Directory.Build.props +++ b/src/Mvc/test/WebSites/Directory.Build.props @@ -1,4 +1,7 @@ + + true + diff --git a/src/Tools/Directory.Build.props b/src/Tools/Directory.Build.props index b4dcdb53d4..2778f5a4bb 100644 --- a/src/Tools/Directory.Build.props +++ b/src/Tools/Directory.Build.props @@ -2,6 +2,7 @@ true $(MSBuildThisFileDirectory)Shared\ + true