Skip to content

Ability to use route pattern analyzer in non-web projects #52532

Open
@TheDusty01

Description

@TheDusty01

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

When working on a web project that involves a separate shared project which contains route definitions (e.g. with a class named ApiRoutes), the current syntax highlighting support is limited to the web project.

The absence of route syntax highlighting in the shared project makes the development experience worse and challenging to have a consistent setup across projects.

Describe the solution you'd like

To address this issue effectively, it would be beneficial to provide developers with the option to choose whether they want to enable syntax highlighting for route definitions in shared projects (for example through NuGet packages).
This flexibility ensures that developers can tailor their coding environment to best suit their preferences and workflow requirements.

Reference for route syntax highlighting:
https://github.com/dotnet/aspnetcore/tree/main/src/Framework/AspNetCoreAnalyzers/src/Analyzers/RouteEmbeddedLanguage

Additional context

Current workaround:
To get syntax highlighting for routes in non web projects you can add <FrameworkReference Include="Microsoft.AspNetCore.App" /> to your .csproj file.

Sample:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
  </ItemGroup>

</Project>

Metadata

Metadata

Assignees

No one assigned

    Labels

    analyzerIndicates an issue which is related to analyzer experiencearea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templates

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions