diff --git a/docs/About.md b/docs/About.md index da9c22fd..064e4663 100644 --- a/docs/About.md +++ b/docs/About.md @@ -10,7 +10,9 @@ DivertR was born out of the need to efficiently modify DI configurations between It has grown into a framework that facilitates testing of wired up systems, bringing a familiar unit/mocking testing style into the realm of component and integration testing, by providing features to conveniently substitute dependency behaviour (including error conditions) and verify inputs and outputs from recorded call information. -# Interfaces Only +# DispatchProxy -DivertR uses the .NET Standard [DispatchProxy](https://learn.microsoft.com/en-us/dotnet/api/system.reflection.dispatchproxy) to build proxies and this is limited to interface types only. -Although other proxy generators that support classes such as DynamicProxy can be used, calls to non-virtual members cannot be intercepted and this can cause inconsistent behaviour e.g. when wrapping root instances. +The default DivertR proxy factory is implemented using [System.Reflection.DispatchProxy](https://learn.microsoft.com/en-us/dotnet/api/system.reflection.dispatchproxy). As this is part of the .NET Standard 2.1, DivertR therefore does not have any dependencies on external libraries however it is limited to proxying interface types only. + +If class proxies are required, [DivertR.DynamicProxy](../src/DivertR.DynamicProxy/README.md) is an alternative proxy factory implemented using [Castle DynamicProxy](http://www.castleproject.org/projects/dynamicproxy/) that does support classes. +However, when proxying classes, care should be taken as only calls to non-virtual members cannot be intercepted, this can cause inconsistent behaviour e.g. when wrapping root instances. diff --git a/src/DivertR.DynamicProxy/DivertR.DynamicProxy.csproj b/src/DivertR.DynamicProxy/DivertR.DynamicProxy.csproj index c8b8ac21..9a93a880 100644 --- a/src/DivertR.DynamicProxy/DivertR.DynamicProxy.csproj +++ b/src/DivertR.DynamicProxy/DivertR.DynamicProxy.csproj @@ -4,12 +4,11 @@ DivertR.DynamicProxy David Naylor - A DivertR IProxyFactory implementation using Castle DynamicProxy with support for proxying class types. - The in-built proxy factory is based on DispatchProxy and therefore only supports proxying interfaces. The proxy factory to use can be specified in DiverterSettings. + A DivertR proxy factory implementation that supports proxying class types using Castle DynamicProxy MIT Copyright (c) David Naylor https://github.com/devodo/DivertR - divert diverter divertr dynamicproxy proxy factory via class mock + divert diverter divertr castle dynamicproxy proxy factory via class mock mocking netstandard2.0;netstandard2.1 MIT git diff --git a/src/DivertR.DynamicProxy/README.md b/src/DivertR.DynamicProxy/README.md new file mode 100644 index 00000000..b6e73502 --- /dev/null +++ b/src/DivertR.DynamicProxy/README.md @@ -0,0 +1,28 @@ +# DivertR DynamicProxy + +[![nuget](https://img.shields.io/nuget/v/DivertR.DynamicProxy.svg)](https://www.nuget.org/packages/DivertR.DynamicProxy) +[![build](https://github.com/devodo/DivertR/actions/workflows/build.yml/badge.svg)](https://github.com/devodo/DivertR/actions/workflows/build.yml) + +A [DivertR](https://github.com/devodo/DivertR) proxy factory implementation that supports proxying class types using [Castle DynamicProxy](http://www.castleproject.org/projects/dynamicproxy/). + +# Installing + +Install DivertR as a [NuGet package](https://www.nuget.org/packages/DivertR): + +```sh +Install-Package DivertR +``` + +Or via the .NET command line interface: + +```sh +dotnet add package DivertR +``` + +# Example Usage + +Configure DivertR to use DynamicProxy: + +```csharp +DiverterSettings.Global = new DiverterSettings(proxyFactory: new DynamicProxyFactory()); +``` diff --git a/src/DivertR/DivertR.csproj b/src/DivertR/DivertR.csproj index bb60fec5..ee4288bf 100644 --- a/src/DivertR/DivertR.csproj +++ b/src/DivertR/DivertR.csproj @@ -3,10 +3,10 @@ DivertR David Naylor - .NET Dependency Injection Diversion - Facilitating an integrated approach to testing by making it easy to hotswap test code in and out at the DI layer. + .NET mocking framework for integration testing MIT Copyright (c) David Naylor https://github.com/devodo/DivertR - test testing divert diverter diversion redirect retarget relay intercept via substitute mock spy proxy di dependency injection + divert divertr diverter via redirect retarget relay reset test testing proxy mock mocking intercept substitute spy di dependency injection webapplicationfactory testserver netstandard2.0;netstandard2.1 MIT git