.NET Blog

Professional .NET development tips and best practices

RestClient.Net 7: Compile-Time Safety and OpenAPI MCP Generation

RestClient.Net 7: Compile-Time Safety and OpenAPI MCP Generation

RestClient.Net 7 is a complete architectural rewrite from the ground up, bringing discriminated union-style Result types, compile-time exhaustiveness checking, and Model Context Protocol integration to C#. As a C# type-safe REST client, it follows C# HttpClient best practices while adding compile-time guarantees. If you’ve been burned by hidden exceptions or missed error cases in production, RestClient.Net 7 is the right choice for you. The Problem: C# Doesn’t Have Exhaustive Pattern Matching on Type Traditional C# pattern matching has a critical flaw that causes production bugs: public enum Status { Success, Error, Pending } // This compiles just fine... var result = status switch { Status.Success => "OK", Status.Error => "Failed", // Missing Status.Pending case }; // ...but throws SwitchExpressionException at runtime! When you’re making HTTP calls, you have multiple distinct failure modes: success responses, client errors (400s), server errors (500s),...
Christian Findlay Christian Findlay Oct 21, 2025