Enable Pubternal API checks (#9530)

* Enable Pubternal API checks

* Use pragma

* Convert to pragma

* Test fix

* Remove extra restore dependencies
This commit is contained in:
John Luo 2019-04-19 18:49:07 -07:00 committed by GitHub
parent 0831456fac
commit 7a040f310b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 31 additions and 12 deletions

View File

@ -79,6 +79,10 @@
<PackageReference Include="Microsoft.SourceLink.Vsts.Git" Version="$(MicrosoftSourceLinkVstsGitPackageVersion)" PrivateAssets="All" AllowExplicitReference="true" /> <PackageReference Include="Microsoft.SourceLink.Vsts.Git" Version="$(MicrosoftSourceLinkVstsGitPackageVersion)" PrivateAssets="All" AllowExplicitReference="true" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(DisablePubternalApiCheck)' != 'true' AND '$(IsTestProject)' != 'true' AND '$(IsBenchmarkProject)' != 'true' AND '$(IsTestAssetProject)' != 'true'">
<PackageReference Include="Internal.AspNetCore.Analyzers" PrivateAssets="All" Version="$(InternalAspNetCoreAnalyzersPackageVersion)" AllowExplicitReference="true" />
</ItemGroup>
<!-- Compilation options which apply to all languages. Language-specific options should be set in eng/targets/$(lang).Common.props --> <!-- Compilation options which apply to all languages. Language-specific options should be set in eng/targets/$(lang).Common.props -->
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>

View File

@ -13,7 +13,9 @@ namespace Microsoft.AspNetCore.JsonPatch.Adapters
public class AdapterFactory : IAdapterFactory public class AdapterFactory : IAdapterFactory
{ {
/// <inheritdoc /> /// <inheritdoc />
#pragma warning disable PUB0001
public virtual IAdapter Create(object target, IContractResolver contractResolver) public virtual IAdapter Create(object target, IContractResolver contractResolver)
#pragma warning restore PUB0001
{ {
if (target == null) if (target == null)
{ {

View File

@ -12,11 +12,13 @@ namespace Microsoft.AspNetCore.JsonPatch.Adapters
public interface IAdapterFactory public interface IAdapterFactory
{ {
/// <summary> /// <summary>
/// Creates an <see cref="IAdapter"/> for the current object /// Creates an <see cref="IAdapter"/> for the current object
/// </summary> /// </summary>
/// <param name="target">The target object</param> /// <param name="target">The target object</param>
/// <param name="contractResolver">The current contract resolver</param> /// <param name="contractResolver">The current contract resolver</param>
/// <returns>The needed <see cref="IAdapter"/></returns> /// <returns>The needed <see cref="IAdapter"/></returns>
#pragma warning disable PUB0001
IAdapter Create(object target, IContractResolver contractResolver); IAdapter Create(object target, IContractResolver contractResolver);
#pragma warning restore PUB0001
} }
} }

View File

@ -31,7 +31,9 @@ namespace Microsoft.AspNetCore.TestHost
/// </summary> /// </summary>
/// <param name="pathBase">The base path.</param> /// <param name="pathBase">The base path.</param>
/// <param name="application">The <see cref="IHttpApplication{TContext}"/>.</param> /// <param name="application">The <see cref="IHttpApplication{TContext}"/>.</param>
#pragma warning disable PUB0001
public ClientHandler(PathString pathBase, IHttpApplication<Context> application) public ClientHandler(PathString pathBase, IHttpApplication<Context> application)
#pragma warning restore PUB0001
{ {
_application = application ?? throw new ArgumentNullException(nameof(application)); _application = application ?? throw new ArgumentNullException(nameof(application));

View File

@ -47,7 +47,9 @@ namespace Microsoft.AspNetCore.Routing.Template
"to create TemplateBinder instances.")] "to create TemplateBinder instances.")]
public TemplateBinder( public TemplateBinder(
UrlEncoder urlEncoder, UrlEncoder urlEncoder,
#pragma warning disable PUB0001
ObjectPool<UriBuildingContext> pool, ObjectPool<UriBuildingContext> pool,
#pragma warning restore PUB0001
RouteTemplate template, RouteTemplate template,
RouteValueDictionary defaults) RouteValueDictionary defaults)
: this(urlEncoder, pool, template?.ToRoutePattern(), defaults, requiredKeys: null, parameterPolicies: null) : this(urlEncoder, pool, template?.ToRoutePattern(), defaults, requiredKeys: null, parameterPolicies: null)
@ -70,7 +72,9 @@ namespace Microsoft.AspNetCore.Routing.Template
"to create TemplateBinder instances.")] "to create TemplateBinder instances.")]
public TemplateBinder( public TemplateBinder(
UrlEncoder urlEncoder, UrlEncoder urlEncoder,
#pragma warning disable PUB0001
ObjectPool<UriBuildingContext> pool, ObjectPool<UriBuildingContext> pool,
#pragma warning restore PUB0001
RoutePattern pattern, RoutePattern pattern,
RouteValueDictionary defaults, RouteValueDictionary defaults,
IEnumerable<string> requiredKeys, IEnumerable<string> 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 still generate a URL from this ("/a") but we shouldn't accept 'c' because
// we can't use it. // we can't use it.
// //
// In the example above we should fall into this block for 'b'. // In the example above we should fall into this block for 'b'.
copyAmbientValues = false; copyAmbientValues = false;
} }
@ -328,11 +332,11 @@ namespace Microsoft.AspNetCore.Routing.Template
if (hasAmbientValue && if (hasAmbientValue &&
(RoutePartsEqual(requiredValue, ambientValue) || RoutePattern.IsRequiredValueAny(requiredValue))) (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<string, object>(key, ambientValue); slots[i] = new KeyValuePair<string, object>(key, ambientValue);
hasExplicitValue = true; hasExplicitValue = true;
value = ambientValue; value = ambientValue;
} }
} }
// If the parameter is a match, add it to the list of values we will use for URI generation // 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) 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. // will be omitted from the RVD.
slots[i] = default; slots[i] = default;
} }
@ -567,13 +571,13 @@ namespace Microsoft.AspNetCore.Routing.Template
} }
else 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 // middle of the segment. We accept this if the parameter is an
// optional parameter and it is preceded by an optional seperator. // optional parameter and it is preceded by an optional seperator.
// In this case, we need to remove the optional seperator that we // In this case, we need to remove the optional seperator that we
// have added to the URI // have added to the URI
// Example: template = {id}.{format?}. parameters: id=5 // 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. // for format, so we remove '.' and generate 5.
if (!context.Accept(converted, parameterPart.EncodeSlashes)) if (!context.Accept(converted, parameterPart.EncodeSlashes))
{ {
@ -739,7 +743,7 @@ namespace Microsoft.AspNetCore.Routing.Template
return slots; return slots;
} }
// This represents an 'explicit null' in the slots array. // This represents an 'explicit null' in the slots array.
[DebuggerDisplay("explicit null")] [DebuggerDisplay("explicit null")]
private class SentinullValue private class SentinullValue
{ {

View File

@ -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.")] [Obsolete("This constructor will be marked internal in a future release. Use the service provider to create instances of TreeRouteBuilder.")]
public TreeRouteBuilder( public TreeRouteBuilder(
ILoggerFactory loggerFactory, ILoggerFactory loggerFactory,
#pragma warning disable CS0618 // Type or member is obsolete #pragma warning disable CS0618, PUB0001 // Type or member is obsolete
ObjectPool<UriBuildingContext> objectPool, ObjectPool<UriBuildingContext> objectPool,
#pragma warning restore CS0618 // Type or member is obsolete #pragma warning restore CS0618, PUB0001 // Type or member is obsolete
IInlineConstraintResolver constraintResolver) IInlineConstraintResolver constraintResolver)
{ {
if (loggerFactory == null) if (loggerFactory == null)

View File

@ -45,9 +45,9 @@ namespace Microsoft.AspNetCore.Routing.Tree
UrlMatchingTree[] trees, UrlMatchingTree[] trees,
IEnumerable<OutboundRouteEntry> linkGenerationEntries, IEnumerable<OutboundRouteEntry> linkGenerationEntries,
UrlEncoder urlEncoder, UrlEncoder urlEncoder,
#pragma warning disable CS0618 // Type or member is obsolete #pragma warning disable CS0618, PUB0001 // Type or member is obsolete
ObjectPool<UriBuildingContext> objectPool, ObjectPool<UriBuildingContext> objectPool,
#pragma warning restore CS0618 // Type or member is obsolete #pragma warning restore CS0618, PUB0001 // Type or member is obsolete
ILogger routeLogger, ILogger routeLogger,
ILogger constraintLogger, ILogger constraintLogger,
int version) int version)

View File

@ -1,6 +1,7 @@
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<OutputInRepoRoot>true</OutputInRepoRoot> <OutputInRepoRoot>true</OutputInRepoRoot>
<DisablePubternalApiCheck>true</DisablePubternalApiCheck>
</PropertyGroup> </PropertyGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\, Directory.Build.props))\Directory.Build.props" /> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\, Directory.Build.props))\Directory.Build.props" />

View File

@ -1,4 +1,7 @@
<Project> <Project>
<PropertyGroup>
<IsTestAssetProject>true</IsTestAssetProject>
</PropertyGroup>
<!-- Skip the parent folder to prevent getting test package references. --> <!-- Skip the parent folder to prevent getting test package references. -->
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\..\, Directory.Build.props))\Directory.Build.props" /> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\..\, Directory.Build.props))\Directory.Build.props" />
</Project> </Project>

View File

@ -2,6 +2,7 @@
<PropertyGroup> <PropertyGroup>
<OutputInRepoRoot>true</OutputInRepoRoot> <OutputInRepoRoot>true</OutputInRepoRoot>
<ToolSharedSourceRoot>$(MSBuildThisFileDirectory)Shared\</ToolSharedSourceRoot> <ToolSharedSourceRoot>$(MSBuildThisFileDirectory)Shared\</ToolSharedSourceRoot>
<DisablePubternalApiCheck>true</DisablePubternalApiCheck>
</PropertyGroup> </PropertyGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\, Directory.Build.props))\Directory.Build.props" /> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\, Directory.Build.props))\Directory.Build.props" />