A .NET library that replaces any method (including static and non-virtual) with a delegate at runtime using managed code.
Pose is a .NET library that allows developers to replace any .NET method—including static, non-virtual, and instance methods—with custom delegate implementations at runtime. It solves the problem of mocking difficult-to-test code by providing a fully managed, in-memory shimming mechanism without requiring assembly rewriting on disk.
.NET developers writing unit tests who need to mock static methods, non-virtual methods, or third-party dependencies that are challenging to isolate with traditional mocking frameworks.
Developers choose Pose because it offers a purely managed code solution for method replacement, works cross-platform, and provides capabilities similar to Microsoft Fakes without the overhead of unmanaged APIs or file system modifications.
Replace any .NET method (including static and non-virtual) with a delegate
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses Reflection Emit API entirely in managed code, avoiding unmanaged Profiling APIs and keeping assemblies untouched on disk, as highlighted in the README's philosophy.
Targets .NET Standard 2.0, supporting .NET Framework, .NET Core, Mono, and Xamarin, making it versatile for diverse .NET environments.
Can shim static methods, instance methods, properties, and constructors for both reference and value types, providing extensive mocking capabilities beyond traditional frameworks.
PoseContext.Isolate allows applying shims within a controlled block, ensuring test isolation without affecting other code, as demonstrated in the usage examples.
Breakpoints in isolated code do not hit, complicating debugging during test development, as admitted in the Caveats & Limitations section.
Unhandled exceptions are wrapped in TargetInvocationException, making stack traces confusing and hindering error diagnosis, a noted limitation in the README.
The roadmap mentions performance improvements for production use, indicating current inefficiencies that may slow down test execution or limit broader application.
pose is an open-source alternative to the following products: