Skip to content

Override ToString for endpoint metadata #35231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Components/Authorization/src/AuthorizeDataAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,11 @@ public string? AuthenticationSchemes
get => null;
set => throw new NotSupportedException();
}

/// <inheritdoc />
public override string ToString()
{
return $"Policy: {Policy ?? "null"}, Roles: {Roles ?? "null"}, AuthenticationSchemes: null";
}
}
}
6 changes: 6 additions & 0 deletions src/Http/Routing/src/DataTokensMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,11 @@ public DataTokensMetadata(IReadOnlyDictionary<string, object?> dataTokens)
/// Get the data tokens.
/// </summary>
public IReadOnlyDictionary<string, object?> DataTokens { get; }

/// <inheritdoc />
public override string ToString()
{
return $"Data: {string.Join(",", DataTokens.Select(token => $"{token.Key}={token.Value}"))}";
}
}
}
6 changes: 6 additions & 0 deletions src/Http/Routing/src/EndpointNameMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,11 @@ public EndpointNameMetadata(string endpointName)
/// Gets the endpoint name.
/// </summary>
public string EndpointName { get; }

/// <inheritdoc />
public override string ToString()
{
return $"Name: {EndpointName}";
}
}
}
10 changes: 10 additions & 0 deletions src/Http/Routing/src/HostAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,15 @@ private string DebuggerToString()

return $"Hosts: {hostsDisplay}";
}

/// <inheritdoc />
public override string ToString()
{
var hostsDisplay = (Hosts.Count == 0)
? "*:*"
: string.Join(",", Hosts.Select(h => h.Contains(':') ? h : h + ":*"));

return $"Hosts: {hostsDisplay}";
}
}
}
6 changes: 6 additions & 0 deletions src/Http/Routing/src/HttpMethodMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,11 @@ private string DebuggerToString()
{
return $"HttpMethods: {string.Join(",", HttpMethods)} - Cors: {AcceptCorsPreflight}";
}

/// <inheritdoc />
public override string ToString()
{
return $"HttpMethods: {string.Join(",", HttpMethods)} - Cors: {AcceptCorsPreflight}";
}
}
}
7 changes: 7 additions & 0 deletions src/Http/Routing/src/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ Microsoft.AspNetCore.Routing.Matching.IParameterLiteralNodeMatchingPolicy
Microsoft.AspNetCore.Routing.Matching.IParameterLiteralNodeMatchingPolicy.MatchesLiteral(string! parameterName, string! literal) -> bool
Microsoft.AspNetCore.Routing.RouteNameMetadata.RouteName.get -> string?
Microsoft.AspNetCore.Routing.RouteNameMetadata.RouteNameMetadata(string? routeName) -> void
override Microsoft.AspNetCore.Routing.DataTokensMetadata.ToString() -> string!
override Microsoft.AspNetCore.Routing.EndpointNameMetadata.ToString() -> string!
override Microsoft.AspNetCore.Routing.HostAttribute.ToString() -> string!
override Microsoft.AspNetCore.Routing.HttpMethodMetadata.ToString() -> string!
override Microsoft.AspNetCore.Routing.RouteNameMetadata.ToString() -> string!
override Microsoft.AspNetCore.Routing.SuppressLinkGenerationMetadata.ToString() -> string!
override Microsoft.AspNetCore.Routing.SuppressMatchingMetadata.ToString() -> string!
static Microsoft.AspNetCore.Builder.MinimalActionEndpointRouteBuilderExtensions.Map(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder! endpoints, Microsoft.AspNetCore.Routing.Patterns.RoutePattern! pattern, System.Delegate! action) -> Microsoft.AspNetCore.Builder.MinimalActionEndpointConventionBuilder!
static Microsoft.AspNetCore.Builder.MinimalActionEndpointRouteBuilderExtensions.Map(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder! endpoints, string! pattern, System.Delegate! action) -> Microsoft.AspNetCore.Builder.MinimalActionEndpointConventionBuilder!
static Microsoft.AspNetCore.Builder.MinimalActionEndpointRouteBuilderExtensions.MapDelete(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder! endpoints, string! pattern, System.Delegate! action) -> Microsoft.AspNetCore.Builder.MinimalActionEndpointConventionBuilder!
Expand Down
6 changes: 6 additions & 0 deletions src/Http/Routing/src/RouteNameMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,11 @@ internal string DebuggerToString()
{
return $"Name: {RouteName}";
}

