name: aspnet
language: csharp
description: "ASP.NET Core MVC + Web API attribute-routed controllers (with class-level [Route] prefix concat)"

detection:
  file_patterns:
    - "**/*.cs"
  markers:
    - pattern: "using Microsoft.AspNetCore"
      type: import
    - pattern: "[ApiController]"
      type: attribute
    - pattern: ": ControllerBase"
      type: base_class
    - pattern: ": Controller"
      type: base_class

# `[HttpGet("/api/users")]`, `[HttpPost("/api/users")]`, etc. The path
# argument is optional — `[HttpGet]` alone is valid and inherits the
# class-level `[Route(...)]` prefix as its full path. Verb attributes
# whose path starts with `/` are absolute and bypass the prefix; the
# `[controller]` token in `[Route("api/[controller]")]` expands to the
# controller class name (lowercased, `Controller` suffix stripped).
endpoint_extraction:
  file_prefix:
    regex: "\\[Route\\s*\\(\\s*[\"']([^\"']+)[\"']\\s*\\)\\s*\\]"
    prefix_group: 1
    expand_controller_token: true
  patterns:
    - regex: "\\[Http(Get|Post|Put|Delete|Patch|Options|Head)(?:\\s*\\(\\s*[\"']([^\"']+)[\"']\\s*\\))?\\s*\\]"
      method_group: 1
      path_group: 2
