This project uses source generation to generate interfaces and proxy-classes to facilitate dependency injection and better unit-testability.
This project uses source generation to generate an IHttpClient interface and HttpClientProxy from the System.Net.Http.HttpClient class.
All the methods and properties from the HttpClient class are replicated to a generated IHttpClient. And a generated HttpClientProxy wraps the HttpClient class.
var httpClient = new HttpClient();
IHttpClient httpClientProxy = new HttpClientProxy(httpClient);
var result = await httpClientProxy.GetAsync("https://www.google.nl");
var todo = await httpClientProxy.GetFromJsonAsync<Todo>("https://jsonplaceholder.typicode.com/todos/1");
var postResult = await httpClientProxy.PostAsJsonAsync("https://jsonplaceholder.typicode.com/todos", new Todo { Id = 123 });
var patchResult = await httpClientProxy.PatchAsJsonAsync("https://jsonplaceholder.typicode.com/todos/1", new Todo { Id = 400 });
var putResult = await httpClientProxy.PutAsJsonAsync("https://jsonplaceholder.typicode.com/todos/1", new Todo { Id = 444 });This project uses source generation to generate an IPing interface and PingProxy from the System.Net.NetworkInformation.Ping class.
All the methods and properties from the Ping class are replicated to a generated IPing. And a generated PingProxy wraps the Ping class.
using System;
using System.Net.NetworkInformation;
var pingProxy = new PingProxy(new Ping());
var reply = await pingProxy.SendPingAsync("localhost", TimeSpan.FromSeconds(1));
Console.WriteLine(reply.Status);This project uses source generation to generate an ITcpClient interface and TcpClientProxy from the System.Net.Sockets.TcpClient class.
All the methods and properties from the TcpClient class are replicated to ITcpClient and a generated TcpClientProxy wraps the TcpClient class.
using System.Linq;
using System.Net;
using System.Net.Sockets;
var tcpClient = new TcpClient();
var tcpClientProxy = new TcpClientProxy(tcpClient);
tcpClientProxy.SendTimeout = 123;
var hostName = Dns.GetHostName();
var address = Dns.GetHostAddresses(hostName).First(a => a.AddressFamily == AddressFamily.InterNetwork);
await tcpClientProxy.ConnectAsync(address, 80);This project uses source generation to generate an IUdpClient interface and UdpClientProxy from the System.Net.Sockets.UdpClient class.
All the methods and properties from the UdpClient class are replicated to IUdpClient and a generated UdpClientProxy wraps the UdpClient class.
using System.Net;
using System.Net.Sockets;
var udpClient = new UdpClient(Dns.GetHostName(), 0);
var udpClientProxy = new UdpClientProxy(udpClient);
udpClientProxy.Ttl = 129;
await udpClientProxy.SendAsync("hello"u8.ToArray());Entity Framework Extensions and Dapper Plus are major sponsors and proud to contribute to the development of IHttpClient, IPing, ITcpClient and IUdpClient.