/// <inheritdoc />
public override string ToString()
{
return $"Name: {RouteName}";
}
}
}
8 changes: 7 additions & 1 deletion src/Http/Routing/src/SuppressLinkGenerationMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,11 @@ public sealed class SuppressLinkGenerationMetadata : ISuppressLinkGenerationMeta
/// Gets a value indicating whether the assocated endpoint should be used for link generation.
/// </summary>
public bool SuppressLinkGeneration => true;

/// <inheritdoc />
public override string ToString()
{
return "SuppressLinkGeneration: true";
}
}
}
}
6 changes: 6 additions & 0 deletions src/Http/Routing/src/SuppressMatchingMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,11 @@ public sealed class SuppressMatchingMetadata : ISuppressMatchingMetadata
/// Gets a value indicating whether the associated endpoint should be used for URL matching.
/// </summary>
public bool SuppressMatching => true;

/// <inheritdoc />
public override string ToString()
{
return "SuppressMatching: true";
}
}
}
6 changes: 6 additions & 0 deletions src/Middleware/CORS/src/CorsPolicyMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,11 @@ public CorsPolicyMetadata(CorsPolicy policy)
/// The policy which needs to be applied.
/// </summary>
public CorsPolicy Policy { get; }

/// <inheritdoc />
public override string ToString()
{
return $"Policy: {Policy}";
}
}
}
6 changes: 6 additions & 0 deletions src/Middleware/CORS/src/EnableCorsAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,11 @@ public EnableCorsAttribute(string? policyName)

/// <inheritdoc />
public string? PolicyName { get; set; }

