Skip to content

Commit

Permalink
Project documentation update (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
devodo authored Nov 26, 2022
1 parent 1ec9132 commit 2927579
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 8 deletions.
8 changes: 5 additions & 3 deletions docs/About.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
5 changes: 2 additions & 3 deletions src/DivertR.DynamicProxy/DivertR.DynamicProxy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
<Title>DivertR.DynamicProxy</Title>
<Authors>David Naylor</Authors>
<Description>
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
</Description>
<Copyright>MIT Copyright (c) David Naylor</Copyright>
<PackageProjectUrl>https://github.com/devodo/DivertR</PackageProjectUrl>
<PackageTags>divert diverter divertr dynamicproxy proxy factory via class mock</PackageTags>
<PackageTags>divert diverter divertr castle dynamicproxy proxy factory via class mock mocking</PackageTags>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
Expand Down
28 changes: 28 additions & 0 deletions src/DivertR.DynamicProxy/README.md
Original file line number Diff line number Diff line change
@@ -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());
```
4 changes: 2 additions & 2 deletions src/DivertR/DivertR.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<PropertyGroup>
<Title>DivertR</Title>
<Authors>David Naylor</Authors>
<Description>.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.</Description>
<Description>.NET mocking framework for integration testing</Description>
<Copyright>MIT Copyright (c) David Naylor</Copyright>
<PackageProjectUrl>https://github.com/devodo/DivertR</PackageProjectUrl>
<PackageTags>test testing divert diverter diversion redirect retarget relay intercept via substitute mock spy proxy di dependency injection</PackageTags>
<PackageTags>divert divertr diverter via redirect retarget relay reset test testing proxy mock mocking intercept substitute spy di dependency injection webapplicationfactory testserver</PackageTags>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
Expand Down

0 comments on commit 2927579

Please sign in to comment.