module Analyzer::CSharp::MinimalApiSupport

Direct including types

Defined in:

analyzer/analyzers/csharp/minimal_api_support.cr

Constant Summary

MAP_ANY_PREFIX_RE = /\.?\s*Map(?:Get|Post|Put|Delete|Patch|Head|Options|Methods)?\s*(?:<[^<>()]*>\s*)?\(/
MAP_CALL_RE = /\bMap(?:Get|Post|Put|Delete|Patch|Head|Options|Methods)?\s*(?:<[^<>()]*>\s*)?\(/
MAP_METHODS = ["Get", "Post", "Put", "Delete", "Patch", "Head", "Options"] of ::String
MAP_METHODS_RE = /(?:\b([A-Za-z_][A-Za-z0-9_]*)\s*\.\s*)?MapMethods\s*(?:<[^<>()]*>\s*)?\(\s*(?:[A-Za-z_][A-Za-z0-9_]*\s*:\s*)?@?"([^"]+)"\s*,\s*([\s\S]+?)(?:=>|\);)/m
MAP_VERB_ROUTE_RE = /(?:\b([A-Za-z_][A-Za-z0-9_]*)\s*\.\s*)?Map(Get|Post|Put|Delete|Patch|Head|Options)\s*(?:<[^<>()]*>\s*)?\(\s*(?:[A-Za-z_][A-Za-z0-9_]*\s*:\s*)?@?"([^"]+)"/m

Map<Verb> may carry an explicit generic argument — Carter's app.MapPut<Person>("/", …) and the typed MapGet<T> helpers some libraries ship. Without the optional <…> the route literal was never reached and the registration produced no endpoint at all.

MINIMAL_API_MARKER_RE = /\.\s*Map(?:Get|Post|Put|Delete|Patch|Head|Options|Methods)\s*(?:<[^<>()]*>\s*)?\(/
SERVICE_BINDING_TYPES = Set {"CancellationToken", "HttpContext", "HttpRequest", "HttpResponse", "ClaimsPrincipal", "IServiceProvider", "ILogger", "ILoggerFactory", "LinkGenerator"}
SIMPLE_BINDING_TYPES = Set {"bool", "byte", "sbyte", "short", "ushort", "int", "uint", "long", "ulong", "float", "double", "decimal", "char", "string", "Guid", "DateTime", "DateTimeOffset", "TimeSpan"}