/// <inheritdoc />
public override string ToString()
{
return $"Policy: {PolicyName ?? "null"}";
}
}
}
2 changes: 2 additions & 0 deletions src/Middleware/CORS/src/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Microsoft.AspNetCore.Cors.Infrastructure.CorsResult.AllowedHeaders.get -> System
Microsoft.AspNetCore.Cors.Infrastructure.CorsResult.AllowedMethods.get -> System.Collections.Generic.IList<string!>!
Microsoft.AspNetCore.Cors.Infrastructure.CorsResult.AllowedOrigin.get -> string?
Microsoft.AspNetCore.Cors.Infrastructure.CorsResult.AllowedOrigin.set -> void
override Microsoft.AspNetCore.Cors.CorsPolicyMetadata.ToString() -> string!
override Microsoft.AspNetCore.Cors.EnableCorsAttribute.ToString() -> string!
~Microsoft.AspNetCore.Cors.Infrastructure.CorsService.CorsService(Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Cors.Infrastructure.CorsOptions!>! options, Microsoft.Extensions.Logging.ILoggerFactory! loggerFactory) -> void
Microsoft.AspNetCore.Cors.Infrastructure.CorsService.EvaluatePolicy(Microsoft.AspNetCore.Http.HttpContext! context, Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy! policy) -> Microsoft.AspNetCore.Cors.Infrastructure.CorsResult!
Microsoft.AspNetCore.Cors.Infrastructure.CorsService.EvaluatePolicy(Microsoft.AspNetCore.Http.HttpContext! context, string! policyName) -> Microsoft.AspNetCore.Cors.Infrastructure.CorsResult!
Expand Down
1 change: 1 addition & 0 deletions src/Mvc/Mvc.Core/src/ApiConventionTypeAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ internal static void EnsureValid(Type conventionType)
{
var unsupportedAttributes = method.GetCustomAttributes(inherit: true)
.Where(attribute => !IsAllowedAttribute(attribute))
.Select(attribute => attribute.GetType().FullName)
.ToArray();

if (unsupportedAttributes.Length == 0)
Expand Down
6 changes: 6 additions & 0 deletions src/Mvc/Mvc.Core/src/ProducesErrorResponseTypeAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,11 @@ public ProducesErrorResponseTypeAttribute(Type type)
/// Gets the default error type.
/// </summary>
public Type Type { get; }

/// <inheritdoc />
public override string ToString()
{
return $"Type: {Type}";
}
}
}
1 change: 1 addition & 0 deletions src/Mvc/Mvc.Core/src/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ Microsoft.AspNetCore.Mvc.Infrastructure.ActionDescriptorCollection.Items.get ->
Microsoft.AspNetCore.Mvc.Infrastructure.AmbiguousActionException.AmbiguousActionException(System.Runtime.Serialization.SerializationInfo! info, System.Runtime.Serialization.StreamingContext context) -> void
Microsoft.AspNetCore.Mvc.Infrastructure.AmbiguousActionException.AmbiguousActionException(string? message) -> void
Microsoft.AspNetCore.Mvc.Infrastructure.ContentResultExecutor.ContentResultExecutor(Microsoft.Extensions.Logging.ILogger<Microsoft.AspNetCore.Mvc.Infrastructure.ContentResultExecutor!>! logger, Microsoft.AspNetCore.Mvc.Infrastructure.IHttpResponseStreamWriterFactory! httpResponseStreamWriterFactory) -> void
override Microsoft.AspNetCore.Mvc.ProducesErrorResponseTypeAttribute.ToString() -> string!
~Microsoft.AspNetCore.Mvc.Infrastructure.DefaultOutputFormatterSelector.DefaultOutputFormatterSelector(Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Mvc.MvcOptions!>! options, Microsoft.Extensions.Logging.ILoggerFactory! loggerFactory) -> void
Microsoft.AspNetCore.Mvc.Infrastructure.FileContentResultExecutor.FileContentResultExecutor(Microsoft.Extensions.Logging.ILoggerFactory! loggerFactory) -> void
Microsoft.AspNetCore.Mvc.Infrastructure.FileResultExecutorBase.FileResultExecutorBase(Microsoft.Extensions.Logging.ILogger! logger) -> void
Expand Down
7 changes: 7 additions & 0 deletions src/Mvc/Mvc.Core/src/Routing/ConsumesMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,12 @@ public ConsumesMetadata(string[] contentTypes)
}

public IReadOnlyList<string> ContentTypes { get; }


/// <inheritdoc />
public override string ToString()
{
return $"ContentTypes: {string.Join(",", ContentTypes)}";
}
}
}
6 changes: 6 additions & 0 deletions src/Security/Authorization/Core/src/AuthorizeAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,11 @@ public AuthorizeAttribute(string policy)
/// Gets or sets a comma delimited list of schemes from which user information is constructed.
/// </summary>
public string? AuthenticationSchemes { get; set; }

/// <inheritdoc />
public override string ToString()
{
return $"Policy: {Policy ?? "null"}, Roles: {Roles ?? "null"}, AuthenticationSchemes: {AuthenticationSchemes ?? "null"}";
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#nullable enable
*REMOVED*static Microsoft.AspNetCore.Authorization.AuthorizationServiceExtensions.AuthorizeAsync(this Microsoft.AspNetCore.Authorization.IAuthorizationService! service, System.Security.Claims.ClaimsPrincipal! user, object! resource, Microsoft.AspNetCore.Authorization.IAuthorizationRequirement! requirement) -> System.Threading.Tasks.Task<Microsoft.AspNetCore.Authorization.AuthorizationResult!>!
override Microsoft.AspNetCore.Authorization.AuthorizeAttribute.ToString() -> string!
static Microsoft.AspNetCore.Authorization.AuthorizationServiceExtensions.AuthorizeAsync(this Microsoft.AspNetCore.Authorization.IAuthorizationService! service, System.Security.Claims.ClaimsPrincipal! user, object? resource, Microsoft.AspNetCore.Authorization.IAuthorizationRequirement! requirement) -> System.Threading.Tasks.Task<Microsoft.AspNetCore.Authorization.AuthorizationResult!>!