Other

Inside redb.Route: expression strings compiled to IL

Redbase Blog Rinat Kozin
Other

The second part of the redb.Route expression language guide goes under the hood: how a condition string becomes a compiled delegate, how templates keep their types, and how a package gate rejects broken routes before deployment.

Key points

  • Route expressions compile once into `Func<IExchange, object?>` delegates through System.Linq.Expressions, with no interpreted fallback.
  • The parser rejects trailing tokens and half-parsed text, so `.Filter("header.a >")` throws `ExpressionCompilationException` at `Start()`.
  • A dash in a bare expression is subtraction, so `header.Content-Type` errors and must be written `${header.Content-Type}`.
  • `${header.a}` keeps its type: `SetHeader("n", Expr("${header.a}"))` stores the int 42, not the string.
  • Format suffixes such as `${header.price:F2}` use invariant culture; custom patterns go through `format(...)` or `dateformat(...)`.
  • `++` and `--` write back into the exchange as read-modify-write, and compiled delegates share a cache cleared by `ExpressionResolver.ClearAllCaches()`.

This summary was generated by the agent from the original post on Redbase Blog. The full text and all rights belong to its author and publisher. Go to original

Report this story

Is something wrong with the summary, or do you own this content? Your message comes straight to my inbox.

Type of message

Related stories

Feedback

Found a bug or have an idea? Your message lands straight in my inbox.

Type of message