Skip to content

Quickly test and compare .NET query string binding across both Minimal APIs and Controllers.

License

Notifications You must be signed in to change notification settings

jacobjmarks/QueryStringDetective.NET

Repository files navigation

.NET Query String Detective

An online tool to quickly and effortlessly test and compare the behaviour of .NET's query string binding across both minimal APIs and controller-based APIs1.

screenshot

How does it work?

Input queries are sent to a set of in-memory test server (TestServer) instances — a component which fuels .NET's integration testing capabilities2 — one which wraps an API built with minimal APIs, and another which wraps an API built with Controllers.

Using source generators3, these test servers define a number of endpoints which utilise the FromQuery attribute to bind (or, attempt to bind) the incoming query string parameter q to a given target type.

A distinct (in-memory) request is sent to each test server for all target types, and these binding results are collated by the caller and returned to the client. To summarize:

flowchart LR
   client["Client<br>[Blazor WASM]"]
   subgraph "Server [Azure Function App]"
    func["Evaluator<br>[Azure Function]"]
    func -->|forward query| tsA[["[TestServer] (Minimal APIs)"]]
    func -->|forward query| tsB[["[TestServer] (Controllers)"]]
   end
   client -->|send query| func
Loading

Footnotes

  1. Choose between controller-based APIs and minimal APIs | Microsoft Learn

  2. Integration tests in ASP.NET Core | Microsoft Learn

  3. Source Generators | Microsoft Learn

About

Quickly test and compare .NET query string binding across both Minimal APIs and Controllers.

Resources

License

Stars

Watchers

Forks