class

Analyzer::CSharp::AspNetCoreMvc

Inherits Analyzer::CSharp::Common < Analyzer < FileHelper < Reference < Object

Constants

ACCEPT_VERB_TOKENS = ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS", "QUERY"] of ::String

ASP.NET Core routing has always accepted an arbitrary method string through [AcceptVerbs(...)]; QUERY (RFC 10008) ships natively as HttpMethods.Query starting with .NET 10.

ACCEPT_VERBS_RE = /\[AcceptVerbs\s*\(([^\]]*)\)\s*\]/

[AcceptVerbs("PUT", "PATCH")] / [AcceptVerbs("PUT", Route = "Bank")] declares an action answering several verbs at one route — the MVC equivalent of stacking [HttpPut] and [HttpPatch]. It was ignored entirely, so such actions fell back to the conventional GET route.

ACCEPT_VERBS_ROUTE_RE = /\bRoute\s*=\s*@?"([^"]+)"/
DEFAULT_ROUTE = "{controller=Home}/{action=Index}/{id?}"
FROM_ATTRIBUTE_PATTERNS = {"FromQuery" => "query", "FromRoute" => "path", "FromBody" => "json", "FromHeader" => "header", "FromForm" => "form", "FromCookie" => "cookie", "FromServices" => "service", "FromKeyedServices" => "service"}.map do |attr, type| {"[#{attr}", /\[#{attr}[^\]]*\]/, type} end

Crystal recompiles an interpolated regex literal on every evaluation (a full PCRE2 JIT compile). The [FromX] attribute set is fixed, so precompile its markers and strippers once at load time; the param-name regex interpolates a discovered name and is memoized.

VERB_ATTRIBUTES = {"[HttpPost" => {"POST", "HttpPost"}, "[HttpGet" => {"GET", "HttpGet"}, "[HttpPut" => {"PUT", "HttpPut"}, "[HttpDelete" => {"DELETE", "HttpDelete"}, "[HttpPatch" => {"PATCH", "HttpPatch"}, "[HttpHead" => {"HEAD", "HttpHead"}, "[HttpOptions" => {"OPTIONS", "HttpOptions"}}

Attribute name carrying each verb, for extract_attribute_route.

Class methods

tech_name
Source

Instance methods

analyze
Source
tech

Instance-side view of the same declaration. The per-file rescues live on this base class, which has no way to name the analyzer that is running inside them, so a skipped file could not be attributed to a tech. Deriving it from analyzer_for keeps the name written exactly once.

Source