From 0d10c498237071b002ccda70726d6b9dc14db986 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 11 Mar 2019 14:25:45 -0700 Subject: [PATCH] Make IApiBehaviorMetadata public (#8410) Fixes https://github.com/aspnet/AspNetCore/issues/8403 The analyzer expects the type to be present. However since it's listed as internal, it is not present when compiling against the ref assembly \ targeting pack. It was left as internal so we could evolve it later, but we haven't found a need for it as yet. --- src/Mvc/Mvc.Analyzers/src/SymbolNames.cs | 2 +- .../Mvc.Api.Analyzers/src/ApiSymbolNames.cs | 2 +- ...rosoft.AspNetCore.Mvc.Core.netcoreapp3.0.cs | 5 ++++- src/Mvc/Mvc.Core/src/ApiControllerAttribute.cs | 1 + src/Mvc/Mvc.Core/src/IApiBehaviorMetadata.cs | 15 --------------- .../src/Infrastructure/IApiBehaviorMetadata.cs | 18 ++++++++++++++++++ 6 files changed, 25 insertions(+), 18 deletions(-) delete mode 100644 src/Mvc/Mvc.Core/src/IApiBehaviorMetadata.cs create mode 100644 src/Mvc/Mvc.Core/src/Infrastructure/IApiBehaviorMetadata.cs diff --git a/src/Mvc/Mvc.Analyzers/src/SymbolNames.cs b/src/Mvc/Mvc.Analyzers/src/SymbolNames.cs index 42d3b18af4..3b002d24e6 100644 --- a/src/Mvc/Mvc.Analyzers/src/SymbolNames.cs +++ b/src/Mvc/Mvc.Analyzers/src/SymbolNames.cs @@ -29,7 +29,7 @@ namespace Microsoft.AspNetCore.Mvc.Analyzers public const string HtmlHelperPartialExtensionsType = "Microsoft.AspNetCore.Mvc.Rendering.HtmlHelperPartialExtensions"; - public const string IApiBehaviorMetadata = "Microsoft.AspNetCore.Mvc.IApiBehaviorMetadata"; + public const string IApiBehaviorMetadata = "Microsoft.AspNetCore.Mvc.Infrastructure.IApiBehaviorMetadata"; public const string IBinderTypeProviderMetadata = "Microsoft.AspNetCore.Mvc.ModelBinding.IBinderTypeProviderMetadata"; diff --git a/src/Mvc/Mvc.Api.Analyzers/src/ApiSymbolNames.cs b/src/Mvc/Mvc.Api.Analyzers/src/ApiSymbolNames.cs index 849d07fa0b..1beb0aa41e 100644 --- a/src/Mvc/Mvc.Api.Analyzers/src/ApiSymbolNames.cs +++ b/src/Mvc/Mvc.Api.Analyzers/src/ApiSymbolNames.cs @@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Mvc.Api.Analyzers public const string DefaultStatusCodeAttribute = "Microsoft.AspNetCore.Mvc.Infrastructure.DefaultStatusCodeAttribute"; - public const string IApiBehaviorMetadata = "Microsoft.AspNetCore.Mvc.IApiBehaviorMetadata"; + public const string IApiBehaviorMetadata = "Microsoft.AspNetCore.Mvc.Infrastructure.IApiBehaviorMetadata"; public const string IActionResult = "Microsoft.AspNetCore.Mvc.IActionResult"; diff --git a/src/Mvc/Mvc.Core/ref/Microsoft.AspNetCore.Mvc.Core.netcoreapp3.0.cs b/src/Mvc/Mvc.Core/ref/Microsoft.AspNetCore.Mvc.Core.netcoreapp3.0.cs index c8dbe9009a..c19fe4e234 100644 --- a/src/Mvc/Mvc.Core/ref/Microsoft.AspNetCore.Mvc.Core.netcoreapp3.0.cs +++ b/src/Mvc/Mvc.Core/ref/Microsoft.AspNetCore.Mvc.Core.netcoreapp3.0.cs @@ -115,7 +115,7 @@ namespace Microsoft.AspNetCore.Mvc System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } } [System.AttributeUsageAttribute(System.AttributeTargets.Assembly | System.AttributeTargets.Class, AllowMultiple=false, Inherited=true)] - public partial class ApiControllerAttribute : Microsoft.AspNetCore.Mvc.ControllerAttribute, Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata + public partial class ApiControllerAttribute : Microsoft.AspNetCore.Mvc.ControllerAttribute, Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata, Microsoft.AspNetCore.Mvc.Infrastructure.IApiBehaviorMetadata { public ApiControllerAttribute() { } } @@ -1980,6 +1980,9 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor SelectBestCandidate(Microsoft.AspNetCore.Routing.RouteContext context, System.Collections.Generic.IReadOnlyList candidates); System.Collections.Generic.IReadOnlyList SelectCandidates(Microsoft.AspNetCore.Routing.RouteContext context); } + public partial interface IApiBehaviorMetadata : Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata + { + } public partial interface IClientErrorActionResult : Microsoft.AspNetCore.Mvc.IActionResult, Microsoft.AspNetCore.Mvc.Infrastructure.IStatusCodeActionResult { } diff --git a/src/Mvc/Mvc.Core/src/ApiControllerAttribute.cs b/src/Mvc/Mvc.Core/src/ApiControllerAttribute.cs index 0be60296de..e9a43dae39 100644 --- a/src/Mvc/Mvc.Core/src/ApiControllerAttribute.cs +++ b/src/Mvc/Mvc.Core/src/ApiControllerAttribute.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNetCore.Mvc.Infrastructure; namespace Microsoft.AspNetCore.Mvc { diff --git a/src/Mvc/Mvc.Core/src/IApiBehaviorMetadata.cs b/src/Mvc/Mvc.Core/src/IApiBehaviorMetadata.cs deleted file mode 100644 index 41a053ebed..0000000000 --- a/src/Mvc/Mvc.Core/src/IApiBehaviorMetadata.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using Microsoft.AspNetCore.Mvc.Filters; - -namespace Microsoft.AspNetCore.Mvc -{ - /// - /// An interface for . See - /// for details. - /// - internal interface IApiBehaviorMetadata : IFilterMetadata - { - } -} diff --git a/src/Mvc/Mvc.Core/src/Infrastructure/IApiBehaviorMetadata.cs b/src/Mvc/Mvc.Core/src/Infrastructure/IApiBehaviorMetadata.cs new file mode 100644 index 0000000000..d51060030e --- /dev/null +++ b/src/Mvc/Mvc.Core/src/Infrastructure/IApiBehaviorMetadata.cs @@ -0,0 +1,18 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNetCore.Mvc.Filters; + +namespace Microsoft.AspNetCore.Mvc.Infrastructure +{ + /// + /// A that indicates that a type and all derived types are used to serve HTTP API responses. + /// + /// Controllers decorated with this attribute () are configured with + /// features and behavior targeted at improving the developer experience for building APIs. + /// + /// + public interface IApiBehaviorMetadata : IFilterMetadata + { + } +}