Skip to content

New route analysers don't appear to support regex #52268

Open
@mcm-ham

Description

@mcm-ham

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

After upgrading to .NET 8 this line:

[HttpGet(@"{platform:alpha}/{locale:regex([[a-z]]+(-[[a-z]]+)?)}")]

Now generates these errors

I18nController.cs(26,66): error ASP0017: Route issue: There is an incomplete parameter in the route template. Check that each '{' character has a matching '}' character. (https://aka.ms/aspnet/analyzers)
I18nController.cs(26,66): error ASP0017: Route issue: There is an incomplete parameter in the route template. Check that each '{' character has a matching '}' character. (https://aka.ms/aspnet/analyzers)
I18nController.cs(26,32): error ASP0017: Route issue: An optional parameter must be at the end of the segment. In the segment '{locale:regex([[a-z]]+(-[[a-z]]+)?)}', optional parameter 'locale' is followed by ')}'. (https://aka.ms/aspnet/analyzers)

Do these new analysers support regex constraint?

Expected Behavior

The new analysers to support regex constraint.

Steps To Reproduce

https://github.com/mcm-ham/bugrepro-routeissue

Exceptions (if any)

No response

.NET Version

8.0.100

Anything else?

dotnet info
.NET SDK:
Version: 8.0.100
Commit: 57efcf1350
Workload version: 8.0.100-manifests.6c33ef20

Runtime Environment:
OS Name: Mac OS X
OS Version: 14.1
OS Platform: Darwin
RID: osx-arm64
Base Path: /usr/local/share/dotnet/sdk/8.0.100/

.NET workloads installed:
Workload version: 8.0.100-manifests.6c33ef20
There are no installed workloads to display.

Host:
Version: 8.0.0
Architecture: arm64
Commit: 5535e31a71

.NET SDKs installed:
6.0.414 [/usr/local/share/dotnet/sdk]
7.0.401 [/usr/local/share/dotnet/sdk]
8.0.100 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.22 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.11 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.22 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.11 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
None

Environment variables:
Not set

vscode about
Version: 1.84.2
Commit: 1a5daa3a0231a0fbba4f14db7ec463cf99d7768e
Date: 2023-11-09T10:52:57.054Z
Electron: 25.9.2
ElectronBuildId: 24603566
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Darwin arm64 23.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    analyzerIndicates an issue which is related to analyzer experiencearea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesbugThis issue describes a behavior which is not expected - a bug.feature-routing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions