Enforce invariants without cluttering business logic:
public class ValidationInterceptor : IInterceptor
public void Intercept(IInvocation invocation)
foreach (var arg in invocation.Arguments)
if (arg == null) throw new ArgumentNullException();
Validator.ValidateObject(arg, new ValidationContext(arg), true);
invocation.Proceed();
You can compose interceptors:
var proxy = ProxyBuilder.For<IUserService>()
.WithInterceptor(new ValidationInterceptor())
.WithInterceptor(new CachingInterceptor(cache))
.WithInterceptor(new LoggingRetryInterceptor(logger))
.Create();
Execution order follows registration (outermost first, then Proceed() chains inward). made with reflect4 proxy high quality
High-quality implementations include automatic proxy blacklisting. If a proxy fails three times in a row, Reflect4 removes it from rotation instantly.
Reflect4 achieves high quality through several design decisions: You can compose interceptors: var proxy = ProxyBuilder
| Feature | Benefit |
|---------|---------|
| Cached delegate dispatch | Each method call resolves to a precompiled delegate – no MethodInfo.Invoke overhead. |
| Struct-based invocations | Avoids heap allocations for each call. |
| Reusable argument arrays | When possible, arrays are pooled. |
| Async-aware | Properly handles Task / ValueTask without blocking or extra state machines. |
Benchmarks (conceptual):
This makes Reflect4 suitable for hot paths like API gateways, database repositories, and message handlers.
Reflect4 emits debuggable IL. Set a breakpoint inside an interceptor – the call stack will show original method names. You can also attach a debugger to generated assembly if needed. 10s for mobile proxies
Retailers need to track competitors’ prices across hundreds of SKUs daily. A Reflect4-based proxy ensures each request comes from a different residential IP in the correct geographic region, preventing rate limiting and bans.
High-quality implementations use adaptive timeouts (e.g., 10s for mobile proxies, 5s for residential, 3s for datacenter).