Skip to content

Commit 707068e

Browse files
authored
Add StringSyntax to the RouteAttribute (#57369)
I noticed when using the `[Route("/orders/{orderId:int}")]` attribute, as an example, doesn't display the same as when using the `EndpointRouteBuilderExtensions` APIs for `Map*` that accept a template/pattern. I think it would be great if we could also highlight routes when using the attribute. This PR adds the `StringSyntax` to decorate the `template` parameter to be highlighted like the method APIs.
1 parent 85b528b commit 707068e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Components/Components/src/RouteAttribute.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Diagnostics.CodeAnalysis;
5+
46
namespace Microsoft.AspNetCore.Components;
57

68
/// <summary>
@@ -13,7 +15,7 @@ public sealed class RouteAttribute : Attribute
1315
/// Constructs an instance of <see cref="RouteAttribute"/>.
1416
/// </summary>
1517
/// <param name="template">The route template.</param>
16-
public RouteAttribute(string template)
18+
public RouteAttribute([StringSyntax("Route")] string template)
1719
{
1820
ArgumentNullException.ThrowIfNull(template);
1921

0 commit comments

Comments
 (0)