DynamicProxy generates proxies for your objects that you can use to transparently add or alter behavior to them, provide pre/post processing and many other things. Following are just a few better known and popular usages of DynamicProxy:
- Castle Windsor uses proxies to enable its interception capabilities and for typed factories
- Moq uses it to provide "the most popular and friendly mocking framework for .NET"
- NSubstitute uses it to provide "a friendly substitute for .NET mocking frameworks"
- FakeItEasy uses it to provide "the easy mocking library for .NET"
- Rhino Mocks uses it to provide "a dynamic mock object framework for the .NET platform"
- NHibernate uses it to provide lazy loading capabilities (pre-v4.0)
- Entity Framework Core uses it in its package Microsoft.EntityFrameworkCore.Proxies to provide lazy-loading proxies
If you're new to DynamicProxy you can read a quick introduction, browse through description of the core types in the library, or go into more advanced, in detail discussion:
- Kinds of proxy objects
- Leaking this
- Make proxy generation hooks purely functional
- Overriding Equals/GetHashCode on proxy generation hook
- Make your supporting classes serializable
- Use proxy generation hooks and interceptor selectors for fine grained control
- SRP applies to interceptors
- Behavior of by-reference parameters during interception
- Optional parameter value limitations
- Asynchronous interception
ℹ️ Where is Castle.DynamicProxy.dll
?: DynamicProxy used to live in its own assembly. As part of changes in version 2.5 it was merged into Castle.Core.dll
and that's where you'll find it